diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2017-03-03 23:20:49 +0000 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2017-03-03 23:20:49 +0000 |
commit | 65a16dd85811f385f36c8d94bb960d88dce9a6c9 (patch) | |
tree | 1599cc157a227db452483a8f3093eb1cdd9cb943 /clang/lib/Driver/ToolChain.cpp | |
parent | 1c9d800fbc4e6552f30bf7ad807a02126f4cf8f0 (diff) | |
download | bcm5719-llvm-65a16dd85811f385f36c8d94bb960d88dce9a6c9.tar.gz bcm5719-llvm-65a16dd85811f385f36c8d94bb960d88dce9a6c9.zip |
Add arch-specific directory to search path
Summary:
This change adds an arch-specific subdirectory in <ResourceDir>/lib/<OS>
to the linker search path. This path also gets added as '-rpath' for
native compilation if a runtime is linked in as a shared object. This
allows arch-specific libraries to be installed alongside clang.
Reviewers: danalbert, cbergstrom, javed.absar
Subscribers: srhines
Differential Revision: https://reviews.llvm.org/D30015
llvm-svn: 296927
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 6adc0386ee7..5a2ed0bd69b 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -10,6 +10,7 @@ #include "clang/Driver/ToolChain.h" #include "Tools.h" #include "clang/Basic/ObjCRuntime.h" +#include "clang/Basic/VirtualFileSystem.h" #include "clang/Config/config.h" #include "clang/Driver/Action.h" #include "clang/Driver/Driver.h" @@ -74,6 +75,10 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, if (!isThreadModelSupported(A->getValue())) D.Diag(diag::err_drv_invalid_thread_model_for_target) << A->getValue() << A->getAsString(Args); + + std::string CandidateLibPath = getArchSpecificLibPath(); + if (getVFS().exists(CandidateLibPath)) + getFilePaths().push_back(CandidateLibPath); } ToolChain::~ToolChain() { @@ -320,6 +325,14 @@ const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args, return Args.MakeArgString(getCompilerRT(Args, Component, Shared)); } +std::string ToolChain::getArchSpecificLibPath() const { + SmallString<128> Path(getDriver().ResourceDir); + StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS(); + llvm::sys::path::append(Path, "lib", OSLibName, + llvm::Triple::getArchTypeName(getArch())); + return Path.str(); +} + bool ToolChain::needsProfileRT(const ArgList &Args) { if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs, false) || |