Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
explicitly set float ABI for all ARM targets
  • Loading branch information
RalfJung committed Dec 30, 2024
commit a51fefcaab835b310e2e26005b50982d0049d905
5 changes: 3 additions & 2 deletions compiler/rustc_target/src/spec/base/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::borrow::Cow;
use std::env;

use crate::spec::{
Cc, DebuginfoKind, FramePointer, LinkerFlavor, Lld, SplitDebuginfo, StackProbeType, StaticCow,
TargetOptions, cvs,
Cc, DebuginfoKind, FloatAbi, FramePointer, LinkerFlavor, Lld, SplitDebuginfo, StackProbeType,
StaticCow, TargetOptions, cvs,
};

#[cfg(test)]
Expand Down Expand Up @@ -105,6 +105,7 @@ pub(crate) fn base(
) -> (TargetOptions, StaticCow<str>, StaticCow<str>) {
let opts = TargetOptions {
abi: abi.target_abi().into(),
llvm_floatabi: Some(FloatAbi::Hard),
Copy link
Member Author

@RalfJung RalfJung Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume all the Apple targets use a hardfloat ABI? This is about armv7s_apple_ios.rs and armv7k_apple_watchos.rs. Both of these set +neon in their target features. LLVM switches to hardfloats for (TargetTriple.isOSBinFormatMachO() && TargetTriple.getSubArch() == Triple::ARMSubArch_v7em), not sure if that applies here.

Cc @deg4uss3r @madsmtm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is my understanding, yeah, and matches what Clang reports when you try to use a different float ABI:

$ touch foo.c
$ xcrun -sdk watchos clang -target armv7k-apple-watchos -S -c foo.c -mfloat-abi=hard # Succeeds
$ xcrun -sdk watchos clang -target armv7k-apple-watchos -S -c foo.c -mfloat-abi=soft # Fails
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7k-apple-watchos'
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7k-apple-watchos'
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7k-apple-watchos'
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7k-apple-watchos'
$ xcrun -sdk watchos clang -target armv7s-apple-watchos -S -c foo.c -mfloat-abi=hard # Succeeds
$ xcrun -sdk watchos clang -target armv7s-apple-watchos -S -c foo.c -mfloat-abi=soft # Fails
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7s-apple-watchos'
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7s-apple-watchos'
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7s-apple-watchos'
clang: error: unsupported option '-mfloat-abi=soft' for target 'thumbv7s-apple-watchos'

os: os.into(),
cpu: arch.target_cpu(abi).into(),
link_env_remove: link_env_remove(os),
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3194,7 +3194,8 @@ impl Target {
);
}

// Check that RISC-V targets always specify which ABI they use.
// Check that RISC-V targets always specify which ABI they use,
// and that ARM targets specify their float ABI.
match &*self.arch {
"riscv32" => {
check_matches!(
Expand All @@ -3211,6 +3212,9 @@ impl Target {
"invalid RISC-V ABI name"
);
}
"arm" => {
check!(self.llvm_floatabi.is_some(), "ARM targets must specify their float ABI",)
}
_ => {}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{SanitizerSet, Target, TargetOptions, base};
use crate::spec::{FloatAbi, SanitizerSet, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
// https://developer.android.com/ndk/guides/abis.html#armeabi
features: "+strict-align,+v5te".into(),
supported_sanitizers: SanitizerSet::ADDRESS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+strict-align,+v6".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
features: "+strict-align,+v6,+vfp2,-d32".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -17,6 +17,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
// Most of these settings are copied from the arm_unknown_linux_gnueabi
// target.
features: "+strict-align,+v6".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -17,6 +17,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
// Most of these settings are copied from the arm_unknown_linux_gnueabihf
// target.
features: "+strict-align,+v6,+vfp2,-d32".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::abi::Endian;
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+strict-align,+v8,+crc".into(),
endian: Endian::Big,
max_atomic_width: Some(64),
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Targets the Big endian Cortex-R4/R5 processor (ARMv7-R)

use crate::abi::Endian;
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions,
};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -17,6 +19,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
endian: Endian::Big,
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Targets the Cortex-R4F/R5F processor (ARMv7-R)

use crate::abi::Endian;
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions,
};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -17,6 +19,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
endian: Endian::Big,
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
//! The default link script is very likely wrong, so you should use
//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script.

use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs};
use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -34,6 +36,7 @@ pub(crate) fn target() -> Target {
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+soft-float,+strict-align".into(),
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Targets the ARMv5TE, with code as `a32` code by default.

use crate::spec::{FramePointer, Target, TargetOptions, base, cvs};
use crate::spec::{FloatAbi, FramePointer, Target, TargetOptions, base, cvs};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -26,6 +26,7 @@ pub(crate) fn target() -> Target {

options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
// extra args passed to the external assembler (assuming `arm-none-eabi-as`):
// * activate t32/a32 interworking
// * use arch ARMv5TE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+soft-float,+strict-align".into(),
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -18,6 +18,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+soft-float,+strict-align".into(),
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+soft-float,+strict-align".into(),
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v6,+vfp2,-d32".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v6,+vfp2,-d32".into(),
max_atomic_width: Some(64),
mcount: "__mcount".into(),
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions, cvs};
use crate::spec::{Cc, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetOptions, cvs};

/// A base target for Nintendo 3DS devices using the devkitARM toolchain.
///
Expand Down Expand Up @@ -28,8 +28,9 @@ pub(crate) fn target() -> Target {
os: "horizon".into(),
env: "newlib".into(),
vendor: "nintendo".into(),
abi: "eabihf".into(),
cpu: "mpcore".into(),
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
families: cvs!["unix"],
linker: Some("arm-none-eabi-gcc".into()),
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions, base};
use crate::spec::{Cc, FloatAbi, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions, base};

// This target if is for the baseline of the Android v7a ABI
// in thumb mode. It's named armv7-* instead of thumbv7-*
Expand All @@ -24,6 +24,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".into(),
supported_sanitizers: SanitizerSet::ADDRESS,
max_atomic_width: Some(64),
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_target/src/spec/targets/armv7_rtems_eabihf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs};
use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -17,6 +19,7 @@ pub(crate) fn target() -> Target {
os: "rtems".into(),
families: cvs!["unix"],
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
linker: None,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::abi::Endian;
use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions, cvs};
use crate::spec::{Cc, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetOptions, cvs};

/// A base target for PlayStation Vita devices using the VITASDK toolchain (using newlib).
///
Expand Down Expand Up @@ -32,6 +32,7 @@ pub(crate) fn target() -> Target {
env: "newlib".into(),
vendor: "sony".into(),
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
no_default_libraries: false,
cpu: "cortex-a9".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

// This target is for glibc Linux on ARMv7 without thumb-mode, NEON or
// hardfloat.
Expand All @@ -17,6 +17,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+v7,+thumb2,+soft-float,-neon".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

// This target is for glibc Linux on ARMv7 without NEON or
// thumb-mode. See the thumbv7neon variant for enabling both.
Expand All @@ -17,6 +17,7 @@ pub(crate) fn target() -> Target {
arch: "arm".into(),
options: TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
// Info about features at https://wiki.debian.org/ArmHardFloatPort
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
max_atomic_width: Some(64),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{FloatAbi, Target, TargetOptions, base};

// This target is for musl Linux on ARMv7 without thumb-mode, NEON or
// hardfloat.
Expand All @@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {

options: TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
features: "+v7,+thumb2,+soft-float,-neon".into(),
max_atomic_width: Some(64),
mcount: "\u{1}mcount".into(),
Expand Down
Loading