[LLVMdev] Instrumentation with liblto and gold
John Criswell
criswell at illinois.edu
Thu Mar 24 17:17:25 PDT 2011
On 3/24/11 7:10 PM, Sangmin Park wrote:
> Hi John,
>
> Thank you for your advice.
> LIBS and LDFLAGS work for the configure script,
> but they gave errors in the make stage for apache and mysql.
>
> I used either of the following ones with other flags:
> - export LIBS="-L/home/sangmin/Dropbox/Falcon/bin/ -ldummy"
> - export LDFLAGS="-L/home/sangmin/Dropbox/Falcon/bin/ -ldummy"
>
> Here are the error messages:
>
> Compile error (apache):
> make[3]: Entering directory `/home/sangmin/Concurrency/apache/srclib/apr'
> /bin/bash /home/sangmin/Concurrency/apache/srclib/apr/libtool --silent
> --mode=link llvm-gcc -use-gold-plugin -pthread -O4 -DHAVE_CONFIG_H
> -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I./include -I../include
> -version-info 9:5:9 -L/home/sangmin/Dropbox/Falcon/bin/ -ldummy -o
> libapr-0.la <http://libapr-0.la> -rpath
> /home/sangmin/Concurrency/apache-25520-llvm//lib
> strings/apr_cpystrn.lo strings/apr_fnmatch.lo strings/apr_snprintf.lo
> <skip>
> collect2: ld terminated with signal 6 [Aborted]
> ld:
> /home/sangmin/Dropbox/Falcon/src/llvm-2.7/include/llvm/Support/Casting.h:200:
> typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&)
> [with X = llvm::Instruction, Y = llvm::Value*]: Assertion `isa<X>(Val)
> && "cast<Ty>() argument of incompatible type!"' failed.
It looks like there is something wrong with your instrumentation pass.
You'll need to run the debugger on the linker. I think you can get
llvm-gcc to dump out the command line it uses for linking with some
option; checks the gcc docs.
-- John T.
> Stack dump:
> 0.Running pass 'Function Pass Manager' on module 'ld-temp.o'.
> 1.Running pass 'Function pass' on function
> '@apr_proc_other_child_refresh_all'
>
> Compile error (mysql):
> ake[2]: Entering directory `/home/sangmin/Concurrency/mysql/libmysql'
> /bin/bash ../libtool --mode=link llvm-gcc -use-gold-plugin -O3
> -DDBUG_OFF -O4 -L/home/sangmin/Dropbox/Falcon/bin/ -ldummy -rdynamic
> -o conf_to_src conf_to_src.o -lz -lcrypt -lnsl -lm
> llvm-gcc -use-gold-plugin -O3 -DDBUG_OFF -O4 -rdynamic -o conf_to_src
> conf_to_src.o -L/home/sangmin/Dropbox/Falcon/bin/ -ldummy -lz -lcrypt
> -lnsl -lm
> collect2: ld terminated with signal 6 [Aborted]
> ld:
> /home/sangmin/Dropbox/Falcon/src/llvm-2.7/include/llvm/Support/Casting.h:200:
> typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&)
> [with X = llvm::Instruction, Y = llvm::Value*]: Assertion `isa<X>(Val)
> && "cast<Ty>() argument of incompatible type!"' failed.
> Stack dump:
> 0.Running pass 'Function Pass Manager' on module 'ld-temp.o'.
> 1.Running pass 'Function pass' on function '@print_arrays_for'
>
> Any thoughts?
>
> Thanks,
> Sangmin
>
> On Thu, Mar 24, 2011 at 7:26 PM, John Criswell <criswell at illinois.edu
> <mailto:criswell at illinois.edu>> wrote:
>
> 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110324/6e2381a3/attachment.html>
More information about the llvm-dev
mailing list