diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-03-22 01:52:07 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-03-22 01:52:07 +0000 |
commit | 48ad6094679ca2bf4f3593068e02e7a208c1a73c (patch) | |
tree | 80addc602298e0572c50e30f95be0429eb456dec /lib/Driver/Driver.cpp | |
parent | 01620704304f819b82ecef769ec114e541a364d7 (diff) |
Add very limited support for GCC's '-B' flag. This allows us to support unusual
toolchain configurations and is a small step toward FreeBSD support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r-- | lib/Driver/Driver.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index acfff386f4..aa55d39886 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -172,6 +172,8 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) { HostTriple = A->getValue(*Args); if (const Arg *A = Args->getLastArg(options::OPT_ccc_install_dir)) Dir = A->getValue(*Args); + if (const Arg *A = Args->getLastArg(options::OPT_B)) + PrefixDir = A->getValue(*Args); Host = GetHostInfo(HostTriple); @@ -1088,6 +1090,15 @@ const char *Driver::GetNamedOutputPath(Compilation &C, } std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const { + // Respect a limited subset of the '-Bprefix' functionality in GCC by + // attempting to use this prefix when lokup up program paths. + if (!PrefixDir.empty()) { + llvm::sys::Path P(PrefixDir); + P.appendComponent(Name); + if (P.exists()) + return P.str(); + } + const ToolChain::path_list &List = TC.getFilePaths(); for (ToolChain::path_list::const_iterator it = List.begin(), ie = List.end(); it != ie; ++it) { @@ -1102,6 +1113,15 @@ std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const { std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC, bool WantFile) const { + // Respect a limited subset of the '-Bprefix' functionality in GCC by + // attempting to use this prefix when lokup up program paths. + if (!PrefixDir.empty()) { + llvm::sys::Path P(PrefixDir); + P.appendComponent(Name); + if (WantFile ? P.exists() : P.canExecute()) + return P.str(); + } + const ToolChain::path_list &List = TC.getProgramPaths(); for (ToolChain::path_list::const_iterator it = List.begin(), ie = List.end(); it != ie; ++it) { |