<div>Hi,</div>I build llvm with gold plugin, clang and the binutils(and it's put into the PATH) with plugins support.<div>ld.gold is renamed to ld.  A quick test of clang -flto -O0 hello.c can succeed.</div><div>But when I try to export CC="clang -v -flto" and compile MySQL, it failed in the linking with the following error message:</div>
<div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 "/home/ryan/binutils/bin/ld" -export-dynamic -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o factorial /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu/crt1.o /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu/crti.o /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o -L/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5 -L/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu -L/lib/i386-linux-gnu -L/usr/lib/i386-linux-gnu -L/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.. -L/lib -L/usr/lib -plugin /home/ryan/llvm-build/Debug+Asserts/bin/../lib/LLVMgold.so my_main.o factorial.o libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a -lpthread -lcrypt -lnsl -lm -lpthread -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtend.o /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu/crtn.o<br>
/home/ryan/binutils/bin/ld: error: libdbug.a: no archive symbol table (run ranlib)<br>/home/ryan/binutils/bin/ld: error: ../strings/libmystrings.a: no archive symbol table (run ranlib)<br>my_main.c:23: error: undefined reference to 'my_thread_global_init'</blockquote>
</div><div><br></div><div>This does not seem to be specific on MySQL, tested on httpd, also emit similar error messages:</div><div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
/home/ryan/binutils/bin/ld: error: /tmp/httpd-2.2.22/srclib/pcre/.libs/libpcre.a: no archive symbol table (run ranlib)</blockquote></div><div><br></div><div>It looks like ar didn't run with gold plugin. Actually I did alias ar="ar --plugin /path/to/LLVMgold.so" and also similarly to</div>
<div>nm. Still didn't help. If I export AR="ar --plugin /path/to/LLVMgold.so", it will complain:</div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
/home/ryan/binutils/bin/ar: no operation specified</blockquote><div>which I found a related bug report to binutils on <a href="http://sourceware.org/bugzilla/show_bug.cgi?id=13256">http://sourceware.org/bugzilla/show_bug.cgi?id=13256</a> .</div>
</div><div><br></div><div>Does anyone have some clue on what's going on ?</div><div><br></div><div>Thanks very much!</div><div><br></div><div>Ryan</div>