Skip to content

Commit 9044e98

Browse files
committed
Auto merge of #150111 - daxpedda:wasm-gc, r=alexcrichton
Add `target_feature = "gc"` for Wasm This PR adds a new target feature for Wasm targets: [GC](https://github.com/WebAssembly/gc). ~~I went ahead and made this insta-stable because it has already [passed phase 5](https://github.com/WebAssembly/proposals/blob/88e7bd6ba9bc585135edcb4def2c4d284f5fd0fc/finished-proposals.md) in addition to being [implemented and stabilized by all major JS engines](https://webassembly.org/features).~~ ~~This doesn't enable the target feature by default!~~ For context: while this proposal adds a lot of new features to Wasm, they are not accessible through Rust apart from unstable inline ASM. This is largely useful to signal tools to make use of the feature, e.g. `wasm-bindgen`, where this can be used to make some pretty optimizations. Companion PR: rust-lang/reference#2114. r? `@alexcrichton`
2 parents 806c2a3 + 4ee01c4 commit 9044e98

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
266266
"leoncasa" => Some(LLVMFeature::new("hasleoncasa")),
267267
s => Some(LLVMFeature::new(s)),
268268
},
269+
Arch::Wasm32 | Arch::Wasm64 => match s {
270+
"gc" if major < 22 => None,
271+
s => Some(LLVMFeature::new(s)),
272+
},
269273
Arch::X86 | Arch::X86_64 => {
270274
match s {
271275
"sse4.2" => Some(LLVMFeature::with_dependencies(

compiler/rustc_target/src/target_features.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
745745
("bulk-memory", Stable, &[]),
746746
("exception-handling", Unstable(sym::wasm_target_feature), &[]),
747747
("extended-const", Stable, &[]),
748+
("gc", Unstable(sym::wasm_target_feature), &["reference-types"]),
748749
("multivalue", Stable, &[]),
749750
("mutable-globals", Stable, &[]),
750751
("nontrapping-fptoint", Stable, &[]),

tests/ui/check-cfg/target_feature.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
121121
`frecipe`
122122
`frintts`
123123
`fxsr`
124+
`gc`
124125
`gfni`
125126
`guarded-storage`
126127
`hard-float`

0 commit comments

Comments
 (0)