From 2c0f9de513810839717ddb5257a298928995cc04 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 May 2026 13:48:33 +0200 Subject: [PATCH] add ABI check logic for wasm --- compiler/rustc_target/src/spec/mod.rs | 13 +++++++++++++ compiler/rustc_target/src/target_features.rs | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d6a9e27c46553..0dd2c11e6ff81 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -3582,6 +3582,19 @@ impl Target { "invalid `target_abi` for CSky" ); } + Arch::Wasm32 | Arch::Wasm64 => { + check!( + self.llvm_abiname == LlvmAbi::Unspecified, + "`llvm_abiname` is unused on wasm" + ); + check!(self.llvm_floatabi.is_none(), "`llvm_floatabi` is unused on wasm"); + check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on wasm"); + check_matches!( + self.cfg_abi, + CfgAbi::Unspecified | CfgAbi::Other(_), + "invalid `target_abi` for wasm" + ); + } ref arch => { check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on {arch}"); // Ensure consistency among built-in targets, but give JSON targets the opportunity diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index b009c42eb2302..c27cdc9bf2e9a 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -1312,11 +1312,17 @@ impl Target { } } Arch::Avr => { + // We only support one ABI on AVR at the moment. // SRAM is minimum requirement for C/C++ in both avr-gcc and Clang, // and backends of them only support assembly for devices have no SRAM. // See the discussion in https://github.com/rust-lang/rust/pull/146900 for more. FeatureConstraints { required: &["sram"], incompatible: &[] } } + Arch::Wasm32 | Arch::Wasm64 => { + // We only support one ABI on wasm at the moment. + // No ABI-relevant target features have been identified thus far. + NOTHING + } _ => NOTHING, } }