Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions compiler/rustc_target/src/callconv/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use rustc_abi::{Endian, HasDataLayout, TyAbiInterface};

use crate::callconv::{Align, ArgAbi, FnAbi, Reg, RegKind, Uniform};
use crate::spec::{Env, HasTargetSpec, Os};
use crate::spec::{Abi, HasTargetSpec, Os};

#[derive(Debug, Clone, Copy, PartialEq)]
enum ABI {
Expand Down Expand Up @@ -106,8 +106,10 @@ where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,
{
let abi = if cx.target_spec().env == Env::Musl || cx.target_spec().os == Os::FreeBsd {
let abi = if cx.target_spec().options.abi == Abi::ElfV2 {
ELFv2
} else if cx.target_spec().options.abi == Abi::ElfV1 {
ELFv1
Comment on lines +109 to +112
Copy link
Member

Choose a reason for hiding this comment

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

Oh, I only just realized that this could also check llvm_abiname -- which is what actually gets sanity-checked in the target spec logic, and it is what actually tells LLVM what to do, so it's the more reliable source of truth.

Can you submit a PR to check llvm_abiname here instead?

} else if cx.target_spec().os == Os::Aix {
AIX
} else {
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3182,6 +3182,27 @@ impl Target {
"ARM targets must set `llvm-floatabi` to `hard` or `soft`",
)
}
// PowerPC64 targets that are not AIX must set their ABI to either ELFv1 or ELFv2
Arch::PowerPC64 => {
if self.os == Os::Aix {
check!(
self.llvm_abiname.is_empty(),
"AIX targets always use the AIX ABI and `llvm_abiname` should be left empty",
);
} else if self.endian == Endian::Big {
check_matches!(
&*self.llvm_abiname,
"elfv1" | "elfv2",
"invalid PowerPC64 ABI name: {}",
self.llvm_abiname,
);
} else {
check!(
self.llvm_abiname == "elfv2",
"little-endian PowerPC64 targets only support the `elfv2` ABI",
);
}
}
_ => {}
}

Expand Down
Loading