diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2190,7 +2190,10 @@ } // Skip other prefixes once a GCC installation is found. - if (Version > VersionZero) + // Solaris GCC installations live in separate Prefixes per Version + // (/usr/gcc/) that arrive in directory order, so check all + // of them to determine the latest. + if (Version > VersionZero && !TargetTriple.isOSSolaris()) break; } } diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/sparcv8plus/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/sparcv8plus/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/32/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/32/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/i386-pc-solaris2.11/4.7.3/amd64/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/i386-pc-solaris2.11/4.7.3/amd64/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/i386-pc-solaris2.11/4.7.3/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/i386-pc-solaris2.11/4.7.3/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3/sparcv9/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3/sparcv9/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0/32/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0/32/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/32/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/32/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/crtbegin.o b/clang/test/Driver/Inputs/solaris_multi_gcc_tree/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/solaris-multi-gcc-search.test b/clang/test/Driver/solaris-multi-gcc-search.test new file mode 100644 --- /dev/null +++ b/clang/test/Driver/solaris-multi-gcc-search.test @@ -0,0 +1,60 @@ +/// Check that clang uses the latest available Solaris GCC installation. + +/// Check sparc-sun-solaris2.11, 32-bit +// RUN: %clang -v 2>&1 --target=sparc-sun-solaris2.11 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/solaris_multi_gcc_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SPARC %s +// CHECK-SPARC-DAG: Found candidate GCC installation: {{.*}}4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3 +// CHECK-SPARC-DAG: Found candidate GCC installation: {{.*}}7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0 +// CHECK-SPARC-DAG: Found candidate GCC installation: {{.*}}11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0 +// CHECK-SPARC: Selected GCC installation: {{.*}}11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0 +// CHECK-SPARC-NEXT: Candidate multilib: .;@m64 +// CHECK-SPARC-NEXT: Candidate multilib: sparcv8plus;@m32 +// CHECK-SPARC-NEXT: Selected multilib: sparcv8plus;@m32 + +/// Check i386-pc-solaris2.11, 32-bit +// RUN: %clang -v 2>&1 --target=i386-pc-solaris2.11 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/solaris_multi_gcc_tree \ +// RUN: | FileCheck --check-prefix=CHECK-I386 %s +// CHECK-I386-DAG: Found candidate GCC installation: {{.*}}4.7/lib/gcc/i386-pc-solaris2.11/4.7.3 +// CHECK-I386-DAG: Found candidate GCC installation: {{.*}}7/lib/gcc/x86_64-pc-solaris2.11/7.5.0 +// CHECK-I386-DAG: Found candidate GCC installation: {{.*}}11/lib/gcc/x86_64-pc-solaris2.11/11.4.0 +// CHECK-I386: Selected GCC installation: {{.*}}11/lib/gcc/x86_64-pc-solaris2.11/11.4.0 +// CHECK-I386-NEXT: Candidate multilib: .;@m64 +// CHECK-I386-NEXT: Candidate multilib: 32;@m32 +// CHECK-I386-NEXT: Selected multilib: 32;@m32 + +/// Check sparcv9-sun-solaris2.11, 64-bit +// RUN: %clang -v 2>&1 --target=sparcv9-sun-solaris2.11 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/solaris_multi_gcc_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SPARCV9 %s +// CHECK-SPARCV9-DAG: Found candidate GCC installation: {{.*}}4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3 +// CHECK-SPARCV9-DAG: Found candidate GCC installation: {{.*}}7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0 +// CHECK-SPARCV9-DAG: Found candidate GCC installation: {{.*}}11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0 +// CHECK-SPARCV9: Selected GCC installation: {{.*}}11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0 +// CHECK-SPARCV9-NEXT: Candidate multilib: .;@m64 +// CHECK-SPARCV9-NEXT: Candidate multilib: sparcv8plus;@m32 +// CHECK-SPARCV9-NEXT: Selected multilib: .;@m64 + +/// Check x86_64-pc-solaris2.11, 64-bit +// RUN: %clang -v 2>&1 --target=x86_64-pc-solaris2.11 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/solaris_multi_gcc_tree \ +// RUN: | FileCheck --check-prefix=CHECK-X86_64 %s + +/// Check amd64-pc-solaris2.11, 64-bit +// RUN: %clang -v 2>&1 --target=amd64-pc-solaris2.11 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/solaris_multi_gcc_tree \ +// RUN: | FileCheck --check-prefix=CHECK-X86_64 %s +// CHECK-X86_64-DAG: Found candidate GCC installation: {{.*}}4.7/lib/gcc/i386-pc-solaris2.11/4.7.3 +// CHECK-X86_64-DAG: Found candidate GCC installation: {{.*}}7/lib/gcc/x86_64-pc-solaris2.11/7.5.0 + +// CHECK-X86_64-DAG: Found candidate GCC installation: {{.*}}11/lib/gcc/x86_64-pc-solaris2.11/11.4.0 +// CHECK-X86_64: Selected GCC installation: {{.*}}11/lib/gcc/x86_64-pc-solaris2.11/11.4.0 +// CHECK-X86_64-NEXT: Candidate multilib: .;@m64 +// CHECK-X86_64-NEXT: Candidate multilib: 32;@m32 +// CHECK-X86_64-NEXT: Selected multilib: .;@m64