[LLVMdev] [Fwd: Re: strace for whole-program bitcodes]

Török Edwin edwintorok at gmail.com
Thu Oct 15 23:27:05 PDT 2009


On 2009-10-15 21:30, Keppler, Dave wrote:
>>>> someone suggested me to use gold-plugin, I know nothing about it yet, I
>>>>         
>> will
>>     
>>>> have a try later.  Does anyone have a good solution for this problem?
>>>>         
>>> Afaik gold does not help here. I tried it and managed to only generate
>>> native code.
>>>       
>> "Just" gold isn't quite good enough, because at the last final link
>> steps gold will still generate native code. However, it should be
>> possible to find a way to get gold to leave the merged bitcode around
>> somewhere, or perhaps do something like llvm-ld. Nicholas?
>>
>>     
>
> I've had some success by adding a call to lto_codegen_write_merged_modules(cg, somePath) at the end of the gold plugin's all_symbols_read_hook() function just before it calls lto_codegen_dispose(cg).  The somePath is set via a plugin option which I patched llvm-gcc to pass through as a derivation from its -o argument.
>
> It has worked on several mid-complexity applications I've tried so far (lighttpd, wu-ftpd, tcdump, and the sqlite library).
>
> I would be interested in seeing more of Timo's solution.  My goal is to eventually have a way to get bitcode + lli script outputs for off the shelf applications without modifying their make files.
>
>   

My way of getting whole program bitcodes is (you can use clang for CC)
for projects using autoconf and automake:
export CC=llvm-gcc
export CXX=llvm-g++
./configure --disable-shared
make CPPFLAGS="-O0 -g -emit-llvm" CCLD="llvm-ld -disable-opt" CFLAGS= -j4

I had to use CPPFLAGS instead of CFLAGS because llvm-ld doesn't
understand -O0 and -g, also it doesn't work to put CCLD on the configure
invocation line, it only works on the make invocation line.

Best regards,
--Edwin



More information about the llvm-dev mailing list