Skip to content

Commit f2e7433

Browse files
committed
prefer actual ABI-controling fields over target.abi when making ABI decisions
1 parent 99246f4 commit f2e7433

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

compiler/rustc_codegen_llvm/src/va_arg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_codegen_ssa::traits::{
88
use rustc_middle::bug;
99
use rustc_middle::ty::Ty;
1010
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
11-
use rustc_target::spec::{Abi, Arch, Env};
11+
use rustc_target::spec::{Arch, Env, RustcAbi};
1212

1313
use crate::builder::Builder;
1414
use crate::llvm::{Type, Value};
@@ -272,7 +272,7 @@ fn emit_powerpc_va_arg<'ll, 'tcx>(
272272

273273
// Rust does not currently support any powerpc softfloat targets.
274274
let target = &bx.cx.tcx.sess.target;
275-
let is_soft_float_abi = target.abi == Abi::SoftFloat;
275+
let is_soft_float_abi = target.rustc_abi == Some(RustcAbi::Softfloat);
276276
assert!(!is_soft_float_abi);
277277

278278
// All instances of VaArgSafe are passed directly.
@@ -1077,7 +1077,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
10771077
AllowHigherAlign::Yes,
10781078
ForceRightAdjust::Yes,
10791079
),
1080-
Arch::RiscV32 if target.abi == Abi::Ilp32e => {
1080+
Arch::RiscV32 if target.llvm_abiname == "ilp32e" => {
10811081
// FIXME: clang manually adjusts the alignment for this ABI. It notes:
10821082
//
10831083
// > To be compatible with GCC's behaviors, we force arguments with

compiler/rustc_target/src/callconv/aarch64.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::iter;
33
use rustc_abi::{BackendRepr, HasDataLayout, Primitive, TyAbiInterface};
44

55
use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
6-
use crate::spec::{Abi, HasTargetSpec, Target};
6+
use crate::spec::{HasTargetSpec, RustcAbi, Target};
77

88
/// Indicates the variant of the AArch64 ABI we are compiling for.
99
/// Used to accommodate Apple and Microsoft's deviations from the usual AAPCS ABI.
@@ -34,7 +34,7 @@ where
3434
RegKind::Integer => false,
3535
// The softfloat ABI treats floats like integers, so they
3636
// do not get homogeneous aggregate treatment.
37-
RegKind::Float => cx.target_spec().abi != Abi::SoftFloat,
37+
RegKind::Float => cx.target_spec().rustc_abi != Some(RustcAbi::Softfloat),
3838
RegKind::Vector => size.bits() == 64 || size.bits() == 128,
3939
};
4040

@@ -43,7 +43,7 @@ where
4343
}
4444

4545
fn softfloat_float_abi<Ty>(target: &Target, arg: &mut ArgAbi<'_, Ty>) {
46-
if target.abi != Abi::SoftFloat {
46+
if target.rustc_abi != Some(RustcAbi::Softfloat) {
4747
return;
4848
}
4949
// Do *not* use the float registers for passing arguments, as that would make LLVM pick the ABI

compiler/rustc_target/src/spec/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,8 +2210,10 @@ pub struct TargetOptions {
22102210
pub env: Env,
22112211
/// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"`
22122212
/// or `"eabihf"`. Defaults to [`Abi::Unspecified`].
2213-
/// This field is *not* forwarded directly to LLVM; its primary purpose is `cfg(target_abi)`.
2214-
/// However, parts of the backend do check this field for specific values to enable special behavior.
2213+
/// This field is *not* forwarded directly to LLVM and therefore does not control which ABI (in
2214+
/// the sense of function calling convention) is actually used; its primary purpose is
2215+
/// `cfg(target_abi)`. The actual calling convention is controlled by `llvm_abiname`,
2216+
/// `llvm_floatabi`, and `rustc_abi`.
22152217
pub abi: Abi,
22162218
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
22172219
#[rustc_lint_opt_deny_field_access(
@@ -3207,7 +3209,7 @@ impl Target {
32073209
),
32083210
RustcAbi::Softfloat => check_matches!(
32093211
self.arch,
3210-
Arch::X86 | Arch::X86_64 | Arch::S390x,
3212+
Arch::X86 | Arch::X86_64 | Arch::S390x | Arch::AArch64,
32113213
"`softfloat` ABI is only valid for x86 and s390x targets"
32123214
),
32133215
}

compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
use rustc_abi::Endian;
99

1010
use crate::spec::{
11-
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
12-
Target, TargetMetadata, TargetOptions,
11+
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, RustcAbi, SanitizerSet,
12+
StackProbeType, Target, TargetMetadata, TargetOptions,
1313
};
1414

1515
pub(crate) fn target() -> Target {
1616
let opts = TargetOptions {
1717
abi: Abi::SoftFloat,
18+
rustc_abi: Some(RustcAbi::Softfloat),
1819
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1920
linker: Some("rust-lld".into()),
2021
features: "+v8a,+strict-align,-neon".into(),

compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
// For example, `-C target-cpu=cortex-a53`.
88

99
use crate::spec::{
10-
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
11-
Target, TargetMetadata, TargetOptions,
10+
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, RustcAbi, SanitizerSet,
11+
StackProbeType, Target, TargetMetadata, TargetOptions,
1212
};
1313

1414
pub(crate) fn target() -> Target {
1515
let opts = TargetOptions {
1616
abi: Abi::SoftFloat,
17+
rustc_abi: Some(RustcAbi::Softfloat),
1718
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1819
linker: Some("rust-lld".into()),
1920
features: "+v8a,+strict-align,-neon".into(),

compiler/rustc_target/src/spec/targets/aarch64v8r_unknown_none_softfloat.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use crate::spec::{
2-
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
3-
Target, TargetMetadata, TargetOptions,
2+
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, RustcAbi, SanitizerSet,
3+
StackProbeType, Target, TargetMetadata, TargetOptions,
44
};
55

66
pub(crate) fn target() -> Target {
77
let opts = TargetOptions {
88
abi: Abi::SoftFloat,
9+
rustc_abi: Some(RustcAbi::Softfloat),
910
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1011
linker: Some("rust-lld".into()),
1112
relocation_model: RelocModel::Static,

0 commit comments

Comments
 (0)