[LLVMdev] Instrumentation with liblto and gold

John Criswell criswell at illinois.edu
Thu Mar 24 16:26:43 PDT 2011


On 3/24/11 6:23 PM, Sangmin Park wrote:
> Hi,
>
> I need advice in instrumenting programs using liblto and gold plugin.
> Specifically, I added my pass in tools/lto/LTOCodeGenerator.cpp.
> My pass inserts functions (myLoad and myStore) for some load and store 
> instructions.
> The functions exist in a library file.
>
> I found that the approach works for the example in the link:
> http://llvm.org/docs/GoldPlugin.html
> $ llvm-gcc -flto a.c -c -o a.o
> $ ar q a.a a.o
> $ llvm-gcc b.c -c -o b.o
> $ llvm-gcc -use-gold-plugin a.a b.o -L<path_to_my_lib> -l<my_lib> -o main
>
> I also found that I can compile large programs (apache and mysql) with 
> gold plugin.
> Here is the command:
> $ export CC="llvm-gcc -use-gold-plugin"; export CXX="llvm-g++ 
> -use-gold-plugin"; export RANLIB=/bin/true; export CFLAGS="-O4";
> $ ./configure
> $ make
> $ make install
>
> However, I cannot compile large programs with modified liblto and gold 
> plugin.
> That is because I have to specify the path to my library containing 
> myLoad and myStore in configure and makefile.
>
> Is there any fancy way to handle this problem?

The configure scripts might recognize the LIBS and LDFLAGS variables and 
add them to the linker options as it does for CFLAGS above.

-- John T.

>
> Thanks in advance.
>
> Sangmin




More information about the llvm-dev mailing list