[cfe-dev] Linker selection

David Chisnall David.Chisnall at cl.cam.ac.uk
Fri Dec 14 00:24:34 PST 2012


Hello the list,

At some point in the near future, FreeBSD is going to start transitioning to a new linker (mclinker, which works now, possibly then migrating to lld once it becomes more complete).  People also often install gold or a newer bfd ld from ports.  This means that we will have two, possibly three, linkers in the base system and another two from ports, and yet clang currently hard-codes the fact that the linker is the one called ld that is the first to be found in the path.  I suspect that, initially, mclinker will be adequate for the base system but possibly not for some ports, so we will need to be able to easily select an alternative linker.

I'd like to add some logic for selecting the linker at run time.  Before I start, I was wondering if anyone had any suggestions as to the correct UI for this.  As far as I can see, there are two possible choices:

1) We have a flag that takes a full path to the linker to use.  This is somewhat problematic, because if two linkers require different arguments (not much of a problem for us, but imagine on Windows being able to switch between the MS and Binutils linkers) then you need to know what the linker is, as well as its name.

2) We have a flag like the libc++ / libstdc++ selection flag, which takes an argument like bfd, gold, mc, lld and some logic in the driver to work out what the paths and names of each of these should be.

Is there a more sensible third option?  

David



More information about the cfe-dev mailing list