gold plugin example

Hi all,

I got an error from the gold plugin example in the following link:
http://llvm.org/docs/GoldPlugin.html#example1

Here is the error message:

sangmin@sangmin-desktop:/tmp$ llvm-gcc -use-gold-plugin a.a b.o -o main
/usr/bin/ld: error: a.a: no archive symbol table (run ranlib)
/usr/bin/ld: /usr/lib/crt1.o:(.text+0x18): error: undefined reference to ‘main’
/usr/bin/ld: b.o: in function foo1:b.c(.text+0x4): error: undefined reference to ‘foo2’
collect2: ld returned 1 exit status

I followed the instructions from the previous thread below, but I still have the problem.
http://old.nabble.com/llvm-gold-plugin-example-td28140005.html

I got the error with both 2.7 and 2.8.
Here are my settings:

LLVMgold.so in (with LLVM 2.8)

  • $HOME/llvm-gcc-4.2-2.8-i686-linux/libexec/gcc/i686-pc-linux-gnu/4.2.1/LLVMgold.so
  • $HOME/llvm-gcc-4.2-2.8-i686-linux/lib/bfd-plugins/LLVMgold.so
  • /usr/lib/bfd-plugins/LLVMgold.so

libLLVMgold.so in (with LLVM 2.7)

  • $HOME/llvm-gcc-4.2-2.7-i686-linux/libexec/gcc/i686-pc-linux-gnu/4.2.1/libLLVMgold.so
  • $HOME/llvm-gcc-4.2-2.7-i686-linux/lib/bfd-plugins/libLLVMgold.so
  • /usr/lib/bfd-plugins/libLLVMgold.so

Compiled ld-new, ar, nm-new are linked to /usr/bin/ld, /usr/bin/ar, /uar/bin/nm, respectively.

sangmin@sangmin-desktop:/tmp$ ld -v
GNU gold (GNU Binutils 2.21.51.20110316) 1.11

Thanks in advance for your help.

Sangmin

Hi,

I fixed error by using different version of ld with LLVM 2.7.
I used ld.gold that comes with Ubuntu 10.04.
Here is the version info:

sangmin@sangmin-desktop:/tmp$ ld -v
GNU gold (GNU Binutils for Ubuntu 2.20.1-system.20100303) 1.9

My experience of gold plugin is as follows:

LLVM 2.7 (with libLLVMgold.so) + ld 2.20.1 (from Ubuntu 10.04) : O
LLVM 2.7 (with libLLVMgold.so) + ld 2.21.51 (manually compiled) : X
LLVM 2.8 (with LLVMgold.so) + ld 2.20.1 (from Ubuntu 10.04): X
LLVM 2.8 (with LLVMgold.so) + ld 2.21.51 (manually compiled): X

When compiling (lib)LLVMgold.so file, I used the source file from ld 2.21.51.

I can work with LLVM 2.7 and ld 2.20.1 now, but am curious with the result.
Can you explain what part I did wrong?

Thanks,
Sangmin

Looks like ar is not using the plugin. Have you created the links in bfd-plugins? Can you run nm in a IL file?

Cheers,
Rafael

Hi,

I fixed error by using different version of ld with LLVM 2.7.
I used ld.gold that comes with Ubuntu 10.04.
Here is the version info:

sangmin@sangmin-desktop:/tmp$ ld -v
GNU gold (GNU Binutils for Ubuntu 2.20.1-system.20100303) 1.9

My experience of gold plugin is as follows:

LLVM 2.7 (with libLLVMgold.so) + ld 2.20.1 (from Ubuntu 10.04) : O
LLVM 2.7 (with libLLVMgold.so) + ld 2.21.51 (manually compiled) : X
LLVM 2.8 (with LLVMgold.so) + ld 2.20.1 (from Ubuntu 10.04): X
LLVM 2.8 (with LLVMgold.so) + ld 2.21.51 (manually compiled): X

When compiling (lib)LLVMgold.so file, I used the source file from ld
2.21.51.

I can work with LLVM 2.7 and ld 2.20.1 now, but am curious with the result.
Can you explain what part I did wrong?

Thanks,
Sangmin

Hi all,

I got an error from the gold plugin example in the following link:
http://llvm.org/docs/GoldPlugin.html#example1

Here is the error message:

sangmin@sangmin-desktop:/tmp$ llvm-gcc -use-gold-plugin a.a b.o -o main
/usr/bin/ld: error: a.a: no archive symbol table (run ranlib)

Looks like ar is not using the plugin. Have you created the links in
bfd-plugins? Can you run nm in a IL file?

I have created the links in bfd-plugins, but I had some mistakes in handling versions. Now, I found that all combinations of versions work well for the example.

By the way, how can I manually check whether ar and nm work?

Thanks,
Sangmin

I have created the links in bfd-plugins, but I had some mistakes in
handling versions. Now, I found that all combinations of versions work
well for the example.

By the way, how can I manually check whether ar and nm work?

Both take --plugin options. You can run nm in a plugin file to see if it
can print the symbols. You can also create an archive with some IL file
in it and check the armap by running "nm -s" in the produced .a file.

Thanks,
Sangmin

Cheers,
Rafael