[patch] -Bprefix functionality improvement

Suppose we use clang and CodeSourcery MIPS toolchain. The toolchain
provides mips-linux-gnu-as, mips-linux-gnu-ld and other tools for a
cross-compilation. Everything is OK if we produce a code for
mips-linux-gnu target. But we get a problem if we want to produce a
code for mipsel-linux-gnu target. In that case clang driver wants to
use "mipsel-linux-gnu-ld" program but cannot find it.

The -B option seems to be a key to resolve this problem. The following
argument works for gcc: -B <path to the


Unfortunately the clang Driver::GetProgramPath() routine assumes that
a -B option's argument is a directory only. If we pass "-B <path to
the tollchain>/bin/mipsel-linux-gnu-" to the clang, driver will search
"<path to the tollchain>/bin/mipsel-linux-gnu-/ld" not "<path to the

/bin/mipsel-linux-gnuld" executable.

The attached patch improves -Bprefix functionality. If the "prefix" is
a directory, we add the program name as a new path component. If the
"prefix" is not a directory, we just join the prefix and the program
name as a couple of string and check the new path existence. Besides
that this patch removed unused argument "WantFile" from
Driver::GetProgramPath() and ToolChain::GetProgramPath() routines.

Bopt.patch (3.85 KB)