Sean Fertile via llvm-dev
2016-Nov-29 22:00 UTC
[llvm-dev] RFC: Overriding default linker at build time
<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div dir="ltr" >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.</div> <div dir="ltr" > </div> <div dir="ltr" >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.)</div> <div dir="ltr" > </div> <div dir="ltr" >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<font size="2" face="Default Monospace,Courier New,Courier,monospace" ><span>: export</span> <span>CXX</span><span>=</span><span>"</span><span>$PREFIX</span><span>/bin/clang++ -flto -fuse-ld=/usr/bin/gold"</span></font>) 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.</div> <div dir="ltr" > </div> <div>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. </div> <div> </div> <div>I would appreciate any feedback. Has anyone else hit similar issues? Is there a better way to work around these issues?</div> <div> </div> <div>Thanks</div> <div>Sean Fertile</div></div></div></div><BR>