Skip to content

Commit 563fb40

Browse files
authored
Unrolled build for #150468
Rollup merge of #150468 - Gelbpunkt:rustc-target-callconv-spec-elf-abi, r=RalfJung rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing All PowerPC64 targets except AIX explicitly set the ABI in the target options. We can therefore stop hardcoding the ABI to be used based on the target environment or OS, except for the AIX special case. The fallback based on endianness is kept for the sake of compatibility with custom targets. This makes it so that big endian targets not explicitly accounted for before (powerpc64-unknown-openbsd) and targets that don't use the expected default ABI (big-endian ELFv2 Glibc targets) use the correct ABI in the calling convention code. The second commit is a tiny change to validate the `llvm_abiname` set on PowerPC64(LE) targets. See the commit messages for details. CC @RalfJung who pointed out the missing `llvm_abiname` validation
2 parents d8b2222 + 168f324 commit 563fb40

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

‎compiler/rustc_target/src/callconv/powerpc64.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use rustc_abi::{Endian, HasDataLayout, TyAbiInterface};
66

77
use crate::callconv::{Align, ArgAbi, FnAbi, Reg, RegKind, Uniform};
8-
use crate::spec::{Env, HasTargetSpec, Os};
8+
use crate::spec::{Abi, HasTargetSpec, Os};
99

1010
#[derive(Debug, Clone, Copy, PartialEq)]
1111
enum ABI {
@@ -106,8 +106,10 @@ where
106106
Ty: TyAbiInterface<'a, C> + Copy,
107107
C: HasDataLayout + HasTargetSpec,
108108
{
109-
let abi = if cx.target_spec().env == Env::Musl || cx.target_spec().os == Os::FreeBsd {
109+
let abi = if cx.target_spec().options.abi == Abi::ElfV2 {
110110
ELFv2
111+
} else if cx.target_spec().options.abi == Abi::ElfV1 {
112+
ELFv1
111113
} else if cx.target_spec().os == Os::Aix {
112114
AIX
113115
} else {

‎compiler/rustc_target/src/spec/mod.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,27 @@ impl Target {
31943194
"ARM targets must set `llvm-floatabi` to `hard` or `soft`",
31953195
)
31963196
}
3197+
// PowerPC64 targets that are not AIX must set their ABI to either ELFv1 or ELFv2
3198+
Arch::PowerPC64 => {
3199+
if self.os == Os::Aix {
3200+
check!(
3201+
self.llvm_abiname.is_empty(),
3202+
"AIX targets always use the AIX ABI and `llvm_abiname` should be left empty",
3203+
);
3204+
} else if self.endian == Endian::Big {
3205+
check_matches!(
3206+
&*self.llvm_abiname,
3207+
"elfv1" | "elfv2",
3208+
"invalid PowerPC64 ABI name: {}",
3209+
self.llvm_abiname,
3210+
);
3211+
} else {
3212+
check!(
3213+
self.llvm_abiname == "elfv2",
3214+
"little-endian PowerPC64 targets only support the `elfv2` ABI",
3215+
);
3216+
}
3217+
}
31973218
_ => {}
31983219
}
31993220

0 commit comments

Comments
 (0)