Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 609809f

Browse files
committedMar 17, 2025
make -Zwasm-c-abi=legacy suppress the lint
1 parent 7c01ac5 commit 609809f

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed
 

‎compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
332332
// please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
333333
// basically the commit introducing this comment should be reverted
334334
if let PassMode::Pair { .. } = fn_abi.ret.mode {
335-
let _ = WasmCAbi::Legacy;
335+
let _ = WasmCAbi::Legacy { with_lint: true };
336336
span_bug!(
337337
tcx.def_span(def_id),
338338
"cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
@@ -384,7 +384,7 @@ fn wasm_type<'tcx>(
384384
BackendRepr::SimdVector { .. } => "v128",
385385
BackendRepr::Memory { .. } => {
386386
// FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
387-
let _ = WasmCAbi::Legacy;
387+
let _ = WasmCAbi::Legacy { with_lint: true };
388388
span_bug!(
389389
tcx.def_span(def_id),
390390
"cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"

‎compiler/rustc_monomorphize/src/mono_checks/abi_check.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ fn do_check_simd_vector_abi<'tcx>(
9292
}
9393
}
9494

95+
/// Determines whether the given argument is passed the same way on the old and new wasm ABIs.
9596
fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool {
9697
if matches!(arg.layout.backend_repr, BackendRepr::Scalar(_)) {
9798
return true;
@@ -120,16 +121,16 @@ fn do_check_wasm_abi<'tcx>(
120121
is_call: bool,
121122
span: impl Fn() -> Span,
122123
) {
123-
// Only proceed for `extern "C" fn` on wasm32-unknown-unknown (same check as what `adjust_for_foreign_abi` uses to call `compute_wasm_abi_info`).
124+
// Only proceed for `extern "C" fn` on wasm32-unknown-unknown (same check as what `adjust_for_foreign_abi` uses to call `compute_wasm_abi_info`),
125+
// and only proceed if `wasm_c_abi_opt` indicates we should emit the lint.
124126
if !(tcx.sess.target.arch == "wasm32"
125127
&& tcx.sess.target.os == "unknown"
126-
&& tcx.wasm_c_abi_opt() == WasmCAbi::Legacy
128+
&& tcx.wasm_c_abi_opt() == WasmCAbi::Legacy { with_lint: true }
127129
&& abi.conv == Conv::C)
128130
{
129131
return;
130132
}
131-
// Warn against all types whose ABI will change. That's all arguments except for things passed as scalars.
132-
// Return values are not affected by this change.
133+
// Warn against all types whose ABI will change. Return values are not affected by this change.
133134
for arg_abi in abi.args.iter() {
134135
if wasm_abi_safe(tcx, arg_abi) {
135136
continue;

‎compiler/rustc_session/src/options.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,8 @@ pub mod parse {
18861886
pub(crate) fn parse_wasm_c_abi(slot: &mut WasmCAbi, v: Option<&str>) -> bool {
18871887
match v {
18881888
Some("spec") => *slot = WasmCAbi::Spec,
1889-
Some("legacy") => *slot = WasmCAbi::Legacy,
1889+
// Explicitly setting the `-Z` flag suppresses the lint.
1890+
Some("legacy") => *slot = WasmCAbi::Legacy { with_lint: false },
18901891
_ => return false,
18911892
}
18921893
true
@@ -2599,7 +2600,7 @@ written to standard error output)"),
25992600
Requires `-Clto[=[fat,yes]]`"),
26002601
wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
26012602
"whether to build a wasi command or reactor"),
2602-
wasm_c_abi: WasmCAbi = (WasmCAbi::Legacy, parse_wasm_c_abi, [TRACKED],
2603+
wasm_c_abi: WasmCAbi = (WasmCAbi::Legacy { with_lint: true }, parse_wasm_c_abi, [TRACKED],
26032604
"use spec-compliant C ABI for `wasm32-unknown-unknown` (default: legacy)"),
26042605
write_long_types_to_disk: bool = (true, parse_bool, [UNTRACKED],
26052606
"whether long type names should be written to files instead of being printed in errors"),

‎compiler/rustc_target/src/callconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
705705
"xtensa" => xtensa::compute_abi_info(cx, self),
706706
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
707707
"wasm32" => {
708-
if spec.os == "unknown" && cx.wasm_c_abi_opt() == WasmCAbi::Legacy {
708+
if spec.os == "unknown" && matches!(cx.wasm_c_abi_opt(), WasmCAbi::Legacy { .. }) {
709709
wasm::compute_wasm_abi_info(self)
710710
} else {
711711
wasm::compute_c_abi_info(cx, self)

‎compiler/rustc_target/src/spec/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,10 @@ pub enum WasmCAbi {
22342234
/// Spec-compliant C ABI.
22352235
Spec,
22362236
/// Legacy ABI. Which is non-spec-compliant.
2237-
Legacy,
2237+
Legacy {
2238+
/// Indicates whether the `wasm_c_abi` lint should be emitted.
2239+
with_lint: bool,
2240+
},
22382241
}
22392242

22402243
pub trait HasWasmCAbiOpt {

0 commit comments

Comments
 (0)
Failed to load comments.