Remove all support for wasm's legacy ABI
This commit is contained in:
@@ -7,7 +7,7 @@ use rustc_abi::{
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
||||
pub use crate::spec::AbiMap;
|
||||
use crate::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, WasmCAbi};
|
||||
use crate::spec::{HasTargetSpec, HasX86AbiOpt};
|
||||
|
||||
mod aarch64;
|
||||
mod amdgpu;
|
||||
@@ -593,7 +593,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
||||
pub fn adjust_for_foreign_abi<C>(&mut self, cx: &C, abi: ExternAbi)
|
||||
where
|
||||
Ty: TyAbiInterface<'a, C> + Copy,
|
||||
C: HasDataLayout + HasTargetSpec + HasWasmCAbiOpt + HasX86AbiOpt,
|
||||
C: HasDataLayout + HasTargetSpec + HasX86AbiOpt,
|
||||
{
|
||||
if abi == ExternAbi::X86Interrupt {
|
||||
if let Some(arg) = self.args.first_mut() {
|
||||
@@ -669,14 +669,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
||||
"hexagon" => hexagon::compute_abi_info(self),
|
||||
"xtensa" => xtensa::compute_abi_info(cx, self),
|
||||
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
|
||||
"wasm32" => {
|
||||
if spec.os == "unknown" && matches!(cx.wasm_c_abi_opt(), WasmCAbi::Legacy { .. }) {
|
||||
wasm::compute_wasm_abi_info(self)
|
||||
} else {
|
||||
wasm::compute_c_abi_info(cx, self)
|
||||
}
|
||||
}
|
||||
"wasm64" => wasm::compute_c_abi_info(cx, self),
|
||||
"wasm32" | "wasm64" => wasm::compute_abi_info(cx, self),
|
||||
"bpf" => bpf::compute_abi_info(self),
|
||||
arch => panic!("no lowering implemented for {arch}"),
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ where
|
||||
}
|
||||
|
||||
/// The purpose of this ABI is to match the C ABI (aka clang) exactly.
|
||||
pub(crate) fn compute_c_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyAbiInterface<'a, C> + Copy,
|
||||
C: HasDataLayout,
|
||||
@@ -75,43 +75,3 @@ where
|
||||
classify_arg(cx, arg);
|
||||
}
|
||||
}
|
||||
|
||||
/// The purpose of this ABI is for matching the WebAssembly standard. This
|
||||
/// intentionally diverges from the C ABI and is specifically crafted to take
|
||||
/// advantage of LLVM's support of multiple returns in WebAssembly.
|
||||
///
|
||||
/// This ABI is *bad*! It uses `PassMode::Direct` for `abi::Aggregate` types, which leaks LLVM
|
||||
/// implementation details into the ABI. It's just hard to fix because ABIs are hard to change.
|
||||
/// Also see <https://github.com/rust-lang/rust/issues/115666>.
|
||||
pub(crate) fn compute_wasm_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret_wasm_abi(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
classify_arg_wasm_abi(arg);
|
||||
}
|
||||
|
||||
fn classify_ret_wasm_abi<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||
if !ret.layout.is_sized() {
|
||||
// Not touching this...
|
||||
return;
|
||||
}
|
||||
// FIXME: this is bad! https://github.com/rust-lang/rust/issues/115666
|
||||
ret.make_direct_deprecated();
|
||||
ret.extend_integer_width_to(32);
|
||||
}
|
||||
|
||||
fn classify_arg_wasm_abi<Ty>(arg: &mut ArgAbi<'_, Ty>) {
|
||||
if !arg.layout.is_sized() {
|
||||
// Not touching this...
|
||||
return;
|
||||
}
|
||||
// FIXME: this is bad! https://github.com/rust-lang/rust/issues/115666
|
||||
arg.make_direct_deprecated();
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2233,22 +2233,6 @@ impl HasTargetSpec for Target {
|
||||
}
|
||||
}
|
||||
|
||||
/// Which C ABI to use for `wasm32-unknown-unknown`.
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub enum WasmCAbi {
|
||||
/// Spec-compliant C ABI.
|
||||
Spec,
|
||||
/// Legacy ABI. Which is non-spec-compliant.
|
||||
Legacy {
|
||||
/// Indicates whether the `wasm_c_abi` lint should be emitted.
|
||||
with_lint: bool,
|
||||
},
|
||||
}
|
||||
|
||||
pub trait HasWasmCAbiOpt {
|
||||
fn wasm_c_abi_opt(&self) -> WasmCAbi;
|
||||
}
|
||||
|
||||
/// x86 (32-bit) abi options.
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct X86Abi {
|
||||
|
||||
Reference in New Issue
Block a user