]> granicus.if.org Git - clang/commitdiff
[runtimes] Move libunwind, libc++abi and libc++ to lib/$target/c++ and include/c++
authorPetr Hosek <phosek@chromium.org>
Wed, 22 May 2019 21:08:33 +0000 (21:08 +0000)
committerPetr Hosek <phosek@chromium.org>
Wed, 22 May 2019 21:08:33 +0000 (21:08 +0000)
This change is a consequence of the discussion in "RFC: Place libs in
Clang-dedicated directories", specifically the suggestion that
libunwind, libc++abi and libc++ shouldn't be using Clang resource
directory. Tools like clangd make this assumption, but this is
currently not true for the LLVM_ENABLE_PER_TARGET_RUNTIME_DIR build.
This change addresses that by moving the output of these libraries to
lib/$target/c++ and include/c++ directories, leaving resource directory
only for compiler-rt runtimes and Clang builtin headers.

Differential Revision: https://reviews.llvm.org/D59168

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361432 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChain.cpp
lib/Driver/ToolChains/Fuchsia.cpp
lib/Driver/ToolChains/Linux.cpp
test/Driver/Inputs/basic_linux_libcxx_tree/usr/lib/x86_64-linux-gnu/c++/.keep [moved from test/Driver/Inputs/basic_linux_libcxx_tree/usr/lib/x86_64-linux-gnu/.keep with 100% similarity]
test/Driver/linux-per-target-runtime-dir.c

index dbb347c8bc8be227c9d8d282bdb67f9986c2f281..3b0e8f2dbaa85816624868dc1f7ac0b4d28f282a 100644 (file)
@@ -75,6 +75,13 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
       CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
   SmallString<128> P;
 
+  if (D.CCCIsCXX()) {
+    P.assign(D.Dir);
+    llvm::sys::path::append(P, "..", "lib", D.getTargetTriple(), "c++");
+    if (getVFS().exists(P))
+      getLibraryPaths().push_back(P.str());
+  }
+
   P.assign(D.ResourceDir);
   llvm::sys::path::append(P, D.getTargetTriple(), "lib");
   if (getVFS().exists(P))
index c906379f19b476f9cd4a7768b669e14e6cbb7457..3249d4f1f7f6e23c88cbe2c6c74eb1d140890040 100644 (file)
@@ -305,8 +305,8 @@ void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
 
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
-    SmallString<128> P(getDriver().ResourceDir);
-    llvm::sys::path::append(P, "include", "c++", "v1");
+    SmallString<128> P(getDriver().Dir);
+    llvm::sys::path::append(P, "..", "include", "c++", "v1");
     addSystemInclude(DriverArgs, CC1Args, P.str());
     break;
   }
index 4890ef457531542c7bee7b5b6cb54e3eba98b07b..7168b7f1192afb22a6e78eeb62d47aad28cab13f 100644 (file)
@@ -889,7 +889,6 @@ void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
                                   llvm::opt::ArgStringList &CC1Args) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-      DetectLibcxxIncludePath(getDriver().ResourceDir + "/include/c++"),
       DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
       // If this is a development, non-installed, clang, libcxx will
       // not be found at ../include/c++ but it likely to be found at
index bbd11570f5223350b6a5b82c04a45cc2eac719d7..3d52342c394ec1f2059ca3b0ca0ef3641881000c 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \
+// RUN: %clangxx -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \
 // RUN:     --target=x86_64-linux-gnu \
 // RUN:     -stdlib=libc++ \
 // RUN:     -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
@@ -9,9 +9,10 @@
 // CHECK-PER-TARGET-RUNTIME: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-PER-TARGET-RUNTIME: "-resource-dir" "[[RESDIR:[^"]*]]"
 // CHECK-PER-TARGET-RUNTIME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-PER-TARGET-RUNTIME: "-internal-isystem" "[[RESDIR]]/include/c++/v1"
+// CHECK-PER-TARGET-RUNTIME: "-internal-isystem" "{{.*}}/../include/c++/v1"
 // CHECK-PER-TARGET-RUNTIME: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-PER-TARGET-RUNTIME: "--sysroot=[[SYSROOT]]"
+// CHECK-PER-TARGET-RUNTIME: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-linux-gnu{{/|\\\\}}c++"
 // CHECK-PER-TARGET-RUNTIME: "-L[[RESDIR]]{{/|\\\\}}x86_64-linux-gnu{{/|\\\\}}lib"
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \