-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 10744 |
| Resolution | FIXED |
| Resolved on | Sep 01, 2011 11:26 |
| Version | trunk |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @efriedma-quic,@zmodem,@nico |
Extended Description
$ clang -B/usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/binutils-bin/2.20.1-gold/ld test.c
uses linker at "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/../../../../x86_64-pc-linux-gnu/bin/ld" and ignores one specified by -B. To see it, use -v.
I think this is because of the following code:
In tools/clang/lib/Driver/ToolChains.cpp:
llvm::sys::Path LinkerPath(Base + "/../../../../" + GccTriple + "/bin/ld");
if (!llvm::sys::fs::exists(LinkerPath.str(), Exists) && Exists)
Linker = LinkerPath.str();
else
Linker = GetProgramPath("ld");
So it tries to use the first guess (/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/../../../../x86_64-pc-linux-gnu/bin/ld) linker, and only if not found, it invokes ToolChain::GetProgramPath("ld", true), which calls Driver::GetProgramPath("ld", this, true):
In tools/clang/lib/Driver/Driver.cpp:
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.
for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(),
ie = PrefixDirs.end(); it != ie; ++it) {
llvm::sys::Path P(*it);
P.appendComponent(Name);
bool Exists;
if (WantFile ? !llvm::sys::fs::exists(P.str(), Exists) && Exists
: P.canExecute())
return P.str();
}
...
So it does respect -B, but only if the first guess not found.