diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2025-06-09 12:17:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-09 12:17:52 -0500 |
| commit | 2f26913270f55356a632377338b6afd5137c71be (patch) | |
| tree | 6654edc09e724a801c62d291c6787850668f33d0 | |
| parent | 14863ea0777c68348b3e6e7a8472423d273a52af (diff) | |
| parent | 632396ea01e7556d9af24ad1a22f9a74ccb63d60 (diff) | |
| download | rust-2f26913270f55356a632377338b6afd5137c71be.tar.gz rust-2f26913270f55356a632377338b6afd5137c71be.zip | |
Rollup merge of #140767 - sayantn:stabilize-sha512, r=traviscross,tgross35
Stabilize `sha512`, `sm3` and `sm4` for x86 This PR stabilizes the feature flag `sha512_sm_x86` (tracking issue rust-lang/rust#126624). # Public API The 3 `x86` target features `sha512`, `sm3` and `sm4`, and the associated intrinsics in stdarch. These target features are very specialized, and are only used to signal the presence of the corresponding CPU instruction. They don't have any nontrivial interaction with the ABI (contrary to something like AVX), and serve the only purpose of enabling 10 stdarch intrinsics, all of which have been implemented and propagated to rustc via a stdarch submodule update. Also, these were added in LLVM17, and as the minimum LLVM required for rustc is LLVM19, we are safe in that front too! # Associated PRs - rust-lang/rust#126704 - rust-lang/stdarch#1592 - rust-lang/stdarch#1790 - rust-lang/rust#140389 (stdarch submodule update) - rust-lang/stdarch#1796 (stabilizing the runtime detection and intrinsics) - rust-lang/rust#141964 (stdarch submodule update for the stabilization of the runtime detection and intrinsics) As all of the required tasks have been done (adding the target features to rustc, implementing their runtime detection in std_detect and implementing the associated intrinsics in core_arch), these target features can be stabilized now. cc `@rust-lang/lang` cc `@rust-lang/libs-api` for the intrinsics and runtime detection I don't think anyone else worked on this feature, so no one else to ping, maybe cc `@Amanieu.` I will send the reference pr soon.
| -rw-r--r-- | compiler/rustc_feature/src/accepted.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/unstable.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_target/src/target_features.rs | 6 | ||||
| -rw-r--r-- | library/core/src/lib.rs | 1 | ||||
| -rw-r--r-- | tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs | 6 | ||||
| -rw-r--r-- | tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr | 13 |
6 files changed, 5 insertions, 25 deletions
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index ffa6ffb40b6..10c5cb194f4 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -382,6 +382,8 @@ declare_features! ( (accepted, self_in_typedefs, "1.32.0", Some(49303)), /// Allows `Self` struct constructor (RFC 2302). (accepted, self_struct_ctor, "1.32.0", Some(51994)), + /// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics + (accepted, sha512_sm_x86, "CURRENT_RUSTC_VERSION", Some(126624)), /// Shortern the tail expression lifetime (accepted, shorter_tail_lifetimes, "1.84.0", Some(123739)), /// Allows using subslice patterns, `[a, .., b]` and `[a, xs @ .., b]`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index b46eac6d8a6..9447deeecbb 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -627,8 +627,6 @@ declare_features! ( (unstable, return_type_notation, "1.70.0", Some(109417)), /// Allows `extern "rust-cold"`. (unstable, rust_cold_cc, "1.63.0", Some(97544)), - /// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics - (unstable, sha512_sm_x86, "1.82.0", Some(126624)), /// Allows the use of SIMD types in functions declared in `extern` blocks. (unstable, simd_ffi, "1.0.0", Some(27731)), /// Allows specialization of implementations (RFC 1210). diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index c1f128fdc87..d48a599f544 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -455,9 +455,9 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("rdseed", Stable, &[]), ("rtm", Unstable(sym::rtm_target_feature), &[]), ("sha", Stable, &["sse2"]), - ("sha512", Unstable(sym::sha512_sm_x86), &["avx2"]), - ("sm3", Unstable(sym::sha512_sm_x86), &["avx"]), - ("sm4", Unstable(sym::sha512_sm_x86), &["avx2"]), + ("sha512", Stable, &["avx2"]), + ("sm3", Stable, &["avx"]), + ("sm4", Stable, &["avx2"]), // This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to // stabilize. It must be in this list for the ABI check to be able to use it. ("soft-float", Stability::Unstable(sym::x87_target_feature), &[]), diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index f2a5c40bada..fc98ae9ff3f 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -197,7 +197,6 @@ #![feature(riscv_target_feature)] #![feature(rtm_target_feature)] #![feature(s390x_target_feature)] -#![feature(sha512_sm_x86)] #![feature(sse4a_target_feature)] #![feature(tbm_target_feature)] #![feature(wasm_target_feature)] diff --git a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs deleted file mode 100644 index 176a40ecf53..00000000000 --- a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ only-x86_64 -#[target_feature(enable = "sha512")] -//~^ ERROR: currently unstable -unsafe fn foo() {} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr deleted file mode 100644 index da9eea095a3..00000000000 --- a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: the target feature `sha512` is currently unstable - --> $DIR/feature-gate-sha512_sm_x86.rs:2:18 - | -LL | #[target_feature(enable = "sha512")] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #126624 <https://github.com/rust-lang/rust/issues/126624> for more information - = help: add `#![feature(sha512_sm_x86)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. |
