summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-06-28 03:11:52 +0000
committerPetr Hosek <phosek@chromium.org>2018-06-28 03:11:52 +0000
commit887f26d4703616934fd7a11b6649f605e1c7b4e3 (patch)
tree6cdd1b4f61afe4300fcd4fd8aa41e6b1e8cfcdc6 /clang/lib/Driver
parent4ba041fa25b7e34bd10c598b53b04f023681b322 (diff)
downloadbcm5719-llvm-887f26d4703616934fd7a11b6649f605e1c7b4e3.tar.gz
bcm5719-llvm-887f26d4703616934fd7a11b6649f605e1c7b4e3.zip
Support for multiarch runtimes layout
This change adds a support for multiarch style runtimes layout, so in addition to the existing layout where runtimes get installed to: lib/clang/$version/lib/$os Clang now allows runtimes to be installed to: lib/clang/$version/$target/lib This also includes libc++, libc++abi and libunwind; today those are assumed to be in Clang library directory built for host, with the new layout it is possible to install libc++, libc++abi and libunwind into the runtime directory built for different targets. The use of new layout is enabled by setting the LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both projects and runtimes layouts. The runtimes CMake build has been further modified to use the new layout when building runtimes for multiple targets. Differential Revision: https://reviews.llvm.org/D45604 llvm-svn: 335809
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r--clang/lib/Driver/ToolChain.cpp17
-rw-r--r--clang/lib/Driver/ToolChains/Fuchsia.cpp24
-rw-r--r--clang/lib/Driver/ToolChains/Linux.cpp1
3 files changed, 18 insertions, 24 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index a56a0380541..d62ba125334 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -74,6 +74,11 @@ 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);
+ llvm::sys::path::append(P, D.getTargetTriple(), "lib");
+ if (getVFS().exists(P))
+ getFilePaths().push_back(P.str());
+
std::string CandidateLibPath = getArchSpecificLibPath();
if (getVFS().exists(CandidateLibPath))
getFilePaths().push_back(CandidateLibPath);
@@ -350,15 +355,23 @@ std::string ToolChain::getCompilerRTPath() const {
std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
bool Shared) const {
const llvm::Triple &TT = getTriple();
- const char *Env = TT.isAndroid() ? "-android" : "";
bool IsITANMSVCWindows =
TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
- StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
const char *Prefix = IsITANMSVCWindows ? "" : "lib";
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)) {
+ llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix);
+ return P.str();
+ }
+
+ StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
+ const char *Env = TT.isAndroid() ? "-android" : "";
SmallString<128> Path(getCompilerRTPath());
llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
Arch + Env + Suffix);
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index bea59b1ac30..459b68b55a3 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -144,21 +144,6 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
/// Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly.
-static std::string normalizeTriple(llvm::Triple Triple) {
- SmallString<64> T;
- T += Triple.getArchName();
- T += "-";
- T += Triple.getOSName();
- return T.str();
-}
-
-static std::string getTargetDir(const Driver &D,
- llvm::Triple Triple) {
- SmallString<128> P(llvm::sys::path::parent_path(D.Dir));
- llvm::sys::path::append(P, "lib", normalizeTriple(Triple));
- return P.str();
-}
-
Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: ToolChain(D, Triple, Args) {
@@ -166,10 +151,6 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
if (getDriver().getInstalledDir() != D.Dir)
getProgramPaths().push_back(D.Dir);
- SmallString<128> P(getTargetDir(D, getTriple()));
- llvm::sys::path::append(P, "lib");
- getFilePaths().push_back(P.str());
-
if (!D.SysRoot.empty()) {
SmallString<128> P(D.SysRoot);
llvm::sys::path::append(P, "lib");
@@ -180,8 +161,7 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
std::string Fuchsia::ComputeEffectiveClangTriple(const ArgList &Args,
types::ID InputType) const {
llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
- Triple.setTriple(normalizeTriple(Triple));
- return Triple.getTriple();
+ return (Triple.getArchName() + "-" + Triple.getOSName()).str();
}
Tool *Fuchsia::buildLinker() const {
@@ -264,7 +244,7 @@ void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
switch (GetCXXStdlibType(DriverArgs)) {
case ToolChain::CST_Libcxx: {
- SmallString<128> P(getTargetDir(getDriver(), getTriple()));
+ SmallString<128> P(getDriver().ResourceDir);
llvm::sys::path::append(P, "include", "c++", "v1");
addSystemInclude(DriverArgs, CC1Args, P.str());
break;
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 675d7b20292..3b99ce581fa 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -803,6 +803,7 @@ void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
const std::string& SysRoot = computeSysRoot();
const std::string LibCXXIncludePathCandidates[] = {
+ DetectLibcxxIncludePath(getDriver().ResourceDir + "/include/c++"),
DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
// If this is a development, non-installed, clang, libcxx will
// not be found at ../include/c++ but it likely to be found at
OpenPOWER on IntegriCloud