[PATCH] D144232: [PowerPC] Correctly use ELFv2 ABI on FreeBSD/powerpc64
Piotr Kubaj via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 16 15:59:06 PST 2023
pkubaj created this revision.
pkubaj added reviewers: dim, nemanjai, adalava.
Herald added subscribers: shchenz, kbarton, hiraditya.
Herald added a project: All.
pkubaj requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
Currently ELFv2 is mostly set, but some places still default to ELFv1.
While this mostly works, it breaks in particular when lld is used with LTO,
as reported in https://github.com/llvm/llvm-project/issues/46697.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144232
Files:
clang/lib/Basic/Targets/PPC.h
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -233,6 +233,10 @@
assert(Options.MCOptions.getABIName().empty() &&
"Unknown target-abi option!");
+ if (TT.isOSFreeBSD() && TT.getArch() == Triple::ppc64 && (TT.getOSMajorVersion() == 0 || TT.getOSMajorVersion() >= 13)) {
+ return PPCTargetMachine::PPC_ABI_ELFv2;
+ }
+
switch (TT.getArch()) {
case Triple::ppc64le:
return PPCTargetMachine::PPC_ABI_ELFv2;
Index: clang/lib/Basic/Targets/PPC.h
===================================================================
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -425,6 +425,9 @@
} 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";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144232.498183.patch
Type: text/x-patch
Size: 1186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230216/945d72fa/attachment.bin>
More information about the llvm-commits
mailing list