diff options
| author | Petr Hosek <phosek@chromium.org> | 2018-08-22 22:56:46 +0000 |
|---|---|---|
| committer | Petr Hosek <phosek@chromium.org> | 2018-08-22 22:56:46 +0000 |
| commit | 678c1c6cccf4ca16df1a9986a2ec5e05040880c4 (patch) | |
| tree | f2425c0ca430aedf44b9e6cebd298675588c39dc /clang | |
| parent | e2efbbe571aea9f0302c297ba3c3fe0d375468f2 (diff) | |
| download | bcm5719-llvm-678c1c6cccf4ca16df1a9986a2ec5e05040880c4.tar.gz bcm5719-llvm-678c1c6cccf4ca16df1a9986a2ec5e05040880c4.zip | |
[Driver] Check normalized triples for multiarch runtime path
Previously we only used target triple as provided which matches the
GCC behavior, but it also means that all clients have to be consistent
in their spelling of target triples since e.g. x86_64-linux-gnu and
x86_64-unknown-linux-gnu will result in Clang driver looking at two
different paths when searching for runtime libraries.
Unfortunatelly, as it turned out many clients aren't consistent in
their spelling of target triples, e.g. many Linux distributions use
the shorter spelling but config.guess and rustc insist on using the
normalized variant which is causing issues. To avoid having to ship
multiple copies of runtimes for different triple spelling or rely on
symlinks which are not portable, we should also check the normalized
triple when constructing paths for multiarch runtimes.
Differential Revision: https://reviews.llvm.org/D50547
llvm-svn: 340471
Diffstat (limited to 'clang')
14 files changed, 23 insertions, 7 deletions
diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 2f9c2c190e3..1395134f40f 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -116,6 +116,9 @@ private: const RTTIMode CachedRTTIMode; + /// The list of toolchain specific path prefixes to search for libraries. + path_list LibraryPaths; + /// The list of toolchain specific path prefixes to search for files. path_list FilePaths; @@ -213,6 +216,9 @@ public: return EffectiveTriple; } + path_list &getLibraryPaths() { return LibraryPaths; } + const path_list &getLibraryPaths() const { return LibraryPaths; } + path_list &getFilePaths() { return FilePaths; } const path_list &getFilePaths() const { return FilePaths; } diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index cf3db34688d..d5004df593b 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -74,10 +74,17 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, const ArgList &Args) : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)), CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) { - SmallString<128> P(D.ResourceDir); + SmallString<128> P; + + P.assign(D.ResourceDir); llvm::sys::path::append(P, D.getTargetTriple(), "lib"); if (getVFS().exists(P)) - getFilePaths().push_back(P.str()); + getLibraryPaths().push_back(P.str()); + + P.assign(D.ResourceDir); + llvm::sys::path::append(P, Triple.str(), "lib"); + if (getVFS().exists(P)) + getLibraryPaths().push_back(P.str()); std::string CandidateLibPath = getArchSpecificLibPath(); if (getVFS().exists(CandidateLibPath)) @@ -362,12 +369,11 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component, const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so") : (IsITANMSVCWindows ? ".lib" : ".a"); - const Driver &D = getDriver(); - SmallString<128> P(D.ResourceDir); - llvm::sys::path::append(P, D.getTargetTriple(), "lib"); - if (getVFS().exists(P)) { + for (const auto &LibPath : getLibraryPaths()) { + SmallString<128> P(LibPath); llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix); - return P.str(); + if (getVFS().exists(P)) + return P.str(); } StringRef Arch = getArchNameForCompilerRTLib(*this, Args); @@ -762,6 +768,10 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, void ToolChain::AddFilePathLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const { + for (const auto &LibPath : getLibraryPaths()) + if(LibPath.length() > 0) + CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath)); + for (const auto &LibPath : getFilePaths()) if(LibPath.length() > 0) CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath)); diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan-preinit.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan-preinit.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan-preinit.a diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan.so b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan.so new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan.so diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.builtins.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.builtins.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.builtins.a diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.fuzzer.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.fuzzer.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.fuzzer.a diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.scudo.so b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.scudo.so new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.scudo.so diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/i386-linux-gnu/lib/libclang_rt.builtins.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/i386-linux-gnu/lib/libclang_rt.builtins.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/i386-linux-gnu/lib/libclang_rt.builtins.a diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan-preinit.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan-preinit.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan-preinit.a diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan.so b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan.so new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan.so diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.builtins.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.builtins.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.builtins.a diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.fuzzer.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.fuzzer.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.fuzzer.a diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.scudo.so b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.scudo.so new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.scudo.so diff --git a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-linux-gnu/lib/libclang_rt.builtins.a b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-linux-gnu/lib/libclang_rt.builtins.a new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-linux-gnu/lib/libclang_rt.builtins.a |

