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
This commit is contained in:
Daniel Dunbar 2009-03-23 16:15:50 +00:00
Родитель 1e0107a3d1
Коммит c50b00dbd8
4 изменённых файлов: 90 добавлений и 12 удалений

Просмотреть файл

@ -920,15 +920,8 @@ llvm::sys::Path Driver::GetProgramPath(const char *Name,
return P; return P;
} }
// As a last resort, always search in our directory before pulling // If all else failed, search the path.
// from the path. llvm::sys::Path P(llvm::sys::Program::FindProgramByName(Name));
llvm::sys::Path P(Dir);
P.appendComponent(Name);
if (P.exists())
return P;
// Search path to increase accuracy of logging output.
P = llvm::sys::Program::FindProgramByName(Name);
if (!P.empty()) if (!P.empty())
return P; return P;

Просмотреть файл

@ -159,7 +159,9 @@ ToolChain *DarwinHostInfo::getToolChain(const ArgList &Args,
if (strcmp(ArchName, "i386") == 0 || strcmp(ArchName, "x86_64") == 0) if (strcmp(ArchName, "i386") == 0 || strcmp(ArchName, "x86_64") == 0)
TC = new toolchains::Darwin_X86(*this, ArchName, TC = new toolchains::Darwin_X86(*this, ArchName,
getPlatformName().c_str(), getPlatformName().c_str(),
getOSName().c_str()); getOSName().c_str(),
DarwinVersion,
GCCVersion);
else else
TC = new toolchains::Darwin_GCC(*this, ArchName, TC = new toolchains::Darwin_GCC(*this, ArchName,
getPlatformName().c_str(), getPlatformName().c_str(),

Просмотреть файл

@ -9,11 +9,74 @@
#include "ToolChains.h" #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;
using namespace clang::driver::toolchains; using namespace clang::driver::toolchains;
/// Darwin_X86 - Darwin tool chain for i386 and x86_64. /// 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() { Darwin_X86::~Darwin_X86() {
// Free tool implementations. // Free tool implementations.
for (llvm::DenseMap<unsigned, Tool*>::iterator for (llvm::DenseMap<unsigned, Tool*>::iterator
@ -84,6 +147,13 @@ const char *Darwin_X86::GetForcedPicModel() const {
/// all subcommands; this relies on gcc translating the majority of /// all subcommands; this relies on gcc translating the majority of
/// command line options. /// 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() { Generic_GCC::~Generic_GCC() {
// Free tool implementations. // Free tool implementations.
for (llvm::DenseMap<unsigned, Tool*>::iterator for (llvm::DenseMap<unsigned, Tool*>::iterator

Просмотреть файл

@ -30,7 +30,7 @@ class VISIBILITY_HIDDEN Generic_GCC : public ToolChain {
public: public:
Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform, Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
const char *OS) : ToolChain(Host, Arch, Platform, OS) {} const char *OS);
~Generic_GCC(); ~Generic_GCC();
virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; } virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; }
@ -47,9 +47,19 @@ public:
class VISIBILITY_HIDDEN Darwin_X86 : public ToolChain { class VISIBILITY_HIDDEN Darwin_X86 : public ToolChain {
mutable llvm::DenseMap<unsigned, Tool*> Tools; mutable llvm::DenseMap<unsigned, Tool*> Tools;
/// Darwin version of tool chain.
unsigned DarwinVersion[3];
/// GCC version to use.
unsigned GCCVersion[3];
/// The directory suffix for this tool chain.
std::string ToolChainDir;
public: public:
Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform, Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform,
const char *OS) : ToolChain(Host, Arch, Platform, OS) {} const char *OS, const unsigned (&DarwinVersion)[3],
const unsigned (&GCCVersion)[3]);
~Darwin_X86(); ~Darwin_X86();
virtual ArgList *TranslateArgs(ArgList &Args) const; virtual ArgList *TranslateArgs(ArgList &Args) const;
@ -60,6 +70,9 @@ public:
virtual bool IsUnwindTablesDefault() const; virtual bool IsUnwindTablesDefault() const;
virtual const char *GetDefaultRelocationModel() const; virtual const char *GetDefaultRelocationModel() const;
virtual const char *GetForcedPicModel() const; virtual const char *GetForcedPicModel() const;
private:
const std::string &getToolChainDir() const { return ToolChainDir; }
}; };
/// Darwin_GCC - Generic Darwin tool chain using gcc. /// Darwin_GCC - Generic Darwin tool chain using gcc.