Skip to content

Commit fa3ce50

Browse files
authored
Rollup merge of #127605 - nikic:remove-extern-wasm, r=oli-obk
Remove extern "wasm" ABI Remove the unstable `extern "wasm"` ABI (`wasm_abi` feature tracked in #83788). As discussed in #127513 (comment) and following, this ABI is a failed experiment that did not end up being used for anything. Keeping support for this ABI in LLVM 19 would require us to switch wasm targets to the `experimental-mv` ABI, which we do not want to do. It should be noted that `Abi::Wasm` was internally used for two things: The `-Z wasm-c-abi=legacy` ABI that is still used by default on some wasm targets, and the `extern "wasm"` ABI. Despite both being `Abi::Wasm` internally, they were not the same. An explicit `extern "wasm"` additionally enabled the `+multivalue` feature. I've opted to remove `Abi::Wasm` in this patch entirely, instead of keeping it as an ABI with only internal usage. Both `-Z wasm-c-abi` variants are now treated as part of the normal C ABI, just with different different treatment in adjust_for_foreign_abi.
2 parents d433f17 + 8a50bcb commit fa3ce50

File tree

25 files changed

+87
-382
lines changed

25 files changed

+87
-382
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFuncti
66
use rustc_middle::ty::{self, TyCtxt};
77
use rustc_session::config::{FunctionReturn, OptLevel};
88
use rustc_span::symbol::sym;
9-
use rustc_target::spec::abi::Abi;
109
use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
1110
use smallvec::SmallVec;
1211

@@ -482,7 +481,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
482481
return;
483482
}
484483

485-
let mut function_features = function_features
484+
let function_features = function_features
486485
.iter()
487486
.flat_map(|feat| {
488487
llvm_util::to_llvm_features(cx.tcx.sess, feat).into_iter().map(|f| format!("+{f}"))
@@ -504,17 +503,6 @@ pub fn from_fn_attrs<'ll, 'tcx>(
504503
let name = name.as_str();
505504
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-name", name));
506505
}
507-
508-
// The `"wasm"` abi on wasm targets automatically enables the
509-
// `+multivalue` feature because the purpose of the wasm abi is to match
510-
// the WebAssembly specification, which has this feature. This won't be
511-
// needed when LLVM enables this `multivalue` feature by default.
512-
if !cx.tcx.is_closure_like(instance.def_id()) {
513-
let abi = cx.tcx.fn_sig(instance.def_id()).skip_binder().abi();
514-
if abi == Abi::Wasm {
515-
function_features.push("+multivalue".to_string());
516-
}
517-
}
518506
}
519507

520508
let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str());

compiler/rustc_feature/src/removed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ declare_features! (
215215
/// Permits specifying whether a function should permit unwinding or abort on unwind.
216216
(removed, unwind_attributes, "1.56.0", Some(58760), Some("use the C-unwind ABI instead")),
217217
(removed, visible_private_types, "1.0.0", None, None),
218+
/// Allows `extern "wasm" fn`
219+
(removed, wasm_abi, "CURRENT_RUSTC_VERSION", Some(83788),
220+
Some("non-standard wasm ABI is no longer supported")),
218221
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
219222
// Features are listed in alphabetical order. Tidy will fail if you don't keep it this way.
220223
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,6 @@ declare_features! (
640640
(unstable, unsized_tuple_coercion, "1.20.0", Some(42877)),
641641
/// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute.
642642
(unstable, used_with_arg, "1.60.0", Some(93798)),
643-
/// Allows `extern "wasm" fn`
644-
(unstable, wasm_abi, "1.53.0", Some(83788)),
645643
/// Allows `do yeet` expressions
646644
(unstable, yeet_expr, "1.62.0", Some(96373)),
647645
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!

compiler/rustc_middle/src/ty/layout.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,6 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
12121212
| RiscvInterruptM
12131213
| RiscvInterruptS
12141214
| CCmseNonSecureCall
1215-
| Wasm
12161215
| Unadjusted => false,
12171216
Rust | RustCall | RustCold | RustIntrinsic => {
12181217
tcx.sess.panic_strategy() == PanicStrategy::Unwind

compiler/rustc_smir/src/rustc_internal/internal.rs

-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ impl RustcInternal for Abi {
466466
Abi::AvrInterrupt => rustc_target::spec::abi::Abi::AvrInterrupt,
467467
Abi::AvrNonBlockingInterrupt => rustc_target::spec::abi::Abi::AvrNonBlockingInterrupt,
468468
Abi::CCmseNonSecureCall => rustc_target::spec::abi::Abi::CCmseNonSecureCall,
469-
Abi::Wasm => rustc_target::spec::abi::Abi::Wasm,
470469
Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind },
471470
Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic,
472471
Abi::RustCall => rustc_target::spec::abi::Abi::RustCall,

compiler/rustc_smir/src/rustc_smir/convert/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,6 @@ impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi {
909909
abi::Abi::AvrInterrupt => Abi::AvrInterrupt,
910910
abi::Abi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt,
911911
abi::Abi::CCmseNonSecureCall => Abi::CCmseNonSecureCall,
912-
abi::Abi::Wasm => Abi::Wasm,
913912
abi::Abi::System { unwind } => Abi::System { unwind },
914913
abi::Abi::RustIntrinsic => Abi::RustIntrinsic,
915914
abi::Abi::RustCall => Abi::RustCall,

compiler/rustc_target/src/abi/call/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::abi::{self, Abi, Align, FieldsShape, Size};
22
use crate::abi::{HasDataLayout, TyAbiInterface, TyAndLayout};
3-
use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt};
3+
use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt, WasmCAbi};
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::Symbol;
66
use std::fmt;
@@ -854,7 +854,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
854854
return Ok(());
855855
}
856856

857-
match &cx.target_spec().arch[..] {
857+
let spec = cx.target_spec();
858+
match &spec.arch[..] {
858859
"x86" => {
859860
let flavor = if let spec::abi::Abi::Fastcall { .. }
860861
| spec::abi::Abi::Vectorcall { .. } = abi
@@ -901,9 +902,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
901902
"sparc" => sparc::compute_abi_info(cx, self),
902903
"sparc64" => sparc64::compute_abi_info(cx, self),
903904
"nvptx64" => {
904-
if cx.target_spec().adjust_abi(cx, abi, self.c_variadic)
905-
== spec::abi::Abi::PtxKernel
906-
{
905+
if cx.target_spec().adjust_abi(abi, self.c_variadic) == spec::abi::Abi::PtxKernel {
907906
nvptx64::compute_ptx_kernel_abi_info(cx, self)
908907
} else {
909908
nvptx64::compute_abi_info(self)
@@ -912,13 +911,14 @@ impl<'a, Ty> FnAbi<'a, Ty> {
912911
"hexagon" => hexagon::compute_abi_info(self),
913912
"xtensa" => xtensa::compute_abi_info(cx, self),
914913
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
915-
"wasm32" | "wasm64" => {
916-
if cx.target_spec().adjust_abi(cx, abi, self.c_variadic) == spec::abi::Abi::Wasm {
914+
"wasm32" => {
915+
if spec.os == "unknown" && cx.wasm_c_abi_opt() == WasmCAbi::Legacy {
917916
wasm::compute_wasm_abi_info(self)
918917
} else {
919918
wasm::compute_c_abi_info(cx, self)
920919
}
921920
}
921+
"wasm64" => wasm::compute_c_abi_info(cx, self),
922922
"bpf" => bpf::compute_abi_info(self),
923923
arch => {
924924
return Err(AdjustForForeignAbiError::Unsupported {

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

+11-15
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub enum Abi {
4848
AvrInterrupt,
4949
AvrNonBlockingInterrupt,
5050
CCmseNonSecureCall,
51-
Wasm,
5251
System {
5352
unwind: bool,
5453
},
@@ -123,7 +122,6 @@ const AbiDatas: &[AbiData] = &[
123122
AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt" },
124123
AbiData { abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt" },
125124
AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call" },
126-
AbiData { abi: Abi::Wasm, name: "wasm" },
127125
AbiData { abi: Abi::System { unwind: false }, name: "system" },
128126
AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" },
129127
AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" },
@@ -149,6 +147,9 @@ pub fn lookup(name: &str) -> Result<Abi, AbiUnsupported> {
149147
"riscv-interrupt-u" => AbiUnsupported::Reason {
150148
explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314",
151149
},
150+
"wasm" => AbiUnsupported::Reason {
151+
explain: "non-standard wasm ABI is no longer supported",
152+
},
152153

153154
_ => AbiUnsupported::Unrecognized,
154155

@@ -241,10 +242,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
241242
feature: sym::abi_c_cmse_nonsecure_call,
242243
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
243244
}),
244-
"wasm" => Err(AbiDisabled::Unstable {
245-
feature: sym::wasm_abi,
246-
explain: "wasm ABI is experimental and subject to change",
247-
}),
248245
_ => Err(AbiDisabled::Unrecognized),
249246
}
250247
}
@@ -287,16 +284,15 @@ impl Abi {
287284
AvrInterrupt => 23,
288285
AvrNonBlockingInterrupt => 24,
289286
CCmseNonSecureCall => 25,
290-
Wasm => 26,
291287
// Cross-platform ABIs
292-
System { unwind: false } => 27,
293-
System { unwind: true } => 28,
294-
RustIntrinsic => 29,
295-
RustCall => 30,
296-
Unadjusted => 31,
297-
RustCold => 32,
298-
RiscvInterruptM => 33,
299-
RiscvInterruptS => 34,
288+
System { unwind: false } => 26,
289+
System { unwind: true } => 27,
290+
RustIntrinsic => 28,
291+
RustCall => 29,
292+
Unadjusted => 30,
293+
RustCold => 31,
294+
RiscvInterruptM => 32,
295+
RiscvInterruptS => 33,
300296
};
301297
debug_assert!(
302298
AbiDatas

compiler/rustc_target/src/spec/mod.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -2608,22 +2608,8 @@ impl DerefMut for Target {
26082608

26092609
impl Target {
26102610
/// Given a function ABI, turn it into the correct ABI for this target.
2611-
pub fn adjust_abi<C>(&self, cx: &C, abi: Abi, c_variadic: bool) -> Abi
2612-
where
2613-
C: HasWasmCAbiOpt,
2614-
{
2611+
pub fn adjust_abi(&self, abi: Abi, c_variadic: bool) -> Abi {
26152612
match abi {
2616-
Abi::C { .. } => {
2617-
if self.arch == "wasm32"
2618-
&& self.os == "unknown"
2619-
&& cx.wasm_c_abi_opt() == WasmCAbi::Legacy
2620-
{
2621-
Abi::Wasm
2622-
} else {
2623-
abi
2624-
}
2625-
}
2626-
26272613
// On Windows, `extern "system"` behaves like msvc's `__stdcall`.
26282614
// `__stdcall` only applies on x86 and on non-variadic functions:
26292615
// https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170
@@ -2676,7 +2662,6 @@ impl Target {
26762662
Msp430Interrupt => self.arch == "msp430",
26772663
RiscvInterruptM | RiscvInterruptS => ["riscv32", "riscv64"].contains(&&self.arch[..]),
26782664
AvrInterrupt | AvrNonBlockingInterrupt => self.arch == "avr",
2679-
Wasm => ["wasm32", "wasm64"].contains(&&self.arch[..]),
26802665
Thiscall { .. } => self.arch == "x86",
26812666
// On windows these fall-back to platform native calling convention (C) when the
26822667
// architecture is not supported.

compiler/rustc_ty_utils/src/abi.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ fn fn_sig_for_fn_abi<'tcx>(
324324
#[inline]
325325
fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
326326
use rustc_target::spec::abi::Abi::*;
327-
match tcx.sess.target.adjust_abi(&tcx, abi, c_variadic) {
327+
match tcx.sess.target.adjust_abi(abi, c_variadic) {
328328
RustIntrinsic | Rust | RustCall => Conv::Rust,
329329

330330
// This is intentionally not using `Conv::Cold`, as that has to preserve
@@ -352,7 +352,6 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
352352
AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt,
353353
RiscvInterruptM => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine },
354354
RiscvInterruptS => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor },
355-
Wasm => Conv::C,
356355

357356
// These API constants ought to be more specific...
358357
Cdecl { .. } => Conv::C,

compiler/stable_mir/src/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,6 @@ pub enum Abi {
10451045
AvrInterrupt,
10461046
AvrNonBlockingInterrupt,
10471047
CCmseNonSecureCall,
1048-
Wasm,
10491048
System { unwind: bool },
10501049
RustIntrinsic,
10511050
RustCall,

tests/run-make/wasm-abi/foo.rs

-87
This file was deleted.

tests/run-make/wasm-abi/host.wat

-22
This file was deleted.

tests/run-make/wasm-abi/rmake.rs

-29
This file was deleted.

tests/ui/abi/removed-wasm-abi.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extern "wasm" fn test() {}
2+
//~^ ERROR invalid ABI: found `wasm`
3+
4+
fn main() {}

0 commit comments

Comments
 (0)