Skip to content

Commit 3d6e33e

Browse files
authored
Unrolled build for rust-lang#139809
Rollup merge of rust-lang#139809 - alexcrichton:wasm-simd-safe, r=RalfJung Don't warn about `v128` in wasm ABI transition The `-Zwasm-c-abi=spec` mode of `extern "C"` does not actually change the meaning of `v128` meaning that the FCW lint firing is a false positive. cc rust-lang#138762 (comment)
2 parents 7f69523 + 19e44d4 commit 3d6e33e

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
@@ -89,6 +89,12 @@ fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool
8989
return true;
9090
}
9191

92+
// Both the old and the new ABIs treat vector types like `v128` the same
93+
// way.
94+
if uses_vector_registers(&arg.mode, &arg.layout.backend_repr) {
95+
return true;
96+
}
97+
9298
// This matches `unwrap_trivial_aggregate` in the wasm ABI logic.
9399
if arg.layout.is_aggregate() {
94100
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)