[LLVMbugs] [Bug 10744] New: Can't specify linker to use with the -B flag

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 25 11:45:27 PDT 2011


           Summary: Can't specify linker to use with the -B flag
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: glotov at chromium.org
                CC: llvmbugs at cs.uiuc.edu

$ clang
-B/usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/binutils-bin/2.20.1-gold/ld test.c
uses linker at
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();
   Linker = GetProgramPath("ld");

So it tries to use the first guess
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);
    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.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list