make -Zwasm-c-abi=legacy suppress the lint
This commit is contained in:
parent
c961d123d2
commit
072ccce553
5 changed files with 15 additions and 10 deletions
|
@ -332,7 +332,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
|
||||||
// please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
|
// please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
|
||||||
// basically the commit introducing this comment should be reverted
|
// basically the commit introducing this comment should be reverted
|
||||||
if let PassMode::Pair { .. } = fn_abi.ret.mode {
|
if let PassMode::Pair { .. } = fn_abi.ret.mode {
|
||||||
let _ = WasmCAbi::Legacy;
|
let _ = WasmCAbi::Legacy { with_lint: true };
|
||||||
span_bug!(
|
span_bug!(
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
"cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
|
"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>(
|
||||||
BackendRepr::SimdVector { .. } => "v128",
|
BackendRepr::SimdVector { .. } => "v128",
|
||||||
BackendRepr::Memory { .. } => {
|
BackendRepr::Memory { .. } => {
|
||||||
// FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
|
// FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
|
||||||
let _ = WasmCAbi::Legacy;
|
let _ = WasmCAbi::Legacy { with_lint: true };
|
||||||
span_bug!(
|
span_bug!(
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
"cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
|
"cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
|
||||||
|
|
|
@ -92,6 +92,7 @@ fn do_check_simd_vector_abi<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Determines whether the given argument is passed the same way on the old and new wasm ABIs.
|
||||||
fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool {
|
fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool {
|
||||||
if matches!(arg.layout.backend_repr, BackendRepr::Scalar(_)) {
|
if matches!(arg.layout.backend_repr, BackendRepr::Scalar(_)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -120,16 +121,16 @@ fn do_check_wasm_abi<'tcx>(
|
||||||
is_call: bool,
|
is_call: bool,
|
||||||
span: impl Fn() -> Span,
|
span: impl Fn() -> Span,
|
||||||
) {
|
) {
|
||||||
// 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`).
|
// 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`),
|
||||||
|
// and only proceed if `wasm_c_abi_opt` indicates we should emit the lint.
|
||||||
if !(tcx.sess.target.arch == "wasm32"
|
if !(tcx.sess.target.arch == "wasm32"
|
||||||
&& tcx.sess.target.os == "unknown"
|
&& tcx.sess.target.os == "unknown"
|
||||||
&& tcx.wasm_c_abi_opt() == WasmCAbi::Legacy
|
&& tcx.wasm_c_abi_opt() == WasmCAbi::Legacy { with_lint: true }
|
||||||
&& abi.conv == Conv::C)
|
&& abi.conv == Conv::C)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Warn against all types whose ABI will change. That's all arguments except for things passed as scalars.
|
// Warn against all types whose ABI will change. Return values are not affected by this change.
|
||||||
// Return values are not affected by this change.
|
|
||||||
for arg_abi in abi.args.iter() {
|
for arg_abi in abi.args.iter() {
|
||||||
if wasm_abi_safe(tcx, arg_abi) {
|
if wasm_abi_safe(tcx, arg_abi) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1886,7 +1886,8 @@ pub mod parse {
|
||||||
pub(crate) fn parse_wasm_c_abi(slot: &mut WasmCAbi, v: Option<&str>) -> bool {
|
pub(crate) fn parse_wasm_c_abi(slot: &mut WasmCAbi, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("spec") => *slot = WasmCAbi::Spec,
|
Some("spec") => *slot = WasmCAbi::Spec,
|
||||||
Some("legacy") => *slot = WasmCAbi::Legacy,
|
// Explicitly setting the `-Z` flag suppresses the lint.
|
||||||
|
Some("legacy") => *slot = WasmCAbi::Legacy { with_lint: false },
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
@ -2599,7 +2600,7 @@ written to standard error output)"),
|
||||||
Requires `-Clto[=[fat,yes]]`"),
|
Requires `-Clto[=[fat,yes]]`"),
|
||||||
wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
|
wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
|
||||||
"whether to build a wasi command or reactor"),
|
"whether to build a wasi command or reactor"),
|
||||||
wasm_c_abi: WasmCAbi = (WasmCAbi::Legacy, parse_wasm_c_abi, [TRACKED],
|
wasm_c_abi: WasmCAbi = (WasmCAbi::Legacy { with_lint: true }, parse_wasm_c_abi, [TRACKED],
|
||||||
"use spec-compliant C ABI for `wasm32-unknown-unknown` (default: legacy)"),
|
"use spec-compliant C ABI for `wasm32-unknown-unknown` (default: legacy)"),
|
||||||
write_long_types_to_disk: bool = (true, parse_bool, [UNTRACKED],
|
write_long_types_to_disk: bool = (true, parse_bool, [UNTRACKED],
|
||||||
"whether long type names should be written to files instead of being printed in errors"),
|
"whether long type names should be written to files instead of being printed in errors"),
|
||||||
|
|
|
@ -705,7 +705,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
||||||
"xtensa" => xtensa::compute_abi_info(cx, self),
|
"xtensa" => xtensa::compute_abi_info(cx, self),
|
||||||
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
|
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
|
||||||
"wasm32" => {
|
"wasm32" => {
|
||||||
if spec.os == "unknown" && cx.wasm_c_abi_opt() == WasmCAbi::Legacy {
|
if spec.os == "unknown" && matches!(cx.wasm_c_abi_opt(), WasmCAbi::Legacy { .. }) {
|
||||||
wasm::compute_wasm_abi_info(self)
|
wasm::compute_wasm_abi_info(self)
|
||||||
} else {
|
} else {
|
||||||
wasm::compute_c_abi_info(cx, self)
|
wasm::compute_c_abi_info(cx, self)
|
||||||
|
|
|
@ -2234,7 +2234,10 @@ pub enum WasmCAbi {
|
||||||
/// Spec-compliant C ABI.
|
/// Spec-compliant C ABI.
|
||||||
Spec,
|
Spec,
|
||||||
/// Legacy ABI. Which is non-spec-compliant.
|
/// Legacy ABI. Which is non-spec-compliant.
|
||||||
Legacy,
|
Legacy {
|
||||||
|
/// Indicates whether the `wasm_c_abi` lint should be emitted.
|
||||||
|
with_lint: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HasWasmCAbiOpt {
|
pub trait HasWasmCAbiOpt {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue