Skip to content

Commit 19e44d4

Browse files
committed
Don't warn about v128 in wasm ABI transition
This has other warnings if necessary and doesn't need extra warnings from this FCW. cc #138762
1 parent 6a0bd27 commit 19e44d4

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

compiler/rustc_monomorphize/src/mono_checks/abi_check.rs

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool
9999
return true;
100100
}
101101

102+
// Both the old and the new ABIs treat vector types like `v128` the same
103+
// way.
104+
if uses_vector_registers(&arg.mode, &arg.layout.backend_repr) {
105+
return true;
106+
}
107+
102108
// This matches `unwrap_trivial_aggregate` in the wasm ABI logic.
103109
if arg.layout.is_aggregate() {
104110
let cx = LayoutCx::new(tcx, TypingEnv::fully_monomorphized());

tests/ui/lint/wasm_c_abi_transition.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@ add-core-stubs
44
//@ build-fail
55

6-
#![feature(no_core)]
6+
#![feature(no_core, repr_simd)]
77
#![no_core]
88
#![crate_type = "lib"]
99
#![deny(wasm_c_abi)]
@@ -45,3 +45,13 @@ pub fn call_other_fun(x: MyType) {
4545
pub struct MyZstType;
4646
#[allow(improper_ctypes_definitions)]
4747
pub extern "C" fn zst_safe(_x: (), _y: MyZstType) {}
48+
49+
// The old and new wasm ABI treats simd types like `v128` the same way, so no
50+
// wasm_c_abi warning should be emitted.
51+
#[repr(simd)]
52+
#[allow(non_camel_case_types)]
53+
pub struct v128([i32; 4]);
54+
#[target_feature(enable = "simd128")]
55+
pub extern "C" fn my_safe_simd(x: v128) -> v128 { x }
56+
//~^ WARN `extern` fn uses type `v128`, which is not FFI-safe
57+
//~| WARN `extern` fn uses type `v128`, which is not FFI-safe

tests/ui/lint/wasm_c_abi_transition.stderr

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
warning: `extern` fn uses type `v128`, which is not FFI-safe
2+
--> $DIR/wasm_c_abi_transition.rs:55:35
3+
|
4+
LL | pub extern "C" fn my_safe_simd(x: v128) -> v128 { x }
5+
| ^^^^ not FFI-safe
6+
|
7+
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
8+
= note: this struct has unspecified layout
9+
note: the type is defined here
10+
--> $DIR/wasm_c_abi_transition.rs:53:1
11+
|
12+
LL | pub struct v128([i32; 4]);
13+
| ^^^^^^^^^^^^^^^
14+
= note: `#[warn(improper_ctypes_definitions)]` on by default
15+
16+
warning: `extern` fn uses type `v128`, which is not FFI-safe
17+
--> $DIR/wasm_c_abi_transition.rs:55:44
18+
|
19+
LL | pub extern "C" fn my_safe_simd(x: v128) -> v128 { x }
20+
| ^^^^ not FFI-safe
21+
|
22+
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
23+
= note: this struct has unspecified layout
24+
note: the type is defined here
25+
--> $DIR/wasm_c_abi_transition.rs:53:1
26+
|
27+
LL | pub struct v128([i32; 4]);
28+
| ^^^^^^^^^^^^^^^
29+
130
error: this function definition involves an argument of type `MyType` which is affected by the wasm ABI transition
231
--> $DIR/wasm_c_abi_transition.rs:18:1
332
|
@@ -33,7 +62,7 @@ LL | unsafe { other_fun(x) }
3362
= note: for more information, see issue #138762 <https://github.com/rust-lang/rust/issues/138762>
3463
= help: the "C" ABI Rust uses on wasm32-unknown-unknown will change to align with the standard "C" ABI for this target
3564

36-
error: aborting due to 3 previous errors
65+
error: aborting due to 3 previous errors; 2 warnings emitted
3766

3867
Future incompatibility report: Future breakage diagnostic:
3968
error: this function definition involves an argument of type `MyType` which is affected by the wasm ABI transition

0 commit comments

Comments
 (0)