I would like to compile software using the autotools build system to LLVM bitcode; that is, I would like the executables obtained at the end to be LLVM bitcode, not actual machine code.
(The goal is to be able to run LLVM bitcode analysis tools on the whole program.)
I've tried specifying CC="clang -emit-llvm -use-gold-plugins"
and variants to the configure
script, to no avail. There is always something going wrong (e.g. the package builds .a
static libraries, which are refused by the linker).
It seems to me that the correct way to do it would be that LLVM bitcode should be a cross-compilation target. to be set with --host=
, but there is no such standard target (even though there is a target for Knuth's MMIX).
So far I've used kludges, such as compiling with CC="clang -emit-llvm -use-gold-plugins"
and running linking lines (using llvm-ld
or llvm-link
) manually. This works for simple packages such as grep
.
I would like a method that's robust and works with most, if not all, configure scripts, including when there are intermediate .a
files, or intermediate targets.