[llvm-branch-commits] [clang] 13be923 - [Driver] Allow for sparcv8plus subdir with Solaris/SPARC GCC
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 11 00:08:16 PDT 2023
Author: Rainer Orth
Date: 2023-08-11T09:01:22+02:00
New Revision: 13be923dfb738bc41f6a3b03b030f05903fcf46a
URL: https://github.com/llvm/llvm-project/commit/13be923dfb738bc41f6a3b03b030f05903fcf46a
DIFF: https://github.com/llvm/llvm-project/commit/13be923dfb738bc41f6a3b03b030f05903fcf46a.diff
LOG: [Driver] Allow for sparcv8plus subdir with Solaris/SPARC GCC
Since GCC 11, the bundled Solaris/SPARC GCC uses the `sparcv8plus`
subdirectory for 32-bit objects, just like upstream GCC. Before that, it
used `32` instead from a local patch.
Since `clang` doesn't know about that `sparcv8plus` subdirectory, it
wouldn't properly use GCC 11+ installations.
The new `solaris-sparc-gcc-search.test` testcase wasn't run initially (like
the existing `crash-report-null.test`) because the `.test` suffix wasn't
handled.
Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.
Differential Revision: https://reviews.llvm.org/D157013
(cherry picked from commit 43dfe0f08ecaf50f986512d0548bd3ac84d1813b)
Added:
clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/32/crtbegin.o
clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/crtbegin.o
clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/crtbegin.o
clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/sparcv8plus/crtbegin.o
clang/test/Driver/solaris-sparc-gcc-search.test
Modified:
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/lit.local.cfg
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index b64fff8b14be8a..8ea2712336e179 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1874,6 +1874,12 @@ static bool findBiarchMultilibs(const Driver &D,
.flag("-m64", /*Disallow=*/true)
.flag("-mx32")
.makeMultilib();
+ Multilib Alt32sparc = MultilibBuilder()
+ .gccSuffix("/sparcv8plus")
+ .includeSuffix("/sparcv8plus")
+ .flag("-m32")
+ .flag("-m64", /*Disallow=*/true)
+ .makeMultilib();
// GCC toolchain for IAMCU doesn't have crtbegin.o, so look for libgcc.a.
FilterNonExistent NonExistent(
@@ -1885,10 +1891,14 @@ static bool findBiarchMultilibs(const Driver &D,
const bool IsX32 = TargetTriple.isX32();
if (TargetTriple.isArch32Bit() && !NonExistent(Alt32))
Want = WANT64;
+ if (TargetTriple.isArch32Bit() && !NonExistent(Alt32sparc))
+ Want = WANT64;
else if (TargetTriple.isArch64Bit() && IsX32 && !NonExistent(Altx32))
Want = WANT64;
else if (TargetTriple.isArch64Bit() && !IsX32 && !NonExistent(Alt64))
Want = WANT32;
+ else if (TargetTriple.isArch64Bit() && !NonExistent(Alt32sparc))
+ Want = WANT64;
else {
if (TargetTriple.isArch32Bit())
Want = NeedsBiarchSuffix ? WANT64 : WANT32;
@@ -1919,6 +1929,7 @@ static bool findBiarchMultilibs(const Driver &D,
Result.Multilibs.push_back(Alt64);
Result.Multilibs.push_back(Alt32);
Result.Multilibs.push_back(Altx32);
+ Result.Multilibs.push_back(Alt32sparc);
Result.Multilibs.FilterOut(NonExistent);
@@ -1932,7 +1943,8 @@ static bool findBiarchMultilibs(const Driver &D,
if (Result.SelectedMultilibs.back() == Alt64 ||
Result.SelectedMultilibs.back() == Alt32 ||
- Result.SelectedMultilibs.back() == Altx32)
+ Result.SelectedMultilibs.back() == Altx32 ||
+ Result.SelectedMultilibs.back() == Alt32sparc)
Result.BiarchSibling = Default;
return true;
diff --git a/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/32/crtbegin.o b/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/32/crtbegin.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/crtbegin.o b/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/crtbegin.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/crtbegin.o b/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/crtbegin.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/sparcv8plus/crtbegin.o b/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/sparcv8plus/crtbegin.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/lit.local.cfg b/clang/test/Driver/lit.local.cfg
index cb788c205b9d74..6370e9f92d89b9 100644
--- a/clang/test/Driver/lit.local.cfg
+++ b/clang/test/Driver/lit.local.cfg
@@ -20,6 +20,7 @@ config.suffixes = [
".hipi",
".hlsl",
".yaml",
+ ".test",
]
config.substitutions = list(config.substitutions)
config.substitutions.insert(
diff --git a/clang/test/Driver/solaris-sparc-gcc-search.test b/clang/test/Driver/solaris-sparc-gcc-search.test
new file mode 100644
index 00000000000000..4d95e5d7fab3d3
--- /dev/null
+++ b/clang/test/Driver/solaris-sparc-gcc-search.test
@@ -0,0 +1,56 @@
+/// Check that clang can handle both old-style (32) and new-style (sparcv8plus)
+/// 32-bit sparc multilib subdirs.
+
+/// Check sparc-sun-solaris2.11, 32-bit, GCC 4.8 tree
+// RUN: %clang -v 2>&1 --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain=%S/Inputs/solaris_sparc_tree/usr/gcc/4.8 \
+// RUN: | FileCheck --check-prefix=CHECK-SPARC32-GCC48 %s
+// CHECK-SPARC32-GCC48: Selected GCC installation: {{.*}}4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2
+// CHECK-SPARC32-GCC48-NEXT: Candidate multilib: .;@m32
+// CHECK-SPARC32-GCC48-NEXT: Candidate multilib: sparcv9;@m64
+// CHECK-SPARC32-GCC48-NEXT: Selected multilib: .;@m32
+
+/// Check sparc-sun-solaris2.11, 32-bit, GCC 10 tree
+// RUN: %clang -v 2>&1 --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain=%S/Inputs/solaris_sparc32_tree/usr/gcc/10 \
+// RUN: | FileCheck --check-prefix=CHECK-SPARC32-GCC10 %s
+// CHECK-SPARC32-GCC10: Selected GCC installation: {{.*}}10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0
+// CHECK-SPARC32-GCC10-NEXT: Candidate multilib: .;@m64
+// CHECK-SPARC32-GCC10-NEXT: Candidate multilib: 32;@m32
+// CHECK-SPARC32-GCC10-NEXT: Selected multilib: 32;@m32
+
+/// Check sparc-sun-solaris2.11, 32-bit, GCC 11 tree
+// RUN: %clang -v 2>&1 --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain=%S/Inputs/solaris_sparcv8+_tree/usr/gcc/11 \
+// RUN: | FileCheck --check-prefix=CHECK-SPARC32-GCC11 %s
+// CHECK-SPARC32-GCC11: Selected GCC installation: {{.*}}11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0
+// CHECK-SPARC32-GCC11-NEXT: Candidate multilib: .;@m64
+// CHECK-SPARC32-GCC11-NEXT: Candidate multilib: sparcv8plus;@m32
+// CHECK-SPARC32-GCC11-NEXT: Selected multilib: sparcv8plus;@m32
+
+/// Check sparcv9-sun-solaris2.11, 64-bit, GCC 4.8 tree
+// RUN: %clang -v 2>&1 --target=sparcv9-sun-solaris2.11 \
+// RUN: --gcc-toolchain=%S/Inputs/solaris_sparc_tree/usr/gcc/4.8 \
+// RUN: | FileCheck --check-prefix=CHECK-SPARC64-GCC48 %s
+// CHECK-SPARC64-GCC48: Selected GCC installation: {{.*}}gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2
+// CHECK-SPARC64-GCC48-NEXT: Candidate multilib: .;@m32
+// CHECK-SPARC64-GCC48-NEXT: Candidate multilib: sparcv9;@m64
+// CHECK-SPARC64-GCC48-NEXT: Selected multilib: sparcv9;@m64
+
+/// Check sparcv9-sun-solaris2.11, 64-bit, GCC 10 tree
+// RUN: %clang -v 2>&1 --target=sparcv9-sun-solaris2.11 \
+// RUN: --gcc-toolchain=%S/Inputs/solaris_sparc32_tree/usr/gcc/10 \
+// RUN: | FileCheck --check-prefix=CHECK-SPARC64-GCC10 %s
+// CHECK-SPARC64-GCC10: Selected GCC installation: {{.*}}10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0
+// CHECK-SPARC64-GCC10-NEXT: Candidate multilib: .;@m64
+// CHECK-SPARC64-GCC10-NEXT: Candidate multilib: 32;@m32
+// CHECK-SPARC64-GCC10-NEXT: Selected multilib: .;@m64
+
+/// Check sparcv9-sun-solaris2.11, 64-bit, GCC 11 tree
+// RUN: %clang -v 2>&1 --target=sparcv9-sun-solaris2.11 \
+// RUN: --gcc-toolchain=%S/Inputs/solaris_sparcv8+_tree/usr/gcc/11 \
+// RUN: | FileCheck --check-prefix=CHECK-SPARC64-GCC11 %s
+// CHECK-SPARC64-GCC11: Selected GCC installation: {{.*}}11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0
+// CHECK-SPARC64-GCC11-NEXT: Candidate multilib: .;@m64
+// CHECK-SPARC64-GCC11-NEXT: Candidate multilib: sparcv8plus;@m32
+// CHECK-SPARC64-GCC11-NEXT: Selected multilib: .;@m64
More information about the llvm-branch-commits
mailing list