[cfe-commits] r140604 - /cfe/trunk/lib/Driver/ToolChains.cpp

David Chisnall csdavec at swan.ac.uk
Sat Oct 1 02:45:40 PDT 2011


On 1 Oct 2011, at 10:06, Chandler Carruth wrote:

> On Sat, Oct 1, 2011 at 1:03 AM, David Chisnall <csdavec at swan.ac.uk> wrote:
>> As the commit message implies, it was making -B work for paths that are provided to ld under Linux.  A lot of cross-compile toolchains put things like crtbegin.o in an SDK-specific location.  With this applied, it was possible to just add -B/path/to/sdk to the clang flags and have things work.
>> 
> For reference, I'm currently working on making --sysroot work for linker flags passed through ld, based on how GCC manages them. I'm not familiar at all with '-B's behavior, as it isn't used by the cross-compiling GCC toolchain I work with, and it was indicated to have design problems.

--sysroot is not a viable alternative, because GCC cross-build toolchains do not put everything in the sysroot. Things like libcrt.o live in the GCC root directory.  This is hard-coded into the GCC version that they ship, so there needs to be some way of providing this path to clang.

> That said, if you need to implement support for '-B' behavior, please do so. One good way to clarify its intent is to include test cases for exactly what you expect the effect to be on the driver.
> 
>> If this has been reverted, then please can someone implement the same feature in a better way?  Without it, I will no longer be able to cross-compile targeting ARM/Linux...
> 
> If you have a use case, I think you're the best person to implement it. Please work up a patch that has both test cases covering the features you want, and that doesn't break existing test cases (I added one to cover the regression that your original patch caused), and mail it to the list.
> 
> I do think something like this should get some review, as I've heard concerns and objections to furthering Clang's support for the '-B' option in the past, as it seemed poorly designed in GCC.

It doesn't need to be done via -B.  In fact, it might be preferable to provide an explicit option to supply the GCC library path, since Linux distributions and toolchains seem to put this in random braindead locations that change at a whim.

I'm hesitant to touch the Linux part of the driver again, because the code is a horrible mess of kludges and hard-coded paths, and I've no idea what will be broken.  Adding = to the start of a path shouldn't have broken anything, because in the absence of -B options this should be exactly equivalent to no = being present.  If it isn't, then there's a bug elsewhere in the spaghetti.

David



More information about the cfe-commits mailing list