Skip to content

Commit c078db8

Browse files
committed
Remove all support for wasm's legacy ABI
1 parent 52bf0cf commit c078db8

File tree

17 files changed

+28
-308
lines changed

17 files changed

+28
-308
lines changed

compiler/rustc_codegen_gcc/src/builder.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
3030
use rustc_span::Span;
3131
use rustc_span::def_id::DefId;
3232
use rustc_target::callconv::FnAbi;
33-
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, Target, WasmCAbi, X86Abi};
33+
use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, X86Abi};
3434

3535
use crate::common::{SignType, TypeReflection, type_is_pointer};
3636
use crate::context::CodegenCx;
@@ -2394,12 +2394,6 @@ impl<'tcx> HasTargetSpec for Builder<'_, '_, 'tcx> {
23942394
}
23952395
}
23962396

2397-
impl<'tcx> HasWasmCAbiOpt for Builder<'_, '_, 'tcx> {
2398-
fn wasm_c_abi_opt(&self) -> WasmCAbi {
2399-
self.cx.wasm_c_abi_opt()
2400-
}
2401-
}
2402-
24032397
impl<'tcx> HasX86AbiOpt for Builder<'_, '_, 'tcx> {
24042398
fn x86_abi_opt(&self) -> X86Abi {
24052399
self.cx.x86_abi_opt()

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use rustc_middle::ty::{self, ExistentialTraitRef, Instance, Ty, TyCtxt};
1919
use rustc_session::Session;
2020
use rustc_span::source_map::respan;
2121
use rustc_span::{DUMMY_SP, Span};
22-
use rustc_target::spec::{
23-
HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, Target, TlsModel, WasmCAbi, X86Abi,
24-
};
22+
use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, TlsModel, X86Abi};
2523

2624
#[cfg(feature = "master")]
2725
use crate::abi::conv_to_fn_attribute;
@@ -516,12 +514,6 @@ impl<'gcc, 'tcx> HasTargetSpec for CodegenCx<'gcc, 'tcx> {
516514
}
517515
}
518516

519-
impl<'gcc, 'tcx> HasWasmCAbiOpt for CodegenCx<'gcc, 'tcx> {
520-
fn wasm_c_abi_opt(&self) -> WasmCAbi {
521-
self.tcx.sess.opts.unstable_opts.wasm_c_abi
522-
}
523-
}
524-
525517
impl<'gcc, 'tcx> HasX86AbiOpt for CodegenCx<'gcc, 'tcx> {
526518
fn x86_abi_opt(&self) -> X86Abi {
527519
X86Abi {

compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind};
22
use rustc_attr_data_structures::InstructionSetAttr;
3-
use rustc_hir::def_id::DefId;
43
use rustc_middle::mir::mono::{Linkage, MonoItemData, Visibility};
54
use rustc_middle::mir::{InlineAsmOperand, START_BLOCK};
65
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
76
use rustc_middle::ty::{Instance, Ty, TyCtxt, TypeVisitableExt};
8-
use rustc_middle::{bug, span_bug, ty};
7+
use rustc_middle::{bug, ty};
98
use rustc_span::sym;
109
use rustc_target::callconv::{ArgAbi, FnAbi, PassMode};
11-
use rustc_target::spec::{BinaryFormat, WasmCAbi};
10+
use rustc_target::spec::BinaryFormat;
1211

1312
use crate::common;
1413
use crate::mir::AsmCodegenMethods;
@@ -287,12 +286,7 @@ fn prefix_and_suffix<'tcx>(
287286
writeln!(begin, "{}", arch_prefix).unwrap();
288287
}
289288
writeln!(begin, "{asm_name}:").unwrap();
290-
writeln!(
291-
begin,
292-
".functype {asm_name} {}",
293-
wasm_functype(tcx, fn_abi, instance.def_id())
294-
)
295-
.unwrap();
289+
writeln!(begin, ".functype {asm_name} {}", wasm_functype(tcx, fn_abi)).unwrap();
296290

297291
writeln!(end).unwrap();
298292
// .size is ignored for function symbols, so we can skip it
@@ -333,7 +327,7 @@ fn prefix_and_suffix<'tcx>(
333327
/// The webassembly type signature for the given function.
334328
///
335329
/// Used by the `.functype` directive on wasm targets.
336-
fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id: DefId) -> String {
330+
fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> String {
337331
let mut signature = String::with_capacity(64);
338332

339333
let ptr_type = match tcx.data_layout.pointer_size.bits() {
@@ -342,17 +336,6 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
342336
other => bug!("wasm pointer size cannot be {other} bits"),
343337
};
344338

345-
// FIXME: remove this once the wasm32-unknown-unknown ABI is fixed
346-
// please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
347-
// basically the commit introducing this comment should be reverted
348-
if let PassMode::Pair { .. } = fn_abi.ret.mode {
349-
let _ = WasmCAbi::Legacy { with_lint: true };
350-
span_bug!(
351-
tcx.def_span(def_id),
352-
"cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
353-
);
354-
}
355-
356339
let hidden_return = matches!(fn_abi.ret.mode, PassMode::Indirect { .. });
357340

358341
signature.push('(');
@@ -366,7 +349,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
366349

367350
let mut it = fn_abi.args.iter().peekable();
368351
while let Some(arg_abi) = it.next() {
369-
wasm_type(tcx, &mut signature, arg_abi, ptr_type, def_id);
352+
wasm_type(&mut signature, arg_abi, ptr_type);
370353
if it.peek().is_some() {
371354
signature.push_str(", ");
372355
}
@@ -375,35 +358,21 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
375358
signature.push_str(") -> (");
376359

377360
if !hidden_return {
378-
wasm_type(tcx, &mut signature, &fn_abi.ret, ptr_type, def_id);
361+
wasm_type(&mut signature, &fn_abi.ret, ptr_type);
379362
}
380363

381364
signature.push(')');
382365

383366
signature
384367
}
385368

386-
fn wasm_type<'tcx>(
387-
tcx: TyCtxt<'tcx>,
388-
signature: &mut String,
389-
arg_abi: &ArgAbi<'_, Ty<'tcx>>,
390-
ptr_type: &'static str,
391-
def_id: DefId,
392-
) {
369+
fn wasm_type<'tcx>(signature: &mut String, arg_abi: &ArgAbi<'_, Ty<'tcx>>, ptr_type: &'static str) {
393370
match arg_abi.mode {
394371
PassMode::Ignore => { /* do nothing */ }
395372
PassMode::Direct(_) => {
396373
let direct_type = match arg_abi.layout.backend_repr {
397374
BackendRepr::Scalar(scalar) => wasm_primitive(scalar.primitive(), ptr_type),
398375
BackendRepr::SimdVector { .. } => "v128",
399-
BackendRepr::Memory { .. } => {
400-
// FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
401-
let _ = WasmCAbi::Legacy { with_lint: true };
402-
span_bug!(
403-
tcx.def_span(def_id),
404-
"cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
405-
);
406-
}
407376
other => unreachable!("unexpected BackendRepr: {:?}", other),
408377
};
409378

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_span::source_map::{RealFileLoader, SourceMapInputs};
2727
use rustc_span::{FileName, SourceFileHashAlgorithm, sym};
2828
use rustc_target::spec::{
2929
CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
30-
RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, WasmCAbi,
30+
RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel,
3131
};
3232

3333
use crate::interface::{initialize_checked_jobserver, parse_cfg};
@@ -881,7 +881,6 @@ fn test_unstable_options_tracking_hash() {
881881
tracked!(verify_llvm_ir, true);
882882
tracked!(virtual_function_elimination, true);
883883
tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
884-
tracked!(wasm_c_abi, WasmCAbi::Spec);
885884
// tidy-alphabetical-end
886885

887886
macro_rules! tracked_no_crate_hash {

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ fn register_builtins(store: &mut LintStore) {
615615
"converted into hard error, \
616616
see <https://github.com/rust-lang/rust/issues/116558> for more information",
617617
);
618+
store.register_removed("wasm_c_abi", "the wasm C ABI has been fixed");
618619
}
619620

620621
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ declare_lint_pass! {
143143
UNUSED_VARIABLES,
144144
USELESS_DEPRECATED,
145145
WARNINGS,
146-
WASM_C_ABI,
147146
// tidy-alphabetical-end
148147
]
149148
}
@@ -5026,49 +5025,6 @@ declare_lint! {
50265025
crate_level_only
50275026
}
50285027

5029-
declare_lint! {
5030-
/// The `wasm_c_abi` lint detects usage of the `extern "C"` ABI of wasm that is affected
5031-
/// by a planned ABI change that has the goal of aligning Rust with the standard C ABI
5032-
/// of this target.
5033-
///
5034-
/// ### Example
5035-
///
5036-
/// ```rust,ignore (needs wasm32-unknown-unknown)
5037-
/// #[repr(C)]
5038-
/// struct MyType(i32, i32);
5039-
///
5040-
/// extern "C" my_fun(x: MyType) {}
5041-
/// ```
5042-
///
5043-
/// This will produce:
5044-
///
5045-
/// ```text
5046-
/// error: this function function definition is affected by the wasm ABI transition: it passes an argument of non-scalar type `MyType`
5047-
/// --> $DIR/wasm_c_abi_transition.rs:17:1
5048-
/// |
5049-
/// | pub extern "C" fn my_fun(_x: MyType) {}
5050-
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5051-
/// |
5052-
/// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5053-
/// = note: for more information, see issue #138762 <https://github.com/rust-lang/rust/issues/138762>
5054-
/// = help: the "C" ABI Rust uses on wasm32-unknown-unknown will change to align with the standard "C" ABI for this target
5055-
/// ```
5056-
///
5057-
/// ### Explanation
5058-
///
5059-
/// Rust has historically implemented a non-spec-compliant C ABI on wasm32-unknown-unknown. This
5060-
/// has caused incompatibilities with other compilers and Wasm targets. In a future version
5061-
/// of Rust, this will be fixed, and therefore code relying on the non-spec-compliant C ABI will
5062-
/// stop functioning.
5063-
pub WASM_C_ABI,
5064-
Warn,
5065-
"detects code relying on rustc's non-spec-compliant wasm C ABI",
5066-
@future_incompatible = FutureIncompatibleInfo {
5067-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
5068-
reference: "issue #138762 <https://github.com/rust-lang/rust/issues/138762>",
5069-
};
5070-
}
5071-
50725028
declare_lint! {
50735029
/// The `aarch64_softfloat_neon` lint detects usage of `#[target_feature(enable = "neon")]` on
50745030
/// softfloat aarch64 targets. Enabling this target feature causes LLVM to alter the ABI of

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension};
1616
use rustc_session::config::OptLevel;
1717
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
1818
use rustc_target::callconv::FnAbi;
19-
use rustc_target::spec::{
20-
HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, PanicStrategy, Target, WasmCAbi, X86Abi,
21-
};
19+
use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, PanicStrategy, Target, X86Abi};
2220
use tracing::debug;
2321
use {rustc_abi as abi, rustc_hir as hir};
2422

@@ -565,12 +563,6 @@ impl<'tcx> HasTargetSpec for TyCtxt<'tcx> {
565563
}
566564
}
567565

568-
impl<'tcx> HasWasmCAbiOpt for TyCtxt<'tcx> {
569-
fn wasm_c_abi_opt(&self) -> WasmCAbi {
570-
self.sess.opts.unstable_opts.wasm_c_abi
571-
}
572-
}
573-
574566
impl<'tcx> HasX86AbiOpt for TyCtxt<'tcx> {
575567
fn x86_abi_opt(&self) -> X86Abi {
576568
X86Abi {
@@ -625,12 +617,6 @@ impl<'tcx> HasTargetSpec for LayoutCx<'tcx> {
625617
}
626618
}
627619

628-
impl<'tcx> HasWasmCAbiOpt for LayoutCx<'tcx> {
629-
fn wasm_c_abi_opt(&self) -> WasmCAbi {
630-
self.calc.cx.wasm_c_abi_opt()
631-
}
632-
}
633-
634620
impl<'tcx> HasX86AbiOpt for LayoutCx<'tcx> {
635621
fn x86_abi_opt(&self) -> X86Abi {
636622
self.calc.cx.x86_abi_opt()

compiler/rustc_monomorphize/messages.ftl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,4 @@ monomorphize_start_not_found = using `fn main` requires the standard library
6060
6161
monomorphize_symbol_already_defined = symbol `{$symbol}` is already defined
6262
63-
monomorphize_wasm_c_abi_transition =
64-
this function {$is_call ->
65-
[true] call
66-
*[false] definition
67-
} involves an argument of type `{$ty}` which is affected by the wasm ABI transition
68-
.help = the "C" ABI Rust uses on wasm32-unknown-unknown will change to align with the standard "C" ABI for this target
69-
7063
monomorphize_written_to_path = the full type name has been written to '{$path}'

compiler/rustc_monomorphize/src/errors.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,3 @@ pub(crate) struct AbiRequiredTargetFeature<'a> {
100100
/// Whether this is a problem at a call site or at a declaration.
101101
pub is_call: bool,
102102
}
103-
104-
#[derive(LintDiagnostic)]
105-
#[diag(monomorphize_wasm_c_abi_transition)]
106-
#[help]
107-
pub(crate) struct WasmCAbiTransition<'a> {
108-
pub ty: Ty<'a>,
109-
/// Whether this is a problem at a call site or at a declaration.
110-
pub is_call: bool,
111-
}

0 commit comments

Comments
 (0)