[cfe-dev] [patch] -Bprefix functionality improvement

Simon Atanasyan satanasyan at mips.com
Wed Mar 28 05:46:06 PDT 2012


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
tollchain>/bin/mipsel-linux-gnu-

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
tollchain>/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.

--
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bopt.patch
Type: application/octet-stream
Size: 3940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120328/531befe4/attachment.obj>


More information about the cfe-dev mailing list