Hi:<div><br></div><div>When I try to execute lli -force-interpreter=true hello.bc, it gave the following error:</div><div><br></div><div><div>LLVM ERROR: Tried to execute an unknown external function: i32 (i8*)* puts</div>
<div><br></div><div>I think the error is because C library is not being linked with the byte code, but I was not able to find any helpful instruction in lli's document.</div><div><br></div><div>Can you please teach me how to do it?</div>
<div><br></div><div>Thanks</div><div>Xu</div><div><br></div><div><br></div><div>The hello.bc is generated as the following:</div></div><div><br></div><div>======file: hello.c======</div><div><div>#include <stdio.h></div>
<div><br></div><div><br></div><div>int main(int argc, char** argv){</div><div>  printf("hello world\n");</div><div>  return 0;</div><div>}</div><div><br></div><div>====================</div><div><br></div><div><br>
</div><div>llvm-gcc -o hello.bc -emit-llvm -c hello.c</div><div><br></div><div><br></div><div>This is the code in hello.bc (after llvm-dis):</div><div>==================================</div><div>; ModuleID = 'hello.bc'</div>
<div><div>target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"</div><div>target triple = "i386-pc-linux-gnu"</div>
<div><br></div><div>@.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1]</div><div><br></div><div>define i32 @main(i32 %argc, i8** %argv) nounwind {</div><div>entry:</div>
<div>  %argc_addr = alloca i32                         ; <i32*> [#uses=1]</div><div>  %argv_addr = alloca i8**                        ; <i8***> [#uses=1]</div><div>  %retval = alloca i32                            ; <i32*> [#uses=2]</div>
<div>  %0 = alloca i32                                 ; <i32*> [#uses=2]</div><div>  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]</div><div>  store i32 %argc, i32* %argc_addr</div>
<div>  store i8** %argv, i8*** %argv_addr</div><div>  %1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0)) nounwind ; <i32> [#uses=0]</div><div>  store i32 0, i32* %0, align 4</div><div>  %2 = load i32* %0, align 4                      ; <i32> [#uses=1]</div>
<div>  store i32 %2, i32* %retval, align 4</div><div>  br label %return</div><div><br></div><div>return:                                           ; preds = %entry</div><div>  %retval1 = load i32* %retval                    ; <i32> [#uses=1]</div>
<div>  ret i32 %retval1</div><div>}</div><div><br></div></div></div>