diff options
author | Fangrui Song <i@maskray.me> | 2024-04-08 16:51:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 16:51:34 -0700 |
commit | ccdebbae4d77d3efc236af92c22941de5d437e01 (patch) | |
tree | dfeb68ea57a76ba4ce54abea6e16b9a5e5429039 /clang/lib/Driver/ToolChain.cpp | |
parent | f28c8339c12917b11c99432de6609e7d46e17e2b (diff) | |
download | llvm-ccdebbae4d77d3efc236af92c22941de5d437e01.zip llvm-ccdebbae4d77d3efc236af92c22941de5d437e01.tar.gz llvm-ccdebbae4d77d3efc236af92c22941de5d437e01.tar.bz2 |
[Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin
Follow-up to #81037.
ToolChain::LibraryPaths holds the new compiler-rt library directory
(e.g. `/tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu`). However,
it might be empty when the directory does not exist (due to the `if
(getVFS().exists(P))` change in https://reviews.llvm.org/D158475).
If neither the old/new compiler-rt library directories exists, we would
suggest the undesired old compiler-rt file name:
```
% /tmp/Debug/bin/clang++ a.cc -fsanitize=memory -o a
ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/linux/libclang_rt.msan-x86_64.a: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```
With this change, we will correctly suggest the new compiler-rt file name.
Fix #87150
Pull Request: https://github.com/llvm/llvm-project/pull/87866
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 03450fc..237092e 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -796,7 +796,13 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const { std::optional<std::string> ToolChain::getRuntimePath() const { SmallString<128> P(D.ResourceDir); llvm::sys::path::append(P, "lib"); - return getTargetSubDirPath(P); + if (auto Ret = getTargetSubDirPath(P)) + return Ret; + // Darwin does not use per-target runtime directory. + if (Triple.isOSDarwin()) + return {}; + llvm::sys::path::append(P, Triple.str()); + return std::string(P); } std::optional<std::string> ToolChain::getStdlibPath() const { |