Keppler, Dave
2009-Oct-15 18:30 UTC
[LLVMdev] [Fwd: Re: strace for whole-program bitcodes]
>>> 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.>The advantage of this approach is that it will potentially work with >build systems that call ar/ld directly. >
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