diff options
author | Brad Smith <brad@comstyle.com> | 2023-02-20 19:46:16 -0500 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2023-02-21 22:22:59 -0800 |
commit | 4c0da2726e7f40b400066a6fb292dc260e135f3e (patch) | |
tree | 085d5aee599a1a4b6e49696700ee5598f2b471ed /clang | |
parent | 80a3a5fe15f71695086eb133a04e7b771a23a765 (diff) | |
download | llvm-llvmorg-16.0.0-rc3.zip llvm-llvmorg-16.0.0-rc3.tar.gz llvm-llvmorg-16.0.0-rc3.tar.bz2 |
[PATCH] [PowerPC] Correctly use ELFv2 ABI on all OS's that use the ELFv2 ABIllvmorg-16.0.0-rc3
Add a member function isPPC64ELFv2ABI() to determine what ABI is used on the
64-bit PowerPC big endian operating environment.
Reviewed By: nemanjai, dim, pkubaj
Differential Revision: https://reviews.llvm.org/D144321
(cherry picked from commit 4b09cb2b16ebac179264b2bf5d99d19f363f24b8)
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Basic/Targets/PPC.h | 5 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Clang.cpp | 3 | ||||
-rw-r--r-- | clang/test/Driver/ppc-abi.c | 1 |
3 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h index cc185fd..c8197154 100644 --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -428,7 +428,10 @@ public: ABI = "elfv2"; } else { DataLayout = "E-m:e-i64:64-n32:64"; - ABI = "elfv1"; + if (Triple.isPPC64ELFv2ABI()) + ABI = "elfv2"; + else + ABI = "elfv1"; } if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 3d40e19..832aaf0 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2003,8 +2003,7 @@ void Clang::AddPPCTargetArgs(const ArgList &Args, if (T.isOSBinFormatELF()) { switch (getToolChain().getArch()) { case llvm::Triple::ppc64: { - if ((T.isOSFreeBSD() && T.getOSMajorVersion() >= 13) || - T.isOSOpenBSD() || T.isMusl()) + if (T.isPPC64ELFv2ABI()) ABIName = "elfv2"; else ABIName = "elfv1"; diff --git a/clang/test/Driver/ppc-abi.c b/clang/test/Driver/ppc-abi.c index a3840c6..cc07b08 100644 --- a/clang/test/Driver/ppc-abi.c +++ b/clang/test/Driver/ppc-abi.c @@ -20,6 +20,7 @@ // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s // RUN: %clang -target powerpc64-unknown-freebsd13 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s // RUN: %clang -target powerpc64-unknown-freebsd14 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s +// RUN: %clang -target powerpc64-unknown-freebsd %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s // RUN: %clang -target powerpc64le-unknown-freebsd13 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2 %s // RUN: %clang -target powerpc64-unknown-openbsd %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE-PIE %s // RUN: %clang -target powerpc64-linux-musl %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE-PIE %s |