diff options
author | Yaxun (Sam) Liu <yaxun.liu@amd.com> | 2023-04-05 19:38:37 -0400 |
---|---|---|
committer | Yaxun (Sam) Liu <yaxun.liu@amd.com> | 2023-04-05 20:14:53 -0400 |
commit | 5f91c747763c20a63f3d6156fced03b474f842a1 (patch) | |
tree | 6c06ee845c2adbb9f7b5440cf3c382d0b294a691 /clang/lib/Driver/ToolChain.cpp | |
parent | f79c037b63278bc5b4481a1a55c68e42f0ea1461 (diff) | |
download | llvm-5f91c747763c20a63f3d6156fced03b474f842a1.zip llvm-5f91c747763c20a63f3d6156fced03b474f842a1.tar.gz llvm-5f91c747763c20a63f3d6156fced03b474f842a1.tar.bz2 |
[Driver] Fix rpath for compiler-rt
The compiler-rt library path can be either {resource_dir}/lib/{triple}
or {resource_dir}/lib/{OS}/{arch} depending on whether
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default is ON or OFF.
Currently, the rpath added by -rtlib-add-rpath only adds
the latter. This patch checks both and adds the one that exists.
Reviewed by: Fangrui Song
Differential Revision: https://reviews.llvm.org/D146686
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 2dba975a..27b66aa 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -86,7 +86,8 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, addIfExists(getLibraryPaths(), Path); for (const auto &Path : getStdlibPaths()) addIfExists(getFilePaths(), Path); - addIfExists(getFilePaths(), getArchSpecificLibPath()); + for (const auto &Path : getArchSpecificLibPaths()) + addIfExists(getFilePaths(), Path); } llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> @@ -621,11 +622,20 @@ ToolChain::path_list ToolChain::getStdlibPaths() const { return Paths; } -std::string ToolChain::getArchSpecificLibPath() const { - SmallString<128> Path(getDriver().ResourceDir); - llvm::sys::path::append(Path, "lib", getOSLibName(), - llvm::Triple::getArchTypeName(getArch())); - return std::string(Path.str()); +ToolChain::path_list ToolChain::getArchSpecificLibPaths() const { + path_list Paths; + + auto AddPath = [&](const ArrayRef<StringRef> &SS) { + SmallString<128> Path(getDriver().ResourceDir); + llvm::sys::path::append(Path, "lib"); + for (auto &S : SS) + llvm::sys::path::append(Path, S); + Paths.push_back(std::string(Path.str())); + }; + + AddPath({getTriple().str()}); + AddPath({getOSLibName(), llvm::Triple::getArchTypeName(getArch())}); + return Paths; } bool ToolChain::needsProfileRT(const ArgList &Args) { |