Using non-standard linker

Erik Cederstrand erik at cederstrand.dk
Thu Dec 13 12:36:33 UTC 2012


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


More information about the freebsd-toolchain mailing list