Start keeping track of what work was done to detect a GCC installation
on the system, and report it when running the driver in verbose mode.
Without this it is essentially impossible to understand why a particular
GCC toolchain is used by Clang for libstdc++, libgcc, etc.
This also required threading a hook through the toolchain layers for
a specific toolchain implementation to print custom information under
'clang -v'. The naming here isn't spectacular. Suggestions welcome.
llvm-svn: 187427
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index 090181b..62f7834 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -1049,6 +1049,16 @@
}
}
+void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const {
+ for (SmallVectorImpl<std::string>::const_iterator
+ I = CandidateGCCInstallPaths.begin(),
+ E = CandidateGCCInstallPaths.end();
+ I != E; ++I)
+ OS << "Found candidate GCC installation: " << *I << "\n";
+
+ OS << "Selected GCC installation: " << GCCInstallPath << "\n";
+}
+
/*static*/ void Generic_GCC::GCCInstallationDetector::CollectLibDirsAndTriples(
const llvm::Triple &TargetTriple, const llvm::Triple &BiarchTriple,
SmallVectorImpl<StringRef> &LibDirs,
@@ -1383,6 +1393,7 @@
llvm::error_code EC;
for (llvm::sys::fs::directory_iterator LI(LibDir + LibSuffix, EC), LE;
!EC && LI != LE; LI = LI.increment(EC)) {
+ CandidateGCCInstallPaths.push_back(LI->path());
StringRef VersionText = llvm::sys::path::filename(LI->path());
GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
static const GCCVersion MinVersion = { "4.1.1", 4, 1, 1, "" };
@@ -1458,6 +1469,11 @@
return new tools::gcc::Link(*this);
}
+void Generic_GCC::printVerboseInfo(raw_ostream &OS) const {
+ // Print the information about how we detected the GCC installation.
+ GCCInstallation.print(OS);
+}
+
bool Generic_GCC::IsUnwindTablesDefault() const {
return getArch() == llvm::Triple::x86_64;
}