Skip to content

Commit d6dc965

Browse files
authored
Rollup merge of #133952 - bjorn3:remove_wasm_legacy_abi, r=alexcrichton
Remove wasm legacy abi Closes #122532 Closes #138762 Fixes #71871 #88152 Fixes #115666 Fixes #129486
2 parents 586ad39 + 4d536bd commit d6dc965

File tree

20 files changed

+28
-598
lines changed

20 files changed

+28
-598
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, AtomicOrdering, 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;
@@ -512,12 +510,6 @@ impl<'gcc, 'tcx> HasTargetSpec for CodegenCx<'gcc, 'tcx> {
512510
}
513511
}
514512

515-
impl<'gcc, 'tcx> HasWasmCAbiOpt for CodegenCx<'gcc, 'tcx> {
516-
fn wasm_c_abi_opt(&self) -> WasmCAbi {
517-
self.tcx.sess.opts.unstable_opts.wasm_c_abi
518-
}
519-
}
520-
521513
impl<'gcc, 'tcx> HasX86AbiOpt for CodegenCx<'gcc, 'tcx> {
522514
fn x86_abi_opt(&self) -> X86Abi {
523515
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};
@@ -882,7 +882,6 @@ fn test_unstable_options_tracking_hash() {
882882
tracked!(verify_llvm_ir, true);
883883
tracked!(virtual_function_elimination, true);
884884
tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
885-
tracked!(wasm_c_abi, WasmCAbi::Spec);
886885
// tidy-alphabetical-end
887886

888887
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
@@ -623,6 +623,7 @@ fn register_builtins(store: &mut LintStore) {
623623
"converted into hard error, \
624624
see <https://github.com/rust-lang/rust/issues/40107> for more information",
625625
);
626+
store.register_removed("wasm_c_abi", "the wasm C ABI has been fixed");
626627
}
627628

628629
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ declare_lint_pass! {
140140
UNUSED_VARIABLES,
141141
USELESS_DEPRECATED,
142142
WARNINGS,
143-
WASM_C_ABI,
144143
// tidy-alphabetical-end
145144
]
146145
}
@@ -4980,50 +4979,6 @@ declare_lint! {
49804979
crate_level_only
49814980
}
49824981

4983-
declare_lint! {
4984-
/// The `wasm_c_abi` lint detects usage of the `extern "C"` ABI of wasm that is affected
4985-
/// by a planned ABI change that has the goal of aligning Rust with the standard C ABI
4986-
/// of this target.
4987-
///
4988-
/// ### Example
4989-
///
4990-
/// ```rust,ignore (needs wasm32-unknown-unknown)
4991-
/// #[repr(C)]
4992-
/// struct MyType(i32, i32);
4993-
///
4994-
/// extern "C" my_fun(x: MyType) {}
4995-
/// ```
4996-
///
4997-
/// This will produce:
4998-
///
4999-
/// ```text
5000-
/// error: this function function definition is affected by the wasm ABI transition: it passes an argument of non-scalar type `MyType`
5001-
/// --> $DIR/wasm_c_abi_transition.rs:17:1
5002-
/// |
5003-
/// | pub extern "C" fn my_fun(_x: MyType) {}
5004-
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5005-
/// |
5006-
/// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5007-
/// = note: for more information, see issue #138762 <https://github.com/rust-lang/rust/issues/138762>
5008-
/// = help: the "C" ABI Rust uses on wasm32-unknown-unknown will change to align with the standard "C" ABI for this target
5009-
/// ```
5010-
///
5011-
/// ### Explanation
5012-
///
5013-
/// Rust has historically implemented a non-spec-compliant C ABI on wasm32-unknown-unknown. This
5014-
/// has caused incompatibilities with other compilers and Wasm targets. In a future version
5015-
/// of Rust, this will be fixed, and therefore code relying on the non-spec-compliant C ABI will
5016-
/// stop functioning.
5017-
pub WASM_C_ABI,
5018-
Warn,
5019-
"detects code relying on rustc's non-spec-compliant wasm C ABI",
5020-
@future_incompatible = FutureIncompatibleInfo {
5021-
reason: FutureIncompatibilityReason::FutureReleaseError,
5022-
reference: "issue #138762 <https://github.com/rust-lang/rust/issues/138762>",
5023-
report_in_deps: true,
5024-
};
5025-
}
5026-
50274982
declare_lint! {
50284983
/// The `aarch64_softfloat_neon` lint detects usage of `#[target_feature(enable = "neon")]` on
50294984
/// 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)