static compilation with the LLVM C frontend

Hello all,

I'm wondering if static compilation using llvm-gcc, i.e. including the library code (for example prinft) in the LLVM bytecode, is possible?

I've tried adding the -static option to the llvm-gcc4 compiler, but that doesn't seem to change much (I got the same instruction count either with or without the option).
Compiling and interpreting a small test program (hello world + a small loop), resulted in 240 dynamic instructions on bytecode level. This was obtained using lli -stats -force-interpreter on Mac OSX.

When I compile the same program on the Alpha architecture (using gcc 2.95, but that doesn't matter for these purposes), and count the amount of dynamic instructions (using instrumentation with ATOM), I get:
dynamic: 389
static: 4250

Apparently including the library functions (i.e. printf) in the code itself, matters a lot. I only used 2 printf calls in my test program. The test program is available on http://www.elis.ugent.be/~kehoste/hello_with_loop.c,
for anyone who would like to try.

I hope this is possible using LLVM, because otherwise it would mean LLVM is not really usefull for me. Any solutions, even compiling glibc myself, are an option.

greetings,

Kenneth

Hello all,

I'm wondering if static compilation using llvm-gcc, i.e. including the
library code (for example prinft) in the LLVM bytecode, is possible?

Static won't help you any. Unless the library is in bytecode form and
you are linking it in that form before analsis/instrumentation, it will
not be counted.

I hope this is possible using LLVM, because otherwise it would mean LLVM
is not really usefull for me. Any solutions, even compiling glibc
myself, are an option.

You need to compile glibc or at least as much of it as you care about
and link it in as bytecode to your application.

Andrew