llvm: make sure to use ELFv2 ABI on powerpc64

Currently LLVM is more or less set up to use ELFv2, but it still defaults to
ELFv1 in some places. This causes lld to generate broken binaries when used
with LTO.

PR:	269455
Approved by:	dim
MFC after:	3 days
This commit is contained in:
Piotr Kubaj 2023-02-17 00:49:43 +01:00
parent 780bae23b8
commit a1ffc2fe9c
2 changed files with 7 additions and 1 deletions

View File

@ -427,6 +427,9 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo {
} else if ((Triple.getArch() == llvm::Triple::ppc64le)) { } else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
DataLayout = "e-m:e-i64:64-n32:64"; DataLayout = "e-m:e-i64:64-n32:64";
ABI = "elfv2"; ABI = "elfv2";
} else if (Triple.isOSFreeBSD() && (Triple.getOSMajorVersion() == 0 || Triple.getOSMajorVersion() >= 13)) {
DataLayout = "E-m:e-i64:64-n32:64";
ABI = "elfv2";
} else { } else {
DataLayout = "E-m:e-i64:64-n32:64"; DataLayout = "E-m:e-i64:64-n32:64";
ABI = "elfv1"; ABI = "elfv1";

View File

@ -231,8 +231,11 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
assert(Options.MCOptions.getABIName().empty() && assert(Options.MCOptions.getABIName().empty() &&
"Unknown target-abi option!"); "Unknown target-abi option!");
if (TT.isMacOSX()) if (TT.isMacOSX()) {
return PPCTargetMachine::PPC_ABI_UNKNOWN; return PPCTargetMachine::PPC_ABI_UNKNOWN;
} else if (TT.isOSFreeBSD() && TT.getArch() == Triple::ppc64 && (TT.getOSMajorVersion() == 0 || TT.getOSMajorVersion() >= 13)) {
return PPCTargetMachine::PPC_ABI_ELFv2;
}
switch (TT.getArch()) { switch (TT.getArch()) {
case Triple::ppc64le: case Triple::ppc64le: