[llvm-dev] (Thin)LTO llvm build

Carsten Mattner via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 4 10:20:59 PDT 2016


On Tue, Oct 4, 2016 at 2:31 AM, Teresa Johnson <tejohnson at google.com> wrote:
>
>
> 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).

Thanks.

> > 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?

cmake.

> 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).

It can be preferable to thinking the option was used but was actually
ignored.

> 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.

It was cmake but not via -DCMAKE. Just plain CXXFLAGS, etc. to tell
the compile driver (gcc) to use gold.

> > 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)?

I haven't tried to build yet, but passing -fuse-ld=gold as suggested
with the three cmake variables by Xinliang David Li didn't break
cmake.

> 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"

A symlink might suffice I suppose.


More information about the llvm-dev mailing list