Skip to content

Commit f749550

Browse files
committed
[libcxx] Stop using use c++ subdirectory for libc++ library
The new layout more closely matches the layout used by other compilers. This is only used when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is enabled. Differential Revision: https://reviews.llvm.org/D100869
1 parent 7735720 commit f749550

File tree

31 files changed

+30
-34
lines changed

31 files changed

+30
-34
lines changed

clang/include/clang/Driver/ToolChain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ class ToolChain {
444444
// Returns target specific runtime path if it exists.
445445
virtual Optional<std::string> getRuntimePath() const;
446446

447-
// Returns target specific C++ library path if it exists.
448-
virtual Optional<std::string> getCXXStdlibPath() const;
447+
// Returns target specific standard library path if it exists.
448+
virtual Optional<std::string> getStdlibPath() const;
449449

450450
// Returns <ResourceDir>/lib/<OSName>/<arch>. This is used by runtimes (such
451451
// as OpenMP) to find arch-specific libraries.

clang/lib/Driver/ToolChain.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
7575
const ArgList &Args)
7676
: D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
7777
CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
78-
if (D.CCCIsCXX()) {
79-
if (auto CXXStdlibPath = getCXXStdlibPath())
80-
getFilePaths().push_back(*CXXStdlibPath);
81-
}
78+
if (auto StdlibPath = getStdlibPath())
79+
getFilePaths().push_back(*StdlibPath);
8280

8381
if (auto RuntimePath = getRuntimePath())
8482
getLibraryPaths().push_back(*RuntimePath);
@@ -500,18 +498,18 @@ Optional<std::string> ToolChain::getRuntimePath() const {
500498
return None;
501499
}
502500

503-
Optional<std::string> ToolChain::getCXXStdlibPath() const {
501+
Optional<std::string> ToolChain::getStdlibPath() const {
504502
SmallString<128> P;
505503

506504
// First try the triple passed to driver as --target=<triple>.
507505
P.assign(D.Dir);
508-
llvm::sys::path::append(P, "..", "lib", D.getTargetTriple(), "c++");
506+
llvm::sys::path::append(P, "..", "lib", D.getTargetTriple());
509507
if (getVFS().exists(P))
510508
return llvm::Optional<std::string>(std::string(P.str()));
511509

512510
// Second try the normalized triple.
513511
P.assign(D.Dir);
514-
llvm::sys::path::append(P, "..", "lib", Triple.str(), "c++");
512+
llvm::sys::path::append(P, "..", "lib", Triple.str());
515513
if (getVFS().exists(P))
516514
return llvm::Optional<std::string>(std::string(P.str()));
517515

clang/lib/Driver/ToolChains/Fuchsia.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,10 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
189189

190190
auto FilePaths = [&](const Multilib &M) -> std::vector<std::string> {
191191
std::vector<std::string> FP;
192-
if (D.CCCIsCXX()) {
193-
if (auto CXXStdlibPath = getCXXStdlibPath()) {
194-
SmallString<128> P(*CXXStdlibPath);
195-
llvm::sys::path::append(P, M.gccSuffix());
196-
FP.push_back(std::string(P.str()));
197-
}
192+
if (auto StdlibPath = getStdlibPath()) {
193+
SmallString<128> P(*StdlibPath);
194+
llvm::sys::path::append(P, M.gccSuffix());
195+
FP.push_back(std::string(P.str()));
198196
}
199197
return FP;
200198
};

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-fuchsia/asan/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-fuchsia/noexcept/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-fuchsia/asan/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-fuchsia/noexcept/.keep

Whitespace-only changes.

clang/test/Driver/fuchsia.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@
142142
// RUN: -fuse-ld=lld 2>&1\
143143
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86
144144
// CHECK-MULTILIB-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
145-
// CHECK-MULTILIB-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}asan"
146-
// CHECK-MULTILIB-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}noexcept"
147-
// CHECK-MULTILIB-ASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}asan+noexcept"
148-
// CHECK-MULTILIB-RELATIVE-VTABLES-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables"
149-
// CHECK-MULTILIB-RELATIVE-VTABLES-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+noexcept"
150-
// CHECK-MULTILIB-RELATIVE-VTABLES-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+asan"
151-
// CHECK-MULTILIB-RELATIVE-VTABLES-ASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+asan+noexcept"
152-
// CHECK-MULTILIB-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}hwasan"
153-
// CHECK-MULTILIB-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}hwasan+noexcept"
154-
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+hwasan"
155-
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+hwasan+noexcept"
156-
// CHECK-MULTILIB-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++"
145+
// CHECK-MULTILIB-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}asan"
146+
// CHECK-MULTILIB-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}noexcept"
147+
// CHECK-MULTILIB-ASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}asan+noexcept"
148+
// CHECK-MULTILIB-RELATIVE-VTABLES-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}relative-vtables"
149+
// CHECK-MULTILIB-RELATIVE-VTABLES-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}relative-vtables+noexcept"
150+
// CHECK-MULTILIB-RELATIVE-VTABLES-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}relative-vtables+asan"
151+
// CHECK-MULTILIB-RELATIVE-VTABLES-ASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}relative-vtables+asan+noexcept"
152+
// CHECK-MULTILIB-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}hwasan"
153+
// CHECK-MULTILIB-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}hwasan+noexcept"
154+
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}relative-vtables+hwasan"
155+
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}relative-vtables+hwasan+noexcept"
156+
// CHECK-MULTILIB-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia"

clang/test/Driver/linux-per-target-runtime-dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// CHECK-PER-TARGET-RUNTIME: "-internal-isystem" "{{.*}}/../include/c++/v1"
1313
// CHECK-PER-TARGET-RUNTIME: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
1414
// CHECK-PER-TARGET-RUNTIME: "--sysroot=[[SYSROOT]]"
15-
// CHECK-PER-TARGET-RUNTIME: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-linux-gnu{{/|\\\\}}c++"
15+
// CHECK-PER-TARGET-RUNTIME: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-linux-gnu"
1616

1717
// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
1818
// RUN: --target=x86_64-linux-gnu \

libcxx/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ endif ()
406406
# TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR
407407
# instead of hard-coding include/c++/v1.
408408
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
409-
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
409+
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
410410
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
411-
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
411+
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
412412
if(LIBCXX_LIBDIR_SUBDIR)
413413
string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
414414
string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})

libcxxabi/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ set(CMAKE_MODULE_PATH
195195

196196
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
197197
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
198-
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
199-
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
198+
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
199+
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
200200
if(LIBCXX_LIBDIR_SUBDIR)
201201
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
202202
string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})

libunwind/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ set(CMAKE_MODULE_PATH
115115
${CMAKE_MODULE_PATH})
116116

117117
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
118-
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
119-
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
118+
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
119+
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
120120
if(LIBCXX_LIBDIR_SUBDIR)
121121
string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
122122
string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})

0 commit comments

Comments
 (0)