aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPiotr Kubaj <pkubaj@FreeBSD.org>2023-02-16 23:49:43 +0000
committerPiotr Kubaj <pkubaj@FreeBSD.org>2023-02-16 23:53:30 +0000
commita1ffc2fe9ce54a498c410dcab86495569dbaa7cc (patch)
treece161465c46582e54ca14edef30a2e0b1aab0802 /contrib
parent780bae23b8e6c386e4b2f971eb27fa3bd1a6edd1 (diff)
downloadsrc-a1ffc2fe9ce54a498c410dcab86495569dbaa7cc.tar.gz
src-a1ffc2fe9ce54a498c410dcab86495569dbaa7cc.zip
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
Diffstat (limited to 'contrib')
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/PPC.h3
-rw-r--r--contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp5
2 files changed, 7 insertions, 1 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
index 8148762f446b..62a06bd493be 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
@@ -427,6 +427,9 @@ public:
} else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
DataLayout = "e-m:e-i64:64-n32:64";
ABI = "elfv2";
+ } else if (Triple.isOSFreeBSD() && (Triple.getOSMajorVersion() == 0 || Triple.getOSMajorVersion() >= 13)) {
+ DataLayout = "E-m:e-i64:64-n32:64";
+ ABI = "elfv2";
} else {
DataLayout = "E-m:e-i64:64-n32:64";
ABI = "elfv1";
diff --git a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index fe396cbfc011..a9bb96d47c7e 100644
--- a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -231,8 +231,11 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
assert(Options.MCOptions.getABIName().empty() &&
"Unknown target-abi option!");
- if (TT.isMacOSX())
+ if (TT.isMacOSX()) {
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()) {
case Triple::ppc64le: