Driver: Setup file and program search paths in tool chains.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67529 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 3165a8f..eac72ee 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -9,11 +9,74 @@
#include "ToolChains.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/HostInfo.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/System/Path.h"
+
using namespace clang::driver;
using namespace clang::driver::toolchains;
/// Darwin_X86 - Darwin tool chain for i386 and x86_64.
+Darwin_X86::Darwin_X86(const HostInfo &Host, const char *Arch,
+ const char *Platform, const char *OS,
+ const unsigned (&_DarwinVersion)[3],
+ const unsigned (&_GCCVersion)[3])
+ : ToolChain(Host, Arch, Platform, OS)
+{
+ DarwinVersion[0] = _DarwinVersion[0];
+ DarwinVersion[1] = _DarwinVersion[1];
+ DarwinVersion[2] = _DarwinVersion[2];
+ GCCVersion[0] = _GCCVersion[0];
+ GCCVersion[1] = _GCCVersion[1];
+ GCCVersion[2] = _GCCVersion[2];
+
+ ToolChainDir = "i686-apple-darwin";
+ ToolChainDir += llvm::utostr(DarwinVersion[0]);
+ ToolChainDir += "/";
+ ToolChainDir += llvm::utostr(GCCVersion[0]);
+ ToolChainDir += '.';
+ ToolChainDir += llvm::utostr(GCCVersion[1]);
+ ToolChainDir += '.';
+ ToolChainDir += llvm::utostr(GCCVersion[2]);
+
+ std::string Path;
+ if (getArchName() == "x86_64") {
+ Path = getHost().getDriver().Dir;
+ Path += "/../lib/gcc/";
+ Path += getToolChainDir();
+ Path += "/x86_64";
+ getFilePaths().push_back(Path);
+
+ Path = "/usr/lib/gcc/";
+ Path += getToolChainDir();
+ Path += "/x86_64";
+ getFilePaths().push_back(Path);
+ }
+
+ Path = getHost().getDriver().Dir;
+ Path += "/../lib/gcc/";
+ Path += getToolChainDir();
+ getFilePaths().push_back(Path);
+
+ Path = "/usr/lib/gcc/";
+ Path += getToolChainDir();
+ getFilePaths().push_back(Path);
+
+ Path = getHost().getDriver().Dir;
+ Path += "/../libexec/gcc/";
+ Path += getToolChainDir();
+ getProgramPaths().push_back(Path);
+
+ Path = "/usr/libexec/gcc/";
+ Path += getToolChainDir();
+ getProgramPaths().push_back(Path);
+
+ getProgramPaths().push_back(getHost().getDriver().Dir);
+}
+
Darwin_X86::~Darwin_X86() {
// Free tool implementations.
for (llvm::DenseMap<unsigned, Tool*>::iterator
@@ -84,6 +147,13 @@
/// all subcommands; this relies on gcc translating the majority of
/// command line options.
+Generic_GCC::Generic_GCC(const HostInfo &Host, const char *Arch,
+ const char *Platform, const char *OS)
+ : ToolChain(Host, Arch, Platform, OS)
+{
+ getProgramPaths().push_back(getHost().getDriver().Dir);
+}
+
Generic_GCC::~Generic_GCC() {
// Free tool implementations.
for (llvm::DenseMap<unsigned, Tool*>::iterator