<div dir="ltr"><div class="gmail_default"><span style="font-family:tahoma,sans-serif">Hi Teresa, David, thanks for your reply!<br><br>Right, installing </span><font face="monospace, monospace"><b>llvm-dev</b></font><span style="font-family:tahoma,sans-serif"> package (<span style="font-family:arial,sans-serif;font-size:small;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><a href="https://packages.ubuntu.com/bionic/llvm-dev">https://packages.ubuntu.com/bionic/llvm-dev</a>)</span></span></div><div class="gmail_default"><ul><li><font face="monospace, monospace" size="1">$ sudo apt install llvm-dev</font></li></ul><span style="font-family:tahoma,sans-serif">and adding <b>LLVMgold.so</b> symbolic link to </span><font face="monospace, monospace">/usr/lib/bfd-plugins<span style="font-family:tahoma,sans-serif;font-size:small;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> worked great. 😀</span></font></div><div class="gmail_default"><ul><li><font face="monospace, monospace" size="1">$ sudo ln -s /usr/lib/LLVMgold.so /usr/lib/bfd-plugins/LLVMgold.so</font></li></ul><font face="tahoma, sans-serif">I'm wondering if adding this symbolic link and LLVMgold.so<br>should be part of installation of Clang on GNU/Linux (Ubuntu in my case)?</font></div><div class="gmail_default"><font face="tahoma, sans-serif">I mean I was expecting Clang to work no problem after installing just <span style="font-family:monospace,monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">clang</span> package.</font></div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div><div class="gmail_default"><font face="tahoma, sans-serif">Best regards, Mateusz Zych</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-08-13 18:52 GMT+02:00 Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I believe if you install LLVMgold.so into /usr/lib/bfd-plugins, the default ar and ranlib should pick it up without --plugin. See the info under Usage at <a href="https://llvm.org/docs/GoldPlugin.html" target="_blank">https://llvm.org/docs/<wbr>GoldPlugin.html</a>.<span class="HOEnZb"><font color="#888888"><div>Teresa</div></font></span></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 13, 2018 at 8:46 AM Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That's correct, we recommend use of the llvm tools for working with bitcode. Note, however, that the GNU ar and ranlib do accept a plugin via --plugin, so you could try using those with the LLVM gold plugin to work with bitcode. I personally use the llvm-ar/llvm-ranlib however.<div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 13, 2018 at 8:38 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">(Teresa, perhaps you can correct me if I'm wrong here)<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 9, 2018 at 2:21 PM Mateusz Zych via cfe-users <<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default"><font face="arial, helvetica, sans-serif">Hi :)</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">I am trying to compile simple project consisting of an executable "app" and static library "bar".</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">Note that I'm enabling thinLTO for both "app" and "bar".</font></div><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></font></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span>

</font></div><div class="gmail_default"><font face="monospace, monospace" size="1">//               bar.h                //</font></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">#ifndef BAR</span></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">#define BAR</span></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><br></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1">void bar ();</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><br></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1">#endif</font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span>

</font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1"><br></font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span>

</font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1">//              bar.cpp               //</font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span>

</font></div></div><div class="gmail_default"><div><div><font face="monospace, monospace" size="1">#include "bar.h"</font></div></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1">#include <iostream></font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1"><br></font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1">void bar ()</font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1">{</font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1">    std::cout << "Bar" << std::endl;</font></div></div><div class="gmail_default"><div><font face="monospace, monospace" size="1">}</font></div></div><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span>

</font></div><div class="gmail_default"><font face="monospace, monospace" size="1"><br></font></div><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span>

</font></div><div class="gmail_default"><font face="monospace, monospace" size="1">//              app.cpp               //</font></div><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//////////////////////////////<wbr>//////////</span>

</font></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1">#include "bar.h"</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1">#include <iostream></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><br></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1">int main()</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1">{</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="white-space:pre-wrap"> </span>std::cout << "App" << std::endl;</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1"><span style="white-space:pre-wrap">  </span>bar();</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace" size="1">}</font></div></div><div class="gmail_default"><font face="monospace, monospace" size="1">//////////////////////////////<wbr>//////////</font></div></blockquote><div class="gmail_default" style="font-family:"courier new",monospace"><br></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">When I'm using llvm-ar and llvm-ranlib to create static library everything works fine:</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">$ clang++ -flto=thin -c bar.cpp -o bar.o</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">$ <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">llvm-ar cr bar.a bar.o</span></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$ llvm-ranlib bar.a</span></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$ <span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">clang++ -flto=thin -c app.cpp -o app.o</span></span></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$ clang++ -flto=thin -o app app.o bar.a</span></span></font></div></div></blockquote><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><font face="arial, helvetica, sans-serif">However using default ar and ranlib provided by my GNU/Linux distribution results in linking failure:</font></span><br></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">$ clang++ -flto=thin -c bar.cpp -o bar.o</font></div></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">$ <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">ar cr bar.a bar.o</span></font></div></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$ ranlib bar.a</span></font></div></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$ <span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">clang++ -flto=thin -c app.cpp -o app.o</span></span></font></div></font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$ clang++ -flto=thin -o app app.o bar.a</span></span></font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div class="gmail_default">bar.a: <b>error adding symbols: Archive has no index; run ranlib to add one</b></div><div class="gmail_default">clang: error: linker command failed with exit code 1 (use -v to see invocation)</div></span></span></font></div></font></div></div></blockquote><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">

</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">Note that for GCC using default ar and ranlib works fine:</font></div><div class="gmail_default" style="font-family:"courier new",monospace"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">$ g++ -flto -c bar.cpp -o bar.o</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">$ </font><span style="font-family:monospace,monospace">ar cr bar.a bar.o</span></div></div><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace">$ ranlib bar.a</span></div></div><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace">$ g++ -flto -c app.cpp -o app.o</span></div></div><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace">$ g++ -flto -o app app.o bar.a</span></div></div></blockquote><div class="gmail_default"><div class="gmail_default"><br></div><div class="gmail_default">Obviously using gcc-ar and gcc-ranlib also works fine:</div><div class="gmail_default"><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">$ g++ -flto -c bar.cpp -o bar.o</font></div></div></div><div class="gmail_default"><div class="gmail_default"><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">$ gcc-</font><span style="font-family:monospace,monospace">ar cr bar.a bar.o</span></div></div></div><div class="gmail_default"><div class="gmail_default"><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="font-family:monospace,monospace">$ gcc-ranlib bar.a</span></div></div></div><div class="gmail_default"><div class="gmail_default"><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="font-family:monospace,monospace">$ g++ -flto -c app.cpp -o app.o</span></div></div></div><div class="gmail_default"><div class="gmail_default"><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="font-family:monospace,monospace">$ g++ -flto -o app app.o bar.a</span></div></div></div></blockquote><div class="gmail_default"><div class="gmail_default"><br></div><div class="gmail_default">My question is: <b>Can I use ar and ranlib provided by GNU/Linux with clang++?</b></div></div></div></blockquote><div><br></div><div>Not when using LTO, so far as I know. Otherwise, yes. (no idea if llvm-ar/llvm-ranlib are totally general purpose replacements for those tools, but I guess they are roughly/generally so)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default"><div class="gmail_default"><br>If not, then to properly setup clang as a default compiler on GNU/Linux machine,</div><div class="gmail_default">I should not only run update-alternatives for cc and c++ commands,<br>but also somehow do that for ar and ranlib commands?</div><div class="gmail_default"><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">$ sudo update-alternatives --config cc</font></div><div class="gmail_default"><span style="font-family:monospace,monospace">$<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> sudo update-alternatives --config c++</span> </span></div></div></blockquote><div class="gmail_default"><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">That's very problematic since update-alternatives doesn't work with ar and ranlib:</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="monospace, monospace">

<blockquote style="text-decoration-style:initial;text-decoration-color:initial;margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small"><font face="monospace, monospace">$ sudo update-alternatives --config ar</font></div><div class="gmail_default"><font face="monospace, monospace">update-alternatives: error: no alternatives for ar<br></font></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small"><span style="font-family:monospace,monospace">$<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> sudo update-alternatives --config ranlib</span></span></div><div class="gmail_default"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">update-alternatives: error: no alternatives for ranlib</span></div></div></blockquote></font></div></div></div></blockquote><div><br>Looks like you can teach update-alternatives to support new commands with the --install option?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default"><div class="gmail_default"><br></div><div class="gmail_default">If default ar and ranlib is expected to not work with clang++,<br>then how should I setup Clang as a default compiler on GNU/Linux?</div><div class="gmail_default"><br></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">Thanks, Mateusz Zych</font></div></div></div>
______________________________<wbr>_________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-users</a><br>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1473905572764948765m_-3175422969324642198gmail_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 style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td 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 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>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1473905572764948765gmail_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 style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td 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 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></blockquote></div><br></div>