[LLVMdev] lli, llvm-ld and runtime libraries

Erick Tryzelaar erickt at dslextreme.com
Thu Dec 21 02:24:12 PST 2006


Hello again,

I'm exploring llvm's intermediary representation with this code:

////////////////////////////////////
%.LC0 = internal constant [13 x sbyte] c"hello world\0A\00"

declare int %puts(sbyte*)

implementation

int %main() {
  %cast210 = getelementptr [13 x sbyte]* %.LC0, long 0, long 0;
  call int %puts(sbyte* %cast210)
  ret int 0
}
////////////////////////////////////

And I can compile and run it like this:

llvm-as foo.ll
lli foo.bc

or

llvm-ld foo.bc -o foo

Which prints "hello world". This is great, but I can't figure out where 
the "puts" function is coming from. Does lli and llvm-ld automatically 
export the c standard library to the input file?

Second, it looks like I cannot specify an alternative runtime for lli. 
I'm guessing I'd have to build my own interpreter/jit if I want to run 
with a custom runtime. It looks like llvm-ld can accept libraries 
though, so I may be able to pass in the runtime there. Is this correct?

Thanks,
-e




More information about the llvm-dev mailing list