Skip to content

Commit fdf84bf

Browse files
Rollup merge of rust-lang#130875 - folkertdev:naked-asm-bootstrap, r=tgross35
update `compiler-builtins` to 0.1.126 this requires the addition of a bootstrap variant of the new `naked_asm!` macro r? `@tgross35` extracted from rust-lang#128651
2 parents 1b3f488 + 1341724 commit fdf84bf

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010

1111
[dependencies]
1212
core = { path = "../core" }
13-
compiler_builtins = { version = "0.1.125", features = ['rustc-dep-of-std'] }
13+
compiler_builtins = { version = "0.1.126", features = ['rustc-dep-of-std'] }
1414

1515
[dev-dependencies]
1616
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

core/src/arch.rs

+34
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#[allow(unused_imports)]
44
#[stable(feature = "simd_arch", since = "1.27.0")]
55
pub use crate::core_arch::arch::*;
6+
#[unstable(feature = "naked_functions", issue = "90957")]
7+
#[cfg(bootstrap)]
8+
pub use crate::naked_asm;
69

710
/// Inline assembly.
811
///
@@ -17,6 +20,37 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
1720
/* compiler built-in */
1821
}
1922

23+
/// Inline assembly used in combination with `#[naked]` functions.
24+
///
25+
/// Refer to [Rust By Example] for a usage guide and the [reference] for
26+
/// detailed information about the syntax and available options.
27+
///
28+
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
29+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
30+
#[unstable(feature = "naked_functions", issue = "90957")]
31+
#[macro_export]
32+
#[cfg(bootstrap)]
33+
macro_rules! naked_asm {
34+
([$last:expr], [$($pushed:expr),*]) => {
35+
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
36+
{
37+
core::arch::asm!($($pushed),*, options(att_syntax, noreturn))
38+
}
39+
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
40+
{
41+
core::arch::asm!($($pushed),* , $last, options(noreturn))
42+
}
43+
};
44+
45+
([$first:expr $(, $rest:expr)*], [$($pushed:expr),*]) => {
46+
naked_asm!([$($rest),*], [$($pushed,)* $first]);
47+
};
48+
49+
($($expr:expr),* $(,)?) => {
50+
naked_asm!([$($expr),*], []);
51+
};
52+
}
53+
2054
/// Inline assembly used in combination with `#[naked]` functions.
2155
///
2256
/// Refer to [Rust By Example] for a usage guide and the [reference] for

std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1717
panic_unwind = { path = "../panic_unwind", optional = true }
1818
panic_abort = { path = "../panic_abort" }
1919
core = { path = "../core", public = true }
20-
compiler_builtins = { version = "0.1.125" }
20+
compiler_builtins = { version = "0.1.126" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.14", default-features = false, features = [

0 commit comments

Comments
 (0)