Skip to content

Commit 7709aa5

Browse files
committed
Add target_feature = "gc" for Wasm
1 parent 07a5b02 commit 7709aa5

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
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", Stable, &["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`

tests/ui/wasm/wasm-stable-target-features.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,27 @@ fn foo3() {}
1717
#[target_feature(enable = "extended-const")]
1818
fn foo4() {}
1919

20-
#[target_feature(enable = "mutable-globals")]
20+
#[target_feature(enable = "gc")]
2121
fn foo5() {}
2222

23-
#[target_feature(enable = "nontrapping-fptoint")]
23+
#[target_feature(enable = "mutable-globals")]
2424
fn foo6() {}
2525

26-
#[target_feature(enable = "simd128")]
26+
#[target_feature(enable = "nontrapping-fptoint")]
2727
fn foo7() {}
2828

29-
#[target_feature(enable = "relaxed-simd")]
29+
#[target_feature(enable = "simd128")]
3030
fn foo8() {}
3131

32-
#[target_feature(enable = "sign-ext")]
32+
#[target_feature(enable = "relaxed-simd")]
3333
fn foo9() {}
3434

35-
#[target_feature(enable = "tail-call")]
35+
#[target_feature(enable = "sign-ext")]
3636
fn foo10() {}
3737

38+
#[target_feature(enable = "tail-call")]
39+
fn foo11() {}
40+
3841
fn main() {
3942
foo1();
4043
foo2();
@@ -46,4 +49,5 @@ fn main() {
4649
foo8();
4750
foo9();
4851
foo10();
52+
foo11();
4953
}

0 commit comments

Comments
 (0)