Skip to content

Commit 17b820c

Browse files
committed
arm: use target.abi over soft-float target feature
1 parent 5c6ed53 commit 17b820c

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3168,14 +3168,22 @@ impl Target {
31683168
self.llvm_abiname,
31693169
);
31703170
}
3171-
"aarch64" => {
3171+
"aarch64" | "arm64ec" => {
31723172
check_matches!(
31733173
&*self.abi,
31743174
"softfloat" | "uwp" | "llvm" | "macabi" | "sim" | "ilp32" | "",
31753175
"invalid aarch64 ABI name: {}",
31763176
self.abi,
31773177
)
31783178
}
3179+
"arm" => {
3180+
check_matches!(
3181+
&*self.abi,
3182+
"eabi" | "eabihf" | "uwp" | "macabi" | "sim" | "",
3183+
"invalid aarch64 ABI name: {}",
3184+
self.abi,
3185+
)
3186+
}
31793187
_ => {}
31803188
}
31813189

compiler/rustc_target/src/target_features.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ impl Target {
758758
match &*self.arch {
759759
"x86" => {
760760
// We support 2 ABIs, hardfloat (default) and softfloat.
761+
// x86 has no sane ABI indicator so we have to use the target feature.
761762
if self.has_feature("soft-float") {
762763
NOTHING
763764
} else {
@@ -767,6 +768,7 @@ impl Target {
767768
}
768769
"x86_64" => {
769770
// We support 2 ABIs, hardfloat (default) and softfloat.
771+
// x86 has no sane ABI indicator so we have to use the target feature.
770772
if self.has_feature("soft-float") {
771773
NOTHING
772774
} else {
@@ -775,20 +777,20 @@ impl Target {
775777
}
776778
}
777779
"arm" => {
778-
// We support 2 ABIs, hardfloat (default) and softfloat.
779-
if self.has_feature("soft-float") {
780-
NOTHING
781-
} else {
782-
// Hardfloat ABI. x87 must be enabled.
783-
(&["fpregs"], &[])
780+
// It's unclear how the `abi` and the `soft-float` target feature interact.
781+
// We use the `abi` as our primary signal, and force `soft-float` to match.
782+
match &*self.abi {
783+
"eabi" => (&["soft-float"], &[]),
784+
"eabihf" | "uwp" | "macabi" | "sim" | "" => (&["fpregs"], &["soft-float"]),
785+
_ => unreachable!(),
784786
}
785787
}
786788
"aarch64" | "arm64ec" => {
787789
match &*self.abi {
788790
"softfloat" => {
789791
// This is not fully correct, LLVM actually doesn't let us enforce the softfloat
790792
// ABI properly... see <https://github.com/rust-lang/rust/issues/134375>.
791-
// FIXME: should be forbid "neon" here? But that would be a breaking change.
793+
// FIXME: should we forbid "neon" here? But that would be a breaking change.
792794
NOTHING
793795
}
794796
"uwp" | "llvm" | "macabi" | "sim" | "ilp32" | "" => {

tests/run-make/simd-ffi/rmake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn main() {
5656
.target(&target)
5757
.emit("llvm-ir,asm")
5858
.input("simd.rs")
59-
.arg("-Ctarget-feature=+neon,+sse")
59+
.arg("-Ctarget-feature=+fpregs,+neon,+sse")
6060
.arg(&format!("-Cextra-filename=-{target}"))
6161
.run();
6262
}

0 commit comments

Comments
 (0)