[PATCH] Implement the -fuse-ld= option.

David Chisnall David.Chisnall at cl.cam.ac.uk
Thu Jun 26 01:01:06 PDT 2014

On 25 Jun 2014, at 19:20, Tim Northover <t.p.northover at gmail.com> wrote:

>> It's a bit binutils-centric isn't it? Can't we make it accept a
>> basename instead, so that any new or otherwise odd (ld.gold-2.25? lld?
>> mclinker?) linker can be used instead without modifying Clang.
> *Sigh*. Apologies. I've just noticed this comes from GCC land, so
> we've probably got to follow for compatibility. After all, why would
> anyone want to use anything except the system-default ld.gold or
> ld.bfd, they're perfect!

The gcc version hard-codes gold and bfd as the two valid options.  My patch, which Logan has cleaned up and fixed, allows --fuse-ld= to take a string and then searches for a program called ld.{whatever the argument string was}.  This means that you can install lld and create an ld.lld->lld symlink and have -fuse-ld=lld work without having to change the clang code.

In discussion when I wrote this patch, the consensus was that we should (initially, at least), only support linkers that had command-line syntax compatible with the system linker via this option.  If the linker needs different arguments, then some more invasive changes are required.  This should be enough for users to switch between bfd ld, gold, lld, and mclinker, however (and hopefully bold once it is released) on ELF platforms.  


More information about the cfe-commits mailing list