diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2014-01-21 22:49:05 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2014-01-21 22:49:05 +0000 |
| commit | 902efc61be719775ccb15cb95ce6c2e79566dd5e (patch) | |
| tree | 2d664afec4e5d22f5b4f62e5367dd7538b713cee | |
| parent | 50ed9af23d9f26a0538f8496f3400a9b0c9143d8 (diff) | |
| download | bcm5719-llvm-902efc61be719775ccb15cb95ce6c2e79566dd5e.tar.gz bcm5719-llvm-902efc61be719775ccb15cb95ce6c2e79566dd5e.zip | |
Teach Clang to look in its installation libdir for libraries (such as
libc++) when the installation is within the system root.
This doesn't really help cross compiles much, but we don't (currently)
have a great story around libc++, cross compiles, and who is responsible
for building and/or installing the libraries. However, it handles the
very common case of non-cross builds in a way entirely consistent with
GCC, so I'm hopeful this won't really hose anyone.
This is the second patch that I think should be backported to 3.4 to
give folks an easy to checkout and install working Clang+libc++
toolchain.
llvm-svn: 199769
| -rw-r--r-- | clang/lib/Driver/ToolChains.cpp | 20 | ||||
| -rw-r--r-- | clang/test/Driver/linux-ld.c | 26 |
2 files changed, 46 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index b8d9639e9c2..b7cb874e079 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -2695,6 +2695,17 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) addPathIfExists(LibPath + "/../" + Multilib, Paths); } } + + // Similar to the logic for GCC above, if we currently running Clang inside + // of the requested system root, add its parent multilib library paths to + // those searched. + // FIXME: It's not clear whether we should use the driver's installed + // directory ('Dir' below) or the ResourceDir. + if (StringRef(D.Dir).startswith(SysRoot)) { + addPathIfExists(D.Dir + "/../lib/" + MultiarchTriple, Paths); + addPathIfExists(D.Dir + "/../" + Multilib, Paths); + } + addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths); addPathIfExists(SysRoot + "/lib/../" + Multilib, Paths); addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths); @@ -2723,6 +2734,15 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) if (StringRef(LibPath).startswith(SysRoot)) addPathIfExists(LibPath, Paths); } + + // Similar to the logic for GCC above, if we are currently running Clang + // inside of the requested system root, add its parent library path to those + // searched. + // FIXME: It's not clear whether we should use the driver's installed + // directory ('Dir' below) or the ResourceDir. + if (StringRef(D.Dir).startswith(SysRoot)) + addPathIfExists(D.Dir + "/../lib", Paths); + addPathIfExists(SysRoot + "/lib", Paths); addPathIfExists(SysRoot + "/usr/lib", Paths); } diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c index 9e9aa3508d7..52f015f3625 100644 --- a/clang/test/Driver/linux-ld.c +++ b/clang/test/Driver/linux-ld.c @@ -214,6 +214,32 @@ // CHECK-GCC-VERSION4: "{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99{{/|\\\\}}crtbegin.o" // CHECK-GCC-VERSION4: "-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99" // +// Test a simulated installation of libc++ on Linux, both through sysroot and +// the installation path of Clang. +// RUN: %clangxx -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \ +// RUN: -target x86_64-unknown-linux-gnu \ +// RUN: -stdlib=libc++ \ +// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \ +// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \ +// RUN: | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-SYSROOT %s +// CHECK-BASIC-LIBCXX-SYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1" +// CHECK-BASIC-LIBCXX-SYSROOT: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-BASIC-LIBCXX-SYSROOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" +// CHECK-BASIC-LIBCXX-SYSROOT: "-internal-isystem" "[[SYSROOT]]/usr/local/include" +// CHECK-BASIC-LIBCXX-SYSROOT: "--sysroot=[[SYSROOT]]" +// RUN: %clang -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \ +// RUN: -target x86_64-unknown-linux-gnu \ +// RUN: -stdlib=libc++ \ +// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \ +// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \ +// RUN: | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-INSTALL %s +// CHECK-BASIC-LIBCXX-INSTALL: "{{[^"]*}}clang{{[^"]*}}" "-cc1" +// CHECK-BASIC-LIBCXX-INSTALL: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" "[[SYSROOT]]/usr/bin/../include/c++/v1" +// CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" "[[SYSROOT]]/usr/local/include" +// CHECK-BASIC-LIBCXX-INSTALL: "--sysroot=[[SYSROOT]]" +// CHECK-BASIC-LIBCXX-INSTALL: "-L[[SYSROOT]]/usr/bin/../lib" +// // Test a very broken version of multiarch that shipped in Ubuntu 11.04. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=i386-unknown-linux \ |

