[cfe-dev] Program path lookup for MIPS targets

Simon Atanasyan satanasyan at mips.com
Thu Mar 15 23:02:31 PDT 2012


Hi,

I want to fix a bug/issue in clang driver which can be described by
the following user story:
1. User wants to create a program for MIPS little-endian target.
2. User downloads and installs MIPS toolchain (say from CodeSourcery).
This toolchain provides mips-linux-gnu-ld tool. This linker generates
code for both big and little endian targets.
3. User runs "clang –target mipsel-linux-gnu –sysroot=..."  but
linking fails because clang cannot find "mipsel-linux-gnu-ld" and
attempts to use "ld".

In fact clang driver passes correct command line options to the
linker. If the user creates a symbolic link mipsel-linux-gnu-ld to
mips-linux-gnu-ld, clang produces code for little-endian target. It's
a workaround but I'd like to avoid it.

The problem seems to be in the Driver::GetProgramPath() routine. If we
request a path to "ld" for mipsel-linux-gnu target, this function
searches either DefaultTargetTriple+"ld" ("mipsel-linux-gnu-ld" in our
case) or "ld" and does not search "mips-linux-gnu-ld".

I’d like to get an advice how to fix this issue. Maybe I just do not
know about appropriate command line options. Put the knowledge of MIPS
targets to the Driver::GetProgramPath() is a straightforward solution
but looks ugly.

Thanks.

--
Simon




More information about the cfe-dev mailing list