From 3a51e4d9e2e263297e148ed99763fc1b8a565b0e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 10 Aug 2026 13:01:46 -0700 Subject: [PATCH] rustc: Stabilize the WebAssembly `wide-arithmetic` feature This commit stabilizes the `wide-arithmetic` target feature for WebAssembly targets. This [upstream WebAssembly proposal][repo] has [now reached phase 4][phase] in the WebAssembly CG standardization process which means that it's expected to ship shortly in browsers/engines and is considered stable. This is intended to be a sibling PR to rust-lang/rust to reflect the stability of the proposal in LLVM/engines to allow users to enable this in downstream code without warnings. To recap what `wide-arithmetic` is -- this is a target feature for all WebAssembly targets for Rust. This feature corresponds to the LLVM `wide-arithmetic` target feature and gates generation of four new instructions added in the [wide-arithmetic proposal][repo], primarily centered around 128-bit addition/subtraction and a widening 64x64-bit multiply producing a 128-bit result. This target feature has no library APIs, no impact on the Rust language, nor any impact on ABIs anywhere. The only change is that more efficient codegen is generated for some operations, primarily 128-bit multiplication. Generally speaking it's expected that users should be able to enable this feature, recompile with today's source code, and see speedups if these operations are bottlenecks. This feature is off-by-default and requires `-Ctarget-feature=...` or similar to enable it. This feature will not be on-by-default for quite some time while engine support percolates and (ideally) becomes pervasive. [repo]: https://github.com/webassembly/wide-arithmetic [phase]: https://github.com/WebAssembly/proposals/pull/239 --- compiler/rustc_target/src/target_features.rs | 2 +- src/doc/rustc/src/platform-support/wasm32v1-none.md | 3 +++ tests/ui/wasm/wasm-stable-target-features.rs | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index f1dd2d8191985..93d48d8341ccb 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -845,7 +845,7 @@ static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("sign-ext", Stable, &[]), ("simd128", Stable, &[]), ("tail-call", Stable, &[]), - ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]), + ("wide-arithmetic", Stable, &[]), // tidy-alphabetical-end ]; diff --git a/src/doc/rustc/src/platform-support/wasm32v1-none.md b/src/doc/rustc/src/platform-support/wasm32v1-none.md index d2f9b3a1f9760..b7224e85ca19a 100644 --- a/src/doc/rustc/src/platform-support/wasm32v1-none.md +++ b/src/doc/rustc/src/platform-support/wasm32v1-none.md @@ -64,6 +64,8 @@ For reference sake, the set of proposals that LLVM supports at the time of writi * [Multiple memories]- `+multimemory` * [Relaxed SIMD] - `+relaxed-simd` * [Tail call] - `+tail-call` +* Post-3.0 proposals: + * [Wide Arithmetic] - `+wide-arithmetic` [Bulk memory]: https://github.com/WebAssembly/spec/blob/main/proposals/bulk-memory-operations/Overview.md [Sign-extending operations]: https://github.com/WebAssembly/spec/blob/main/proposals/sign-extension-ops/Overview.md @@ -78,6 +80,7 @@ For reference sake, the set of proposals that LLVM supports at the time of writi [Multiple memories]: https://github.com/WebAssembly/multi-memory [Relaxed SIMD]: https://github.com/WebAssembly/relaxed-simd [Tail call]: https://github.com/WebAssembly/tail-call +[Wide Arithmetic]: https://github.com/WebAssembly/wide-arithmetic Additional proposals in the future are, of course, also not enabled by default. diff --git a/tests/ui/wasm/wasm-stable-target-features.rs b/tests/ui/wasm/wasm-stable-target-features.rs index b6d4b67d0703f..4ea8810ed308b 100644 --- a/tests/ui/wasm/wasm-stable-target-features.rs +++ b/tests/ui/wasm/wasm-stable-target-features.rs @@ -35,6 +35,9 @@ fn foo9() {} #[target_feature(enable = "tail-call")] fn foo10() {} +#[target_feature(enable = "wide-arithmetic")] +fn foo11() {} + fn main() { foo1(); foo2(); @@ -46,4 +49,5 @@ fn main() { foo8(); foo9(); foo10(); + foo11(); }