Using non-standard linker

David Chisnall theraven at FreeBSD.org
Thu Dec 13 13:10:54 UTC 2012


Hi Eric,

The easiest way of doing this is to make /usr/bin/ld (in the host system and in the bootstrap) into a symbolic link that points to whatever the selected linker is.  I had to do this when testing gold as well (we end up with ld-gold and ld-bfd and ld being a symlink to one of them).  

A better solution would be to teach clang about mclinker.  I was pondering adding a linker selection flag, along the lines of the existing -stdlib= for selecting the C++ standard library, as you may want to pass different options to different linkers.

David

On 13 Dec 2012, at 12:36, Erik Cederstrand wrote:

> Hi folks,
> 
> I'm working with Pete Chou from MCLinker (actually, he's doing almost all the work) to get mclinker to survive a buildworld. The goal is to allow mclinker to be a drop-in replacement for GNU ld.
> 
> My first suggestion was to just add LD=/usr/local/bin/mclinker to src.conf. But this only works when ld is invoked explicitly (and only when 'ld' is not hard-coded, of course).
> 
> When ld is invoked internally by the compiler, Pete has tested that gcc(collect2) and clang do not respect the LD variable, but search for 'ld' in COMPILER_PATH and then PATH instead. Since mclinker is not part of the build process, it isn't found in COMPILER_PATH, and GNU ld is used instead. Instead, he can add an additional compiler search path via the "-B" flag, which seems to work.
> 
> I'm worried that 'ld' is so hard-wired everywhere that it's impossible to specify another name. In that case, my suggestion would be to use build knobs, e.g. WITH_GNU_LD and WITH_MCLINKER_LD to install either GNU ld or mclinker as 'ld', but that wouldn't work unless mclinker is imported into base.
> 
> What's the FreeBSD way of doing this? What do other toolchains do if they use a non-GNU ld linker?
> 
> Thanks,
> Erik
> _______________________________________________
> freebsd-toolchain at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
> To unsubscribe, send any mail to "freebsd-toolchain-unsubscribe at freebsd.org"



More information about the freebsd-toolchain mailing list