about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2025-06-10 16:54:46 +0200
committerGitHub <noreply@github.com>2025-06-10 16:54:46 +0200
commitd11756f811b1b955b1dccafea7f65eab41484802 (patch)
tree3a92dbe78c975fb4b671fd34c327ae1c7e0d4666
parent0f16ccbb64ee16a0b957fa07bd9976dacf6482d8 (diff)
parentcd7533ab44cbc7b1b50b582d45a574af6eec12b7 (diff)
downloadrust-d11756f811b1b955b1dccafea7f65eab41484802.tar.gz
rust-d11756f811b1b955b1dccafea7f65eab41484802.zip
Rollup merge of #140766 - sayantn:stabilize-keylocker, r=traviscross,tgross35
Stabilize keylocker

This PR stabilizes the feature flag `keylocker_x86` (tracking issue rust-lang/rust#134813).

# Public API
The 2 `x86` target features `kl` and `widekl`, 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 11 stdarch intrinsics, all of which have been implemented and propagated to rustc via a stdarch submodule update.

Also, these were added way back in LLVM12, and as the minimum LLVM required for rustc is LLVM19, we are safe in that front too!

# Associated PRs
 - rust-lang/rust#134814
 - rust-lang/stdarch#1706
 - rust-lang/rust#136831 (stdarch submodule update)
 - rust-lang/stdarch#1795 (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.rs2
-rw-r--r--compiler/rustc_feature/src/unstable.rs2
-rw-r--r--compiler/rustc_target/src/target_features.rs4
-rw-r--r--library/core/src/lib.rs1
-rw-r--r--tests/ui/feature-gates/feature-gate-keylocker_x86.rs6
-rw-r--r--tests/ui/feature-gates/feature-gate-keylocker_x86.stderr13
6 files changed, 4 insertions, 24 deletions
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
index 10c5cb194f4..b1c185220f4 100644
--- a/compiler/rustc_feature/src/accepted.rs
+++ b/compiler/rustc_feature/src/accepted.rs
@@ -259,6 +259,8 @@ declare_features! (
     /// Allows some increased flexibility in the name resolution rules,
     /// especially around globs and shadowing (RFC 1560).
     (accepted, item_like_imports, "1.15.0", Some(35120)),
+    // Allows using the `kl` and `widekl` target features and the associated intrinsics
+    (accepted, keylocker_x86, "CURRENT_RUSTC_VERSION", Some(134813)),
     /// Allows `'a: { break 'a; }`.
     (accepted, label_break_value, "1.65.0", Some(48594)),
     /// Allows `let...else` statements.
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
index 9447deeecbb..594021d78d2 100644
--- a/compiler/rustc_feature/src/unstable.rs
+++ b/compiler/rustc_feature/src/unstable.rs
@@ -546,8 +546,6 @@ declare_features! (
     (incomplete, inherent_associated_types, "1.52.0", Some(8995)),
     /// Allows using `pointer` and `reference` in intra-doc links
     (unstable, intra_doc_pointers, "1.51.0", Some(80896)),
-    // Allows using the `kl` and `widekl` target features and the associated intrinsics
-    (unstable, keylocker_x86, "1.86.0", Some(134813)),
     // Allows setting the threshold for the `large_assignments` lint.
     (unstable, large_assignments, "1.52.0", Some(83518)),
     /// Allow to have type alias types for inter-crate use.
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index d48a599f544..5d1182fce48 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -443,7 +443,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
     ("fma", Stable, &["avx"]),
     ("fxsr", Stable, &[]),
     ("gfni", Stable, &["sse2"]),
-    ("kl", Unstable(sym::keylocker_x86), &["sse2"]),
+    ("kl", Stable, &["sse2"]),
     ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
     ("lzcnt", Stable, &[]),
     ("movbe", Stable, &[]),
@@ -471,7 +471,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
     ("tbm", Unstable(sym::tbm_target_feature), &[]),
     ("vaes", Stable, &["avx2", "aes"]),
     ("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
-    ("widekl", Unstable(sym::keylocker_x86), &["kl"]),
+    ("widekl", Stable, &["kl"]),
     ("x87", Unstable(sym::x87_target_feature), &[]),
     ("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]),
     ("xsave", Stable, &[]),
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index fc98ae9ff3f..88855831788 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -190,7 +190,6 @@
 #![feature(aarch64_unstable_target_feature)]
 #![feature(arm_target_feature)]
 #![feature(hexagon_target_feature)]
-#![feature(keylocker_x86)]
 #![feature(loongarch_target_feature)]
 #![feature(mips_target_feature)]
 #![feature(powerpc_target_feature)]
diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.rs b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs
deleted file mode 100644
index cef80ad41a8..00000000000
--- a/tests/ui/feature-gates/feature-gate-keylocker_x86.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-//@ only-x86_64
-#[target_feature(enable = "kl")]
-//~^ ERROR: currently unstable
-unsafe fn foo() {}
-
-fn main() {}
diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr
deleted file mode 100644
index ed814d3a3ce..00000000000
--- a/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0658]: the target feature `kl` is currently unstable
-  --> $DIR/feature-gate-keylocker_x86.rs:2:18
-   |
-LL | #[target_feature(enable = "kl")]
-   |                  ^^^^^^^^^^^^^
-   |
-   = note: see issue #134813 <https://github.com/rust-lang/rust/issues/134813> for more information
-   = help: add `#![feature(keylocker_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`.