someone suggested me to use gold-plugin, I know nothing about it yet, I
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
"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.