Xu Yang
2009-Nov-16 07:14 UTC
[LLVMdev] lli -force-interpreter complains about external function
Hi: When I try to execute lli -force-interpreter=true hello.bc, it gave the following error: LLVM ERROR: Tried to execute an unknown external function: i32 (i8*)* puts 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. Can you please teach me how to do it? Thanks Xu The hello.bc is generated as the following: ======file: hello.c=====#include <stdio.h> int main(int argc, char** argv){ printf("hello world\n"); return 0; } =================== llvm-gcc -o hello.bc -emit-llvm -c hello.c This is the code in hello.bc (after llvm-dis): =================================; ModuleID = 'hello.bc' 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" target triple = "i386-pc-linux-gnu" @.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1] define i32 @main(i32 %argc, i8** %argv) nounwind { entry: %argc_addr = alloca i32 ; <i32*> [#uses=1] %argv_addr = alloca i8** ; <i8***> [#uses=1] %retval = alloca i32 ; <i32*> [#uses=2] %0 = alloca i32 ; <i32*> [#uses=2] %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] store i32 %argc, i32* %argc_addr store i8** %argv, i8*** %argv_addr %1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0)) nounwind ; <i32> [#uses=0] store i32 0, i32* %0, align 4 %2 = load i32* %0, align 4 ; <i32> [#uses=1] store i32 %2, i32* %retval, align 4 br label %return return: ; preds = %entry %retval1 = load i32* %retval ; <i32> [#uses=1] ret i32 %retval1 } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091116/1314fe99/attachment.html>
Nick Lewycky
2009-Nov-16 07:23 UTC
[LLVMdev] lli -force-interpreter complains about external function
Xu Yang wrote:> Hi: > > When I try to execute lli -force-interpreter=true hello.bc, it gave the > following error: > > LLVM ERROR: Tried to execute an unknown external function: i32 (i8*)* puts > > 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. > > Can you please teach me how to do it?The interpreter uses libffi to make external function calls. However, it needs to be detected at LLVM's compile time. If you're using the released packages, we disabled that because we were worried about users who don't have libffi installed. In short, install libffi and rebuild LLVM. Nick> Thanks > Xu > > > The hello.bc is generated as the following: > > ======file: hello.c=====> #include <stdio.h> > > > int main(int argc, char** argv){ > printf("hello world\n"); > return 0; > } > > ===================> > > llvm-gcc -o hello.bc -emit-llvm -c hello.c > > > This is the code in hello.bc (after llvm-dis): > =================================> ; ModuleID = 'hello.bc' > 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" > target triple = "i386-pc-linux-gnu" > > @.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x > i8]*> [#uses=1] > > define i32 @main(i32 %argc, i8** %argv) nounwind { > entry: > %argc_addr = alloca i32 ; <i32*> [#uses=1] > %argv_addr = alloca i8** ; <i8***> [#uses=1] > %retval = alloca i32 ; <i32*> [#uses=2] > %0 = alloca i32 ; <i32*> [#uses=2] > %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] > store i32 %argc, i32* %argc_addr > store i8** %argv, i8*** %argv_addr > %1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i32 > 0, i32 0)) nounwind ; <i32> [#uses=0] > store i32 0, i32* %0, align 4 > %2 = load i32* %0, align 4 ; <i32> [#uses=1] > store i32 %2, i32* %retval, align 4 > br label %return > > return: ; preds = %entry > %retval1 = load i32* %retval ; <i32> [#uses=1] > ret i32 %retval1 > } > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Timo Juhani Lindfors
2009-Nov-16 12:47 UTC
[LLVMdev] lli -force-interpreter complains about external function
Nick Lewycky <nicholas at mxc.ca> writes:> The interpreter uses libffi to make external function calls. However, it > needs to be detected at LLVM's compile time. If you're using the > released packages, we disabled that because we were worried about users > who don't have libffi installed.This seems to be quite a common problem (I too hit it once, thought it was a bug and reported it at http://llvm.org/bugs/show_bug.cgi?id=5466) how about making lli inform the user that LLVM was built without FFI support?
Apparently Analagous Threads
- [LLVMdev] lli -force-interpreter complains about external function
- [LLVMdev] lli -force-interpreter complains about external function
- [LLVMdev] lli -force-interpreter complains about external function
- [LLVMdev] lli -force-interpreter complains about external function
- [LLVMdev] lli -force-interpreter complains about external function