<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 5:04 PM, Carsten Mattner <span dir="ltr"><<a href="mailto:carstenmattner@gmail.com" target="_blank">carstenmattner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Mon, Oct 3, 2016 at 10:54 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>> wrote:<br>
><br>
> Aha - finally reproduced! The difference is using ld.bfd not<br>
> ld.gold. With that I get the same failure (using 3.9 to build 3.9<br>
> sources):<br>
<br>
</span>Thanks a lot!<br>
<br>
[...]<br>
<span class="gmail-"><br>
> I am not sure what the official support story is for LLVMgold.so and<br>
> ld.bfd. As mentioned earlier, the LLVM site indicates it should use<br>
> the gold linker. Can you use that while I try to figure out whether<br>
> this is something that should be supported/working?<br>
<br>
</span>I'm probably confused but I was under the impression that I am using<br>
ld.gold due to the use of llvm-ar and llvm-ranlib and having enabled<br>
ThinLTO, which, if not strictly required with ld.bfd >=2.26, prefers<br>
ld.gold.<br></blockquote><div><br></div><div>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.</div><div><br></div><div>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).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Anyway, if I extend CFLAGS and CXXFLAGS with -fuse-ld=gold, then<br>
ld.gold terminates with<br>
<br>
/usr/bin/ld.gold: fatal error: --plugin-opt requires --plugin<br></blockquote><div><br></div><div>Is this during cmake or during the build of bin/lldb? </div><div><br></div><div>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).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
According to the manpage the compile driver, if passed -fuse-ld=gold,<br>
will use ld.gold, so I added that to CFLAGS and CXXFLAGS before<br>
running cmake. The above was how far I got without further insight<br>
what I might have missed.<br>
<br>
I also tried setting LD=ld.gold, but that wasn't really respected by<br>
cmake, judging by how the ld actually used complained about the<br>
unsupport -Wl options (those which you suggested for aggressive<br>
pruning and which are not universal).<br>
<br>
Which are:<br>
-Wl,--gc-sections<br>
-Wl,-plugin-opt,-function-<wbr>sections<br>
-Wl,-plugin-opt,-data-<wbr>sections"<br></blockquote><div><br></div><div>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.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
What's the right way to enable ld.gold explicitly when configuring<br>
llvm with cmake?<br>
</blockquote></div><div class="gmail_extra"><br></div>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)?</div><div class="gmail_extra"><br></div><div class="gmail_extra">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"</div><div class="gmail_extra"><br></div><div class="gmail_extra">Teresa<br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><span style="font-family:times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>