aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/ToolChains.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-10-03 08:02:58 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-10-03 08:02:58 +0000
commit663abc976af682b9426918b3c534d132a2b09a64 (patch)
tree09ab04f8efa647653e66a25322422d9b7e2adf17 /lib/Driver/ToolChains.cpp
parentfde8d14ea3061ff82e9dfddb23f17648c103eae6 (diff)
Teach the logic for locating an installed GCC about the system root.
This requires fixing a latent bug -- if we used the default host triple instead of an autodetected triple to locate GCC's installation, we didn't go back and fix the GCC triple. Correct that with a pile of hacks. This entire routine needs a major refactoring which I'm saving for a subsequent commit. Essentially, the detection of the GCC triple should be hoisted into the same routine as we locate the GCC installation: the first is intrinsically tied to the latter. Then the routine will just return the triple and base directory. Also start to bring the rest of the library search path logic under test, including locating crtbegin.o. Still need to test the multilib and other behaviors, but there are also bugs in the way of that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140995 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains.cpp')
-rw-r--r--lib/Driver/ToolChains.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index dd35172402..c6adbc04a8 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1483,8 +1483,12 @@ static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) {
return UnknownDistro;
}
-static std::string findGCCBaseLibDir(const Driver &D,
- const std::string &GccTriple) {
+/// \brief Find an installed GCC lib base directory.
+///
+/// Tries both the auto-detected GccTriple passed in as well as the
+/// Driver-specified default host triple. Sets the GccTriple to the triple
+/// actually used.
+static std::string findGCCBaseLibDir(const Driver &D, std::string &GccTriple) {
// FIXME: Using CXX_INCLUDE_ROOT is here is a bit of a hack, but
// avoids adding yet another option to configure/cmake.
// It would probably be cleaner to break it in two variables
@@ -1519,13 +1523,14 @@ static std::string findGCCBaseLibDir(const Driver &D,
bool Exists;
llvm::SmallVector<std::string, 8> Paths(D.PrefixDirs.begin(),
D.PrefixDirs.end());
- Paths.push_back("/usr/");
- const std::string *Triples[] = {&GccTriple, &D.DefaultHostTriple};
+ Paths.push_back(D.SysRoot + "/usr/");
+ const std::string Triples[] = {GccTriple, D.DefaultHostTriple};
for (llvm::SmallVector<std::string, 8>::const_iterator it = Paths.begin(),
ie = Paths.end(); it != ie; ++it) {
for (unsigned i = 0; i < sizeof(GccVersions)/sizeof(char*); ++i) {
for (unsigned j = 0; j < sizeof(Triples)/sizeof(Triples[0]); ++j) {
- std::string Suffix = *Triples[j] + "/" + GccVersions[i];
+ GccTriple = Triples[j];
+ std::string Suffix = Triples[j] + "/" + GccVersions[i];
std::string t1 = *it + "lib/gcc/" + Suffix;
if (!llvm::sys::fs::exists(t1 + "/crtbegin.o", Exists) && Exists)
return t1;
@@ -1546,6 +1551,7 @@ static std::string findGCCBaseLibDir(const Driver &D,
}
}
}
+ GccTriple.clear();
return "";
}
@@ -1710,7 +1716,7 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple)
// Add the non-multiplib suffixed paths (if potentially different).
if (!Base.empty() && !GccTriple.empty()) {
- if (!Suffix.empty())
+ if (!Suffix.empty() || !HasMultilib(Arch, Distro))
addPathIfExists(Base, Paths);
addPathIfExists(Base + "/../../../../" + GccTriple + "/lib", Paths);
addPathIfExists(Base + "/../../..", Paths);