Compilation time

Ben Gamari ben at
Fri Jul 7 23:33:58 UTC 2017

Evan Laforge <qdunkan at> writes:

> On Fri, Jul 7, 2017 at 9:28 AM, Ben Gamari <ben at> wrote:
>> In short, ./configure will now choose to use or ld.lld if
>> available (although this can be disabled using the --disable-ld-override
>> configure flag).
> Just from curiosity, does this apply to OS X?  Of course, gold is
> ELF-only, so it surely doesn't apply, but there's still lld.  OS X
> uses clang to compile so I thought it might already use lld, but the
> 'ld -v' output looks different, and implies it's a
> replacement for OS X ld, so maybe not.  But it doesn't look like GNU
> ld either, so maybe it's not affected by the BFD bug?
> I'll try 8.2 on OS X and see if the link time changes.

8.2 will prefer both gold and lld over bfd ld. However two conditions
must hold for these to be used,

 * The ld.lld/ executable must be in $PATH (or explicitly named
   by passing the LD variable to configure)

 * $CC must understand the `-fuse-ld={gold,lld}` option. For (IMHO quite
   silly) political reasons, gcc doesn't support `-fuse-ld=lld`. Debian
   happens to patch gcc to add support but I don't know how common this
   is in other distributions.

Unfortunately, some earlier `gcc` versions didn't fail if given a
`-fuse-ld` option that they didn't understand. Sadly we have no reliable
way to detect this, so in this case we may end up passing a `-fuse-ld`
option that gcc simply ignores.

In the case of OS X we use Apple's own home-grown linker. I'm not sure
whether/how OS X's gcc wrapper treats `-fuse-ld` (beyond that it doesn't
error if the flag is given). I also don't know whether lld is currently a
capable replacement for OS X ld.


- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <>

More information about the ghc-devs mailing list