[LLVMdev] Problem compiling with clang + gold plugin: no archive symbol table

1,789 views
Skip to first unread message

ryan

unread,
Jun 28, 2012, 5:58:11 PM6/28/12
to llv...@cs.uiuc.edu
Hi,
I build llvm with gold plugin, clang and the binutils(and it's put into the PATH) with plugins support.
ld.gold is renamed to ld.  A quick test of clang -flto -O0 hello.c can succeed.
But when I try to export CC="clang -v -flto" and compile MySQL, it failed in the linking with the following error message:

 "/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
/home/ryan/binutils/bin/ld: error: libdbug.a: no archive symbol table (run ranlib)
/home/ryan/binutils/bin/ld: error: ../strings/libmystrings.a: no archive symbol table (run ranlib)
my_main.c:23: error: undefined reference to 'my_thread_global_init'

This does not seem to be specific on MySQL, tested on httpd, also emit similar error messages:

/home/ryan/binutils/bin/ld: error: /tmp/httpd-2.2.22/srclib/pcre/.libs/libpcre.a: no archive symbol table (run ranlib)

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
nm. Still didn't help. If I export AR="ar --plugin /path/to/LLVMgold.so", it will complain:
/home/ryan/binutils/bin/ar: no operation specified
which I found a related bug report to binutils on http://sourceware.org/bugzilla/show_bug.cgi?id=13256 .

Does anyone have some clue on what's going on ?

Thanks very much!

Ryan

Rafael Espíndola

unread,
Jun 28, 2012, 6:05:47 PM6/28/12
to ryan, llv...@cs.uiuc.edu
> Does anyone have some clue on what's going on ?

You don't need to pass command line options to ar and nm if the plugin
is installed in the correct directories. A guess is that the build
system is running ranlib on the .a files and that is destroying the
index created by nm.

If you put the plugins in the bfd-plugins directory nm, ar and ranlib
will use them.

> Thanks very much!
>
> Ryan
>

Cheers,
Rafael
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

ryan

unread,
Jun 28, 2012, 6:18:01 PM6/28/12
to Rafael Espíndola, llv...@cs.uiuc.edu
Thanks for replying!
I didn't install the new binutils to system directory in case it messes thing up.
For ranlib, from the error message, it seems to be the reason. But even I export 
RANLIB=/bin/true, clean the code and rebuild, it still fails with the same message.
I created a symlink in /usr/lib/bfd-plugins as suggested in http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-March/030101.html.
Still it doesn't work..
Really have no idea what to try next.


Best regards,
Ryan

ryan

unread,
Jun 29, 2012, 4:17:02 AM6/29/12
to Rafael Espíndola, llv...@cs.uiuc.edu
I tried some other configurations. Now with llvm 3.0 + clang 3.0, and expoert CC to be clang -flto -use-gold-plugin,
and other ENV variables.
Good news is the "no archive symbol error message" is gone, but bad news is new error messages appear
/path/to/ld: error: ../mysys/libmysys.a: member at 8758 is not an ELF object
/path/to/ld: error: ../mysys/libmysys.a: member at 817850 is not an ELF object
/path/to/ld: error: ../mysys/libmysys.a: member at 827534 is not an ELF object

Searched a related thread(where the failed test case have similar error message) in:
I'm wondering if that issue has been resolved?

Best regards,
Ryan

Konstantin Tokarev

unread,
Jun 29, 2012, 5:07:14 AM6/29/12
to ryan, "llvmdev@cs.uiuc.edu"

29.06.2012, 12:17, "ryan" <stds...@gmail.com>:
> I tried some other configurations. Now with llvm 3.0 + clang 3.0, and expoert CC to be clang -flto -use-gold-plugin,and other ENV variables.
> Good news is the "no archive symbol error message" is gone, but bad news is new error messages appear

Why are you using outdated llvm and clang?
--
Regards,
Konstantin

ryan

unread,
Jun 29, 2012, 1:47:04 PM6/29/12
to Konstantin Tokarev, "llvmdev@cs.uiuc.edu"
I'm trying to enumerate different combinations to get a workable solution. 
At least this combination passed the previously failed step, but got stuck in later ones.
Also my GCC is still 4.5, so llvm 3.0 is not that outdated?

Regards,
Ryan

Konstantin Tokarev

unread,
Jun 29, 2012, 1:50:25 PM6/29/12
to ryan, llv...@cs.uiuc.edu

29.06.2012, 21:47, "ryan" <stds...@gmail.com>:

> I'm trying to enumerate different combinations to get a workable solution. At least this combination passed the previously failed step, but got stuck in later ones.
> Also my GCC is still 4.5, so llvm 3.0 is not that outdated?

It's much easier to build clang and llvm from sources that gcc, and seem to do it already :)

Reply all
Reply to author
Forward
0 new messages