[cfe-dev] RFC: Overriding default linker at build time

Mehdi Amini via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 29 14:42:13 PST 2016


(-llvm-dev)

> On Nov 29, 2016, at 2:00 PM, Sean Fertile via cfe-dev <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
> 
> I've been trying to build a number of applications with link time optimization, and I am finding the existing options for picking-up gold as the linker don't play well with some of their build systems. I can't configure the system to use gold as the default system linker since that would affect everyone working on the machine, and that is typically more then just the people working on LLVM.
>  
> There is a gcc install directory that everyone building llvm targets with '-DGCC_INSTALL_PREFIX=', and looking at the driver/tool chain code, we could add a symlink to gold in there but again there are a number of non-llvm developers using that install for other purposes. If gcc has the same behavior as clang it will also start picking 'ld' from that path and I've affected everyone on the system. (Also the person who has been nice enough to maintain these installs for us is quite hesitant to the idea of modifying anything in these install directories.)
>  
> I've been able to use the '-fuse-ld=<path_to_gold>' option on most applications, but this still has a number of drawbacks. If I add the option to the LDFLAGS of something that builds Fortran and C/C++ then the Fortran compiler doesn't recognize it in the Fortran link steps and the compiles fail. If I add it to the C/C++ compilers (eg: export CXX="$PREFIX/bin/clang++ -flto -fuse-ld=/usr/bin/gold") then I get warnings about an unused option in all the C/C++ compile only steps, and a lot of these build have -Werror turned on. A bigger issue is builds that are using libtools, where libtools discards the -fuse-ld option in the link steps, breaking the -flto build completely.
>  
> I'd like to be able to specify a linker to use at build time. If a cmake option is set, then rather then trying to look up the default linker, ToolChain::GetLinkerPath would just return the path that was specified in the cmake configuration. This would enable being able to build and test lto builds (or test lld) without affecting anyone else.  

Is this: https://reviews.llvm.org/D25263 <https://reviews.llvm.org/D25263> ?

— 
Mehdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161129/fcde324e/attachment.html>


More information about the cfe-dev mailing list