[llvm-dev] (Thin)LTO llvm build

Teresa Johnson via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 3 17:31:11 PDT 2016


On Mon, Oct 3, 2016 at 5:04 PM, Carsten Mattner <carstenmattner at gmail.com>
wrote:

> On Mon, Oct 3, 2016 at 10:54 PM, Teresa Johnson <tejohnson at google.com>
> wrote:
> >
> > Aha - finally reproduced! The difference is using ld.bfd not
> > ld.gold. With that I get the same failure (using 3.9 to build 3.9
> > sources):
>
> Thanks a lot!
>
> [...]
>
> > I am not sure what the official support story is for LLVMgold.so and
> > ld.bfd. As mentioned earlier, the LLVM site indicates it should use
> > the gold linker. Can you use that while I try to figure out whether
> > this is something that should be supported/working?
>
> I'm probably confused but I was under the impression that I am using
> ld.gold due to the use of llvm-ar and llvm-ranlib and having enabled
> ThinLTO, which, if not strictly required with ld.bfd >=2.26, prefers
> ld.gold.
>

llvm-ar and llvm-ranlib are separate tools from ld.gold. And by using them
instead of system ar and ranlib, you don't need to ensure they use the
LLVMgold.so plugin, because they invoke LLVM libraries directly.

I poked around a little on the web a bit and it looks like the ld.bfd
support for using LLVMgold.so is fairly recent (probably why David says it
needs to be >= 2.26). However, they may still be resolving issues with
supporting the LLVMgold.so plugin. Definitely using LLVMgold.so with
ld.gold is much better tested (and possibly much better supported from the
LLVM side).


> Anyway, if I extend CFLAGS and CXXFLAGS with -fuse-ld=gold, then
> ld.gold terminates with
>
> /usr/bin/ld.gold: fatal error: --plugin-opt requires --plugin
>

Is this during cmake or during the build of bin/lldb?

But yeah, that is an aggravating issue with gold - it won't simply ignore
-plugin-opt when the plugin is not being invoked, which has given me issues
as well trying to run cmake configuration with -plugin-opt. Looks like
-fuse-ld=gold is somehow passing in a -plugin-opt? Oh, maybe it is the
plugin-opts below (see my next comment).


> According to the manpage the compile driver, if passed -fuse-ld=gold,
> will use ld.gold, so I added that to CFLAGS and CXXFLAGS before
> running cmake. The above was how far I got without further insight
> what I might have missed.
>
> I also tried setting LD=ld.gold, but that wasn't really respected by
> cmake, judging by how the ld actually used complained about the
> unsupport -Wl options (those which you suggested for aggressive
> pruning and which are not universal).
>
> Which are:
> -Wl,--gc-sections
> -Wl,-plugin-opt,-function-sections
> -Wl,-plugin-opt,-data-sections"
>

Did you set these via the cmake command? Maybe these are the options giving
the above error actually (if during cmake). In that case, edit
the CMakeCache.txt and add them there after running cmake.


> What's the right way to enable ld.gold explicitly when configuring
> llvm with cmake?
>

If you get rid of the above -plugin-opt from the cmake command (and maybe
add to CMakeCache.txt after running cmake), does it work ok with
-fuse-ld=gold (possibly specify this on the *LINKER_FLAGS instead as David
suggests in his reply)?

Another possibility, which is what I did to force usage of ld.bfd, is to
set your PATH to somewhere that ld -> ld.gold before running the "ninja
bin/lldb"

Teresa


-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/8eb5b4e6/attachment-0001.html>


More information about the llvm-dev mailing list