diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2011-09-27 22:03:18 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2011-09-27 22:03:18 +0000 |
commit | 5adcec16cb8d9e7bebf310b6c07249dfd852346b (patch) | |
tree | e15e56e05353afea624f7f1b6be1b7306afb49bb /lib/Driver/Driver.cpp | |
parent | c1c0dfb376b829b94d4c61e9f358ce23e6aa3169 (diff) |
Check for GCC paths that have the target triple in them. This is required for a lot of cross-compile toolchains. Also add some slightly better support for -B.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r-- | lib/Driver/Driver.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 121abc8b8b..ed9e275f7b 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1485,33 +1485,46 @@ std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const { return Name; } +static bool isPathExecutable(llvm::sys::Path &P, bool WantFile) { + bool Exists; + return (WantFile ? !llvm::sys::fs::exists(P.str(), Exists) && Exists + : P.canExecute()); +} + std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC, bool WantFile) const { + std::string TargetSpecificExecutable(DefaultHostTriple + "-" + Name); // Respect a limited subset of the '-Bprefix' functionality in GCC by // attempting to use this prefix when lokup up program paths. for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(), ie = PrefixDirs.end(); it != ie; ++it) { llvm::sys::Path P(*it); + P.appendComponent(TargetSpecificExecutable); + if (isPathExecutable(P, WantFile)) return P.str(); + P.eraseComponent(); P.appendComponent(Name); - bool Exists; - if (WantFile ? !llvm::sys::fs::exists(P.str(), Exists) && Exists - : P.canExecute()) - return P.str(); + if (isPathExecutable(P, WantFile)) 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) { llvm::sys::Path P(*it); + P.appendComponent(TargetSpecificExecutable); + if (isPathExecutable(P, WantFile)) return P.str(); + P.eraseComponent(); P.appendComponent(Name); - bool Exists; - if (WantFile ? !llvm::sys::fs::exists(P.str(), Exists) && Exists - : P.canExecute()) - return P.str(); + if (isPathExecutable(P, WantFile)) return P.str(); } // If all else failed, search the path. - llvm::sys::Path P(llvm::sys::Program::FindProgramByName(Name)); + llvm::sys::Path + P(llvm::sys::Program::FindProgramByName(TargetSpecificExecutable)); + if (!P.empty()) + return P.str(); + + P = llvm::sys::Path(llvm::sys::Program::FindProgramByName( + TargetSpecificExecutable)); if (!P.empty()) return P.str(); |