[LLVMdev] static compilation with the LLVM C frontend

Kenneth Hoste Kenneth.Hoste at UGent.be
Fri Jul 14 06:15:13 PDT 2006


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

-- 
Statistics are like a bikini. What they reveal is suggestive, but what 
they conceal is vital (Aaron Levenstein)

Kenneth Hoste
ELIS - Ghent University
kenneth.hoste at elis.ugent.be
http://www.elis.ugent.be/~kehoste



More information about the llvm-dev mailing list