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 | 84559243036b1f7a1ae10b223c613edef15b3921 (patch) | |
| tree | d617300187efb73a8c506cbd4e905a88cda6a739 /clang/lib | |
| parent | 77eede5776a770aeecd700ffb7ecfbb404a8df63 (diff) | |
| download | bcm5719-llvm-84559243036b1f7a1ae10b223c613edef15b3921.tar.gz bcm5719-llvm-84559243036b1f7a1ae10b223c613edef15b3921.zip | |
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.
llvm-svn: 99159
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index acfff386f48..aa55d398866 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/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) { |

