# glod plugin use

Hi,
I was trying to use gold plugin to compile and run some of my passes on some large softwares like mysql, apache etc. When I compile using llvm-gcc, everything works fine. But, when I followed the instructions on http://llvm.org/docs/GoldPlugin.html#build to use gold plugin, I got errors like:

/home/vadve/ssahoo2/local/bin/ld: error: modules/standard/libstandard.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: modules/extra/libextra.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: main/libmain.a: no archive symbol table (run ranlib)
....

I tried ranlib/llvm-ranlib, but it didn't work. Can someone help me, if I am doing anything wrong here?

Thanks,
Swarup.

Hi,
I am giving more details about the commands which gave these errors below, which may be helpful in figuring out the problem.

Hi,
I was trying to use gold plugin to compile and run some of my passes on some large softwares like mysql, apache etc. When I compile using llvm-gcc, everything works fine. But, when I followed the instructions on http://llvm.org/docs/GoldPlugin.html#build to use gold plugin, I got errors like:

/home/vadve/ssahoo2/local/bin/ld: error: modules/standard/libstandard.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: modules/extra/libextra.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: main/libmain.a: no archive symbol table (run ranlib)
....

I got these errors when build system was running the following command:

lvm-gcc -use-gold-plugin -DLINUX=2 -DUSE_HSREGEX -DUSE_EXPAT -I./lib/expat-lite -DNO_DL_NEEDED -O4 ./apaci -o httpd buildmark.o modules.o modules/standard/libstandard.a modules/extra/libextra.a main/libmain.a ./os/unix/libos.a ap/libap.a regex/libregex.a lib/expat-lite/libexpat.a -lm -lcrypt

When I replace llvm-gcc with the following ld -plugin command, I also get the same errors:

ld -plugin ~/local/lib/libLLVMgold.so -o httpd buildmark.o modules.o modules/standard/libstandard.a modules/extra/libextra.a main/libmain.a ./os/unix/libos.a ap/libap.a regex/libregex.a lib/expat-lite/libexpat.a -lm -lcrypt

Swarup Kumar Sahoo wrote:

Hi,
I was trying to use gold plugin to compile and run some of my passes on some large softwares like mysql, apache etc. When I compile using llvm-gcc, everything works fine. But, when I followed the instructions on http://llvm.org/docs/GoldPlugin.html#build to use gold plugin, I got errors like:

/home/vadve/ssahoo2/local/bin/ld: error: modules/standard/libstandard.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: modules/extra/libextra.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: main/libmain.a: no archive symbol table (run ranlib)
....

I tried ranlib/llvm-ranlib, but it didn't work. Can someone help me, if I am doing anything wrong here?

You shouldn't need ranlib nor llvm-ranlib.

I'm not entirely sure what's up with the .a files. It looks like ar has grown a --plugin options to match gold, whereas I seem to recall it used to just look in a fixed directory.

Rafael, have you been following what binutils has done with plugins for ar, nm and friends? It looks like we might need to update llvm-gcc to pass the gold plugin flag to ar and nm.

Nick

Date: Wed, 10 Mar 2010 22:09:22 -0800
From: Nick Lewycky <nicholas@mxc.ca>
Subject: Re: [LLVMdev] glod plugin use
To: Swarup Kumar Sahoo <ssahoo2@illinois.edu>

Swarup Kumar Sahoo wrote:

Hi,
I was trying to use gold plugin to compile and run some of my passes on some large softwares like mysql, apache etc. When I compile using llvm-gcc, everything works fine. But, when I followed the instructions on http://llvm.org/docs/GoldPlugin.html#build to use gold plugin, I got errors like:

/home/vadve/ssahoo2/local/bin/ld: error: modules/standard/libstandard.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: modules/extra/libextra.a: no archive symbol table (run ranlib)
/home/vadve/ssahoo2/local/bin/ld: error: main/libmain.a: no archive symbol table (run ranlib)
....

I tried ranlib/llvm-ranlib, but it didn't work. Can someone help me, if I am doing anything wrong here?

You shouldn't need ranlib nor llvm-ranlib.

I'm not entirely sure what's up with the .a files. It looks like ar has
grown a --plugin options to match gold, whereas I seem to recall it used
to just look in a fixed directory.

Rafael, have you been following what binutils has done with plugins for
ar, nm and friends? It looks like we might need to update llvm-gcc to
pass the gold plugin flag to ar and nm.

Yes, ar and nm actually take -plugin option and if I pass this option, then I don't get these errors. But, llvm-gcc doesn't automatically pass this option to ar.

You shouldn't need ranlib nor llvm-ranlib.

I'm not entirely sure what's up with the .a files. It looks like ar has
grown a --plugin options to match gold, whereas I seem to recall it used to
just look in a fixed directory.

Rafael, have you been following what binutils has done with plugins for ar,
nm and friends? It looks like we might need to update llvm-gcc to pass the
gold plugin flag to ar and nm.

ar and nm are supposed to try to use plugins automatically. Swarup,
can you check that you can run nm in a file with LLVM IL and it
displays the symbols?

Nick

Cheers,

Yes, ar and nm actually take -plugin option and if I pass this option, then I don't get these errors. But, llvm-gcc doesn't automatically pass this option to ar.

You probably just need to copy the gold plugin to
$PREFIX/lib/bfd-plugins. Let me know if that works. If not I will check if there is a bug in the plugin search in binutils. Cheers, Yes, ar and nm actually take -plugin option and if I pass this option, then I don't get these errors. But, llvm-gcc doesn't automatically pass this option to ar. You probably just need to copy the gold plugin to$PREFIX/lib/bfd-plugins. Let me know if that works. If not I will
check if there is a bug in the plugin search in binutils.

There is no problem in plugin search. If I give -plugin \path\to\plugin option to ar and nm, they are working fine. But, llvm-gcc doesn't pass this option to ar and nm automatically, so when I compile apache, I get those errors. When I wrote a small script to run ar with -plugin option for compiling apache, then I don't get these errors.

BTW, there is no directory called bfd_plugins inside lib. I think, there is some mistake in the documentation. I just copied the plugin to /lib directory and it works fine.

-Swarup.

Swarup Kumar Sahoo wrote:

Yes, ar and nm actually take -plugin option and if I pass this option, then I don't get these errors. But, llvm-gcc doesn't automatically pass this option to ar.

You probably just need to copy the gold plugin to
\$PREFIX/lib/bfd-plugins. Let me know if that works. If not I will
check if there is a bug in the plugin search in binutils.

There is no problem in plugin search. If I give -plugin \path\to\plugin option to ar and nm, they are working fine. But, llvm-gcc doesn't pass this option to ar and nm automatically, so when I compile apache, I get those errors. When I wrote a small script to run ar with -plugin option for compiling apache, then I don't get these errors.

I don't believe that llvm-gcc is used to execute the ar command. Having read everyone's input, I believe the problem stems from the fact that your llvmGold.so is not in a directory in which ar searches for plugins by default, *and* the Makefiles aren't passing the --plugin option to ar, so ar never loads llvmGold.so and cannot link LLVM bitcode files.

The solution is to either convince the software's build system to run ar with the --plugin option (you can set the AR environment variable before running configure to do this) or place llvmGold.so in the bfd-plugins directory as Rafael suggests (which will cause ar to load it whenever it is run).

-- John T.

There is no problem in plugin search. If I give -plugin \path\to\plugin option to ar and nm, they are working fine. But, llvm-gcc doesn't pass this option to ar and nm automatically, so when I compile apache, I get those errors. When I wrote a small script to run ar with -plugin option for compiling apache, then I don't get these errors.

The search is so that you don't have to pass -plugin

BTW, there is no directory called bfd_plugins inside lib. I think, there is some mistake in the documentation. I just copied the plugin to /lib directory and it works fine.

You need to created it manually.

-Swarup.

Cheers,

I don't believe that llvm-gcc is used to execute the ar command. Having
read everyone's input, I believe the problem stems from the fact that
your llvmGold.so is not in a directory in which ar searches for plugins
by default, *and* the Makefiles aren't passing the --plugin option to
ar, so ar never loads llvmGold.so and cannot link LLVM bitcode files.

The solution is to either convince the software's build system to run ar
with the --plugin option (you can set the AR environment variable before
running configure to do this) or place llvmGold.so in the bfd-plugins
directory as Rafael suggests (which will cause ar to load it whenever it
is run).

ok, now it works when I manually created the bfd-plugins directory and put the plugin there. I think, we can change the documentation to make this clear.

Thanks,
Swarup.