Difficulties in using gold plugin. ("ar" not working properly)

Dear all,
I'm trying to use the gold plugin to make it easier to generate LLVM bitcode
from complex applications. I did the steps mentioned on
"http://llvm.org/docs/GoldPlugin.html". Both linking and LLVM generation seem to
work properly, however when using the tool ar, the symbol table is lost. "no
archive symbol table (run ranlib)".

I'm using LLVM 2.9, Ubuntu 10.10, binutils 2.20.51 both from the repository and
hand built (with -enable-gold and -enable-plugins).

Both LLVMgold.so and libLTO.so are located in:
~/tools/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/
~/lib/bfd-plugins
/usr/lib/bfd-plugins

The following are the build commands:
llvm-g++ -use-gold-plugin -flto $test.cpp -c -o test.o
ar --plugin /usr/lib/bfd-plugins/LLVMgold.so crs test.a test.o
llvm-g++ -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm test.a libstdc++.a -o

Maybe its just me doing some small error, but I can't see it..
Thanks for the help,
Istvan

Dear all,
I'm trying to use the gold plugin to make it easier to generate LLVM bitcode
from complex applications. I did the steps mentioned on
"http://llvm.org/docs/GoldPlugin.html". Both linking and LLVM generation seem to
work properly, however when using the tool ar, the symbol table is lost. "no
archive symbol table (run ranlib)".

I'm using LLVM 2.9, Ubuntu 10.10, binutils 2.20.51 both from the repository and
hand built (with -enable-gold and -enable-plugins).

Both LLVMgold.so and libLTO.so are located in:
~/tools/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/
~/lib/bfd-plugins
/usr/lib/bfd-plugins

The following are the build commands:
llvm-g++ -use-gold-plugin -flto $test.cpp -c -o test.o
ar --plugin /usr/lib/bfd-plugins/LLVMgold.so crs test.a test.o
llvm-g++ -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm test.a libstdc++.a -o

Maybe its just me doing some small error, but I can't see it..

Can you run nm on an IL file? What if you pass an explicit -plugin option to nm?

Thanks for the help,
Istvan

Cheers,
Rafael

Executing
nm --plugin /usr/lib/bfd-plugins/LLVMgold.so test.a
Gives:
00000000 W _ZN6tester4dumpEv
00000000 W _ZN6tester7readArgEPc
00000000 W _ZN6testerC1Ev
00000000 W _ZN6testerD1Ev
And and more entries
Without the plugin command "File format not recognized".

So it seems like nm is using the plugin.

Istvan

Executing
nm --plugin /usr/lib/bfd-plugins/LLVMgold.so test.a
Gives:
00000000 W _ZN6tester4dumpEv
00000000 W _ZN6tester7readArgEPc
00000000 W _ZN6testerC1Ev
00000000 W _ZN6testerD1Ev
And and more entries
Without the plugin command "File format not recognized".

So it seems like nm is using the plugin.

But only if explicitly told to do so. It should search the bfd-plugins directory automatically. Is the nm you are using installed in /usr/bin?

Istvan

Cheers,
Rafael

Rafael Avila de Espindola <rafael.espindola <at> gmail.com> writes:

But only if explicitly told to do so. It should search the bfd-plugins
directory automatically. Is the nm you are using installed in /usr/bin?

Cheers,
Rafael

It seems like I also had one in /usr/local/bin with the same version and it was
the default to be used. Now I copied my bfd-plugins folder to /usr/local/lib and
nm does not require the plugin option anymore. However the linker still cannot
find the symbols.

Thanks for the pointers,
Istvan

It seems like I also had one in /usr/local/bin with the same version and it was
the default to be used. Now I copied my bfd-plugins folder to /usr/local/lib and
nm does not require the plugin option anymore. However the linker still cannot
find the symbols.

Have you recreated the .a files? Does "nm -s" prints the archive symbol map?

Thanks for the pointers,
Istvan

Cheers,
Rafael

Have you recreated the .a files? Does "nm -s" prints the archive symbol map?

I delete and recreate the .a file every time.
nm output the same thing both with and without the "-s" option.
It seems to be the list of symbols in the format shown in the first post.

Istvan

It seems like using the latest version of binutils from CVS solved the problem.
The important part is that it works now, thanks again.

Istvan