Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6396,6 +6396,11 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
if (auto P = SearchPaths(TC.getFilePaths()))
return *P;

SmallString<128> R2(ResourceDir);
llvm::sys::path::append(R2, "..", "..", Name);
if (llvm::sys::fs::exists(Twine(R2)))
return std::string(R2);

return std::string(Name);
}

Expand Down
26 changes: 26 additions & 0 deletions clang/test/Driver/modules-print-library-module-manifest-path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@
// RUN: --target=x86_64-linux-gnu 2>&1 \
// RUN: | FileCheck libcxx.cpp

// for macos there is a different directory structure
// where the library and libc++.modules.json file are in lib
// directly but headers are in clang/ver directory which
// is the resource directory
// RUN: mkdir -p %t/Inputs/usr/lib/clang/20
// RUN: touch %t/Inputs/usr/lib/libc++.so
// RUN: touch %t/Inputs/usr/lib/libc++.modules.json
// RUN: %clang -print-library-module-manifest-path \
// RUN: -stdlib=libc++ \
// RUN: -resource-dir=%t/Inputs/usr/lib/clang/20 \
// RUN: --target=arm64-apple-darwin24.1.0 2>&1 \
// RUN: | FileCheck libcxx.cpp.macos

// RUN: rm %t/Inputs/usr/lib/libc++.so
// RUN: touch %t/Inputs/usr/lib/libc++.a
// RUN: touch %t/Inputs/usr/lib/libc++.modules.json
// RUN: %clang -print-library-module-manifest-path \
// RUN: -stdlib=libc++ \
// RUN: -resource-dir=%t/Inputs/usr/lib/clang/20 \
// RUN: --target=arm64-apple-darwin24.1.0 2>&1 \
// RUN: | FileCheck libcxx.cpp.macos

// RUN: rm %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.so
// RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.a
// RUN: %clang -print-library-module-manifest-path \
Expand All @@ -40,6 +62,10 @@

// CHECK: {{.*}}/Inputs/usr/lib/x86_64-linux-gnu{{/|\\}}libc++.modules.json

//--- libcxx.cpp.macos

// CHECK: {{.*}}libc++.modules.json

//--- libcxx-no-shared-lib.cpp

// Note this might find a different path depending whether search path
Expand Down
Loading