<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 5:24 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Small repro:<div><br></div><div><div>__attribute__((weak)) int hello_world();</div><div><br></div><div>int test() {</div><div>  if (hello_world)</div><div>      return hello_world();</div><div>  return 0;</div><div>}</div></div><div><br></div><div>$ clang -fuse-ld=gold  -flto=thin -O2 -shared -fPIC -o libmore.so more.c<br></div><div>$ objdump -t libmore.so |grep hello</div><div>0000000000000000  w      *UND*<span class="m_174928693278912880gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>0000000000000000              hello_world<br></div><div><br></div><div><div>$ clang -fuse-ld=bfd  -flto=thin -O2 -shared -fPIC -o libmore.so more.c</div><div>$ objdump -t libmore.so |grep hello</div><div>0000000000000000       *UND*<span class="m_174928693278912880gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>0000000000000000              hello_world</div></div></div></blockquote><div><br></div><div>Same issue reproduces with just -flto (not just -flto=thin). So this is a general issue with ld.bfd interactions with LLVMgold.so.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 4:40 PM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Oct 3, 2016 at 3:53 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@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"><div dir="ltr">What is the linker command line buidling liblldb.so? is libgcc.a passed in?</div></blockquote><div><br></div></span><div>There is no difference in the linker command for liblldb.so or bin/lldb between the ld.bfd and ld.gold cases, and neither links libgcc.a that I can see.</div><div><br></div><div>The difference appears to be that the __morestack symbol is weak in the ld.gold liblldb.so case (and simply doesn't appear in the resulting bin/lldb presumably because libgcc.a is not linked):</div><div><br></div><div>$ nm lib/liblldb.so.3.9.1 | grep morestack</div><div>                 w __morestack</div><div> <br></div><div>whereas it is an undef in the ld.bfd case:</div><div><br></div><div><div>$ nm lib/liblldb.so | grep morestack </div><div>                 U __morestack</div></div><div><br></div><div>resulting in the failure linking bin/lldb in that case.</div><div><div class="m_174928693278912880h5"><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"><div dir="ltr"><span class="m_174928693278912880m_1473642249882286040gmail-HOEnZb"><div style="color:rgb(136,136,136)"><br></div><div style="color:rgb(136,136,136)">David</div></span></div><div class="m_174928693278912880m_1473642249882286040gmail-HOEnZb"><div class="m_174928693278912880m_1473642249882286040gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 3:52 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@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"><div dir="ltr"><div>In  uint64_t</div><div>RTDyldMemoryManager::getSymbol<wbr>AddressInProcess(const std::string &Name)  {</div><div><br></div><div>there is reference to morestack:</div><div><br></div><div><br></div><div><br></div><div>#if defined(__i386__) || defined(__x86_64__)</div><div>  // __morestack lives in libgcc, a static library.</div><div>  if (&__morestack && Name == "__morestack")</div><div>    return (uint64_t)&__morestack;</div><div>#endif</div><div>#endif // __linux__ && __GLIBC__</div><div>  </div></div><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479HOEnZb"><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 3:32 PM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.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"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Oct 3, 2016 at 2:59 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@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"><div dir="ltr">Is -fsplit-stack option used anywhere? My wild guess is that with ld.bfd, the thinLTO link for the DSO does not bring in morestack.o from libgcc.a, but the hidden symbol is defined in lldb binary.</div></blockquote><div> </div></span><div>AFAICT, no - I had done "ninja -v" so I have all of the intermediate build commands, and it doesn't show up in that.</div><div><br></div><div>I'll have to do some more digging to figure out why it is referenced from liblldb.so in the ld.bfd case and not when using ld.gold</div><span class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479m_-2928118940119202326HOEnZb"><font color="#888888"><div><br></div><div>Teresa</div></font></span><div><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479m_-2928118940119202326h5"><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"><div dir="ltr"><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479m_-2928118940119202326m_-1038416839069215171gmail-h5">On Mon, Oct 3, 2016 at 1:54 PM, Teresa Johnson via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479m_-2928118940119202326m_-1038416839069215171gmail-h5"><div dir="ltr">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):<div><br></div><div><div>/usr/local/google/home/tejohns<wbr>on/binutils_build/install/bin/<wbr>ld: bin/lldb-3.9.1: hidden symbol `__morestack' in /usr/lib/gcc/x86_64-linux-gnu/<wbr>4.8/libgcc.a(morestack.o) is referenced by DSO</div><div>/usr/local/google/home/tejohns<wbr>on/binutils_build/install/bin/<wbr>ld: final link failed: Bad value</div><div>clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)</div><span><div>ninja: build stopped: subcommand failed.</div></span></div><div><br></div><div>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?</div><div><br></div><div>Thanks,</div><div>Teresa</div></div><div class="gmail_extra"><span><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 9:56 AM, 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>On Mon, Oct 3, 2016 at 3:50 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:<br>
><br>
> On Sun, Oct 2, 2016 at 4:02 AM, Carsten Mattner <<a href="mailto:carstenmattner@gmail.com" target="_blank">carstenmattner@gmail.com</a>> wrote:<br>
>><br>
>> On Sun, Oct 2, 2016 at 6:41 AM, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:<br>
> ><br>
</span><span>> > > I use trunk, but it depends on how close to the bleeding edge you<br>
> > > are comfortable with. But like I said, I also tried bootstrapping<br>
> > > with 3.9 (both trunk as well as 3.9 sources) and couldn't reproduce.<br>
>><br>
>> Hmm, so you're saying neither fails for you, right?<br>
><br>
> Yes<br>
<br>
</span>Okay. Do you mind focusing on the 3.9 branch? It's less of a moving target<br>
and lends itself more to figuring out what's failing for me.<br>
<br>
As soon as I get around to it, I'll send you my full configure and build<br>
steps as a shell script. Need to streamline it.<br>
</blockquote></div><br><br clear="all"><div><br></div></span><span>-- <br><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479m_-2928118940119202326m_-1038416839069215171gmail-m_6401007485645504697m_5651372993640721410gmail_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)"> <a href="tel:408-460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</span></div>
<br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div></div></div><div><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479m_-2928118940119202326h5"><br><br clear="all"><div><br></div>-- <br><div class="m_174928693278912880m_1473642249882286040gmail-m_-404270037872728479m_-2928118940119202326m_-1038416839069215171gmail_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)"> <a href="tel:408-460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div></div></div><div><div class="m_174928693278912880h5"><br><br clear="all"><div><br></div>-- <br><div class="m_174928693278912880m_1473642249882286040gmail_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)"> <a href="tel:408-460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="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-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>