Skip to content

Commit e2ee3c4

Browse files
committed
Auto merge of rust-lang#91728 - Amanieu:stable_asm, r=joshtriplett
Stabilize asm! and global_asm! Tracking issue: rust-lang#72016 It's been almost 2 years since the original [RFC](rust-lang/rfcs#2850) was posted and we're finally ready to stabilize this feature! The main changes in this PR are: - Removing `asm!` and `global_asm!` from the prelude as per the decision in rust-lang#87228. - Stabilizing the `asm` and `global_asm` features. - Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](rust-lang/reference#1105) and [rust by example](rust-lang/rust-by-example#1483). - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example. - Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`. - Updating `stdarch` and `compiler-builtins`. - Updating all the tests. r? `@joshtriplett`
2 parents 4a2bc3f + 08a09f8 commit e2ee3c4

File tree

13 files changed

+19
-62
lines changed

13 files changed

+19
-62
lines changed

core/src/lib.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
#![feature(abi_unadjusted)]
154154
#![feature(allow_internal_unsafe)]
155155
#![feature(allow_internal_unstable)]
156-
#![feature(asm)]
157156
#![feature(associated_type_bounds)]
158157
#![feature(auto_traits)]
159158
#![feature(cfg_target_has_atomic)]
@@ -373,26 +372,14 @@ pub mod arch {
373372
pub use crate::core_arch::arch::*;
374373

375374
/// Inline assembly.
376-
///
377-
/// Read the [unstable book] for the usage.
378-
///
379-
/// [unstable book]: ../../unstable-book/library-features/asm.html
380-
#[unstable(
381-
feature = "asm",
382-
issue = "72016",
383-
reason = "inline assembly is not stable enough for use and is subject to change"
384-
)]
375+
#[stable(feature = "asm", since = "1.59.0")]
385376
#[rustc_builtin_macro]
386377
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
387378
/* compiler built-in */
388379
}
389380
390381
/// Module-level inline assembly.
391-
#[unstable(
392-
feature = "global_asm",
393-
issue = "35119",
394-
reason = "`global_asm!` is not stable enough for use and is subject to change"
395-
)]
382+
#[stable(feature = "global_asm", since = "1.59.0")]
396383
#[rustc_builtin_macro]
397384
pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {
398385
/* compiler built-in */

core/src/num/dec2flt/fpu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub use fpu_precision::set_precision;
1010
// computations are performed in the desired precision.
1111
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
1212
mod fpu_precision {
13+
use core::arch::asm;
1314
use core::mem::size_of;
1415

1516
/// A structure used to preserve the original value of the FPU control word, so that it can be

core/src/prelude/v1.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,6 @@ pub use crate::{
6969
#[doc(no_inline)]
7070
pub use crate::concat_bytes;
7171

72-
#[unstable(
73-
feature = "asm",
74-
issue = "72016",
75-
reason = "inline assembly is not stable enough for use and is subject to change"
76-
)]
77-
#[doc(no_inline)]
78-
pub use crate::arch::asm;
79-
80-
#[unstable(
81-
feature = "global_asm",
82-
issue = "35119",
83-
reason = "`global_asm!` is not stable enough for use and is subject to change"
84-
)]
85-
#[doc(no_inline)]
86-
pub use crate::arch::global_asm;
87-
8872
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
8973
#[allow(deprecated, deprecated_in_future)]
9074
#[doc(no_inline)]

panic_abort/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(std_internals)]
1515
#![feature(staged_api)]
1616
#![feature(rustc_attrs)]
17-
#![feature(asm)]
1817
#![feature(c_unwind)]
1918

2019
#[cfg(target_os = "android")]
@@ -69,11 +68,11 @@ pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMe
6968
const FAST_FAIL_FATAL_APP_EXIT: usize = 7;
7069
cfg_if::cfg_if! {
7170
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
72-
asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
71+
core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
7372
} else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] {
74-
asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
73+
core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
7574
} else if #[cfg(target_arch = "aarch64")] {
76-
asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
75+
core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
7776
} else {
7877
core::intrinsics::abort();
7978
}

std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ panic_unwind = { path = "../panic_unwind", optional = true }
1616
panic_abort = { path = "../panic_abort" }
1717
core = { path = "../core" }
1818
libc = { version = "0.2.108", default-features = false, features = ['rustc-dep-of-std'] }
19-
compiler_builtins = { version = "0.1.55" }
19+
compiler_builtins = { version = "0.1.65" }
2020
profiler_builtins = { path = "../profiler_builtins", optional = true }
2121
unwind = { path = "../unwind" }
2222
hashbrown = { version = "0.11", default-features = false, features = ['rustc-dep-of-std'] }

std/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@
233233
#![feature(allow_internal_unstable)]
234234
#![feature(arbitrary_self_types)]
235235
#![feature(array_error_internals)]
236-
#![feature(asm)]
237236
#![feature(assert_matches)]
238237
#![feature(associated_type_bounds)]
239238
#![feature(async_stream)]
@@ -287,7 +286,6 @@
287286
#![feature(gen_future)]
288287
#![feature(generator_trait)]
289288
#![feature(get_mut_unchecked)]
290-
#![feature(global_asm)]
291289
#![feature(hashmap_internals)]
292290
#![feature(int_error_internals)]
293291
#![feature(integer_atomics)]

std/src/os/fortanix_sgx/arch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![unstable(feature = "sgx_platform", issue = "56975")]
66

77
use crate::mem::MaybeUninit;
8+
use core::arch::asm;
89

910
/// Wrapper struct to force 16-byte alignment.
1011
#[repr(align(16))]

std/src/prelude/v1.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@ pub use core::prelude::v1::{
5454
#[doc(no_inline)]
5555
pub use core::prelude::v1::concat_bytes;
5656

57-
#[unstable(
58-
feature = "asm",
59-
issue = "72016",
60-
reason = "inline assembly is not stable enough for use and is subject to change"
61-
)]
62-
#[doc(no_inline)]
63-
pub use core::prelude::v1::asm;
64-
65-
#[unstable(
66-
feature = "global_asm",
67-
issue = "35119",
68-
reason = "`global_asm!` is not stable enough for use and is subject to change"
69-
)]
70-
#[doc(no_inline)]
71-
pub use core::prelude::v1::global_asm;
72-
7357
// FIXME: Attribute and internal derive macros are not documented because for them rustdoc generates
7458
// dead links which fail link checker testing.
7559
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]

std/src/sys/sgx/abi/mem.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::arch::asm;
2+
13
// Do not remove inline: will result in relocation failure
24
#[inline(always)]
35
pub(crate) unsafe fn rel_ptr<T>(offset: u64) -> *const T {

std/src/sys/sgx/abi/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![cfg_attr(test, allow(unused))] // RT initialization logic is not compiled for test
22

33
use crate::io::Write;
4+
use core::arch::global_asm;
45
use core::sync::atomic::{AtomicUsize, Ordering};
56

67
// runtime features

0 commit comments

Comments
 (0)