From: Chandler Carruth Date: Wed, 5 Oct 2011 01:01:57 +0000 (+0000) Subject: Implement the feature I was originally driving toward when I started X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5058e3a18c5f305d7ff21ba1e9e1439701d40e0b;p=clang Implement the feature I was originally driving toward when I started this saga. Teach the driver to detect a GCC installed along side Clang using the existing InstalledDir support in the Clang driver. This makes a lot of Clang's behavior more automatic when it is installed along side GCC. Also include the first test cases (more to come, honest) which test both the install directory behavior, and the version sorting behavior to show that we're actually searching for the best candidate GCC installation now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141145 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 493dc97ddc..33b1916d6a 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1587,6 +1587,7 @@ public: D.PrefixDirs.end()); Prefixes.push_back(D.SysRoot); Prefixes.push_back(D.SysRoot + "/usr"); + Prefixes.push_back(D.InstalledDir); // Loop over the various components which exist and select the best GCC // installation available. GCC installs are ranked by version number. diff --git a/test/Driver/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o b/test/Driver/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/fake_install_tree/lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o b/test/Driver/Inputs/fake_install_tree/lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index a7319fbb18..cd89c79809 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -90,3 +90,23 @@ // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." // CHECK-64-TO-32: "-L[[SYSROOT]]/lib" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -ccc-host-triple i386-unknown-linux -m32 \ +// RUN: -ccc-install-dir %S/Inputs/fake_install_tree \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-32 %s +// CHECK-INSTALL-DIR-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o" +// CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0" +// +// Check that with 64-bit builds, we don't actually use the install directory +// as its version of GCC is lower than our sysrooted version. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -ccc-host-triple x86_64-unknown-linux -m64 \ +// RUN: -ccc-install-dir %S/Inputs/fake_install_tree \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-64 %s +// CHECK-INSTALL-DIR-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-INSTALL-DIR-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" +// CHECK-INSTALL-DIR-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"