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?
Nick Lewycky
2009-Nov-17 07:52 UTC
[LLVMdev] lli -force-interpreter complains about external function
Timo Juhani Lindfors wrote:> 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?Thanks for the reminder. I recall looking at the patch but I didn't apply it at the time because I couldn't figure out why the code above it used errs() in one case and llvm_report_error in another. Nick
Xu Yang
2009-Nov-18 05:02 UTC
[LLVMdev] lli -force-interpreter complains about external function
Hi Nick: Thanks for pointing me to libffi. Recompile LLVM with libffi does solve the problem of printf. But it still has other problems: 1) sinf() returns 0 in the interpreter, but returns correct value in JIT (see hellosin.c) 2) calling pthread_create cause lli to crash in the interpreter mode, but no problem in JIT (see phello.c). My questions are: i) can I call any arbitrary external function in the interpreter? ii) how do I specify the dynamic library (where the external function is implemented), when I call the interpreter? Thanks Xu hellosin.c ======================#include <stdio.h> #include <math.h> int main(int argc, char** argv){ float f = sinf(0.5235988f); printf("hello sin: %10.2f\n", f); return 0; } =======================$ llvm-gcc -o hellosin.bc -emit-llvm -c hellosin.c $ lli -force-interpreter=true hellosin.bc hello sin: 0.00 $ lli hellosin.bc hello sin: 0.50 phello.c =======================#include <pthread.h> #include <stdio.h> #define NUM_THREADS 4 void *PrintHello(void *threadid) { long tid; tid = (long)threadid; printf("Hello from %ld.\n", tid); pthread_exit(NULL); } int main (int argc, char *argv[]) { pthread_t threads[NUM_THREADS]; int ret; long t; for(t=0; t<NUM_THREADS; t++){ #ifdef DEBUG printf("creating thread %ld\n", t); #endif ret = pthread_create(&threads[t], NULL, PrintHello, (void *)t); if (ret){ printf("pthread_create ERROR: %d\n", ret); return(-1); } } pthread_exit(NULL); } =======================$ llvm-gcc -o phello.bc -emit-llvm -c phello.c $ lli -force-interpreter=true phello.bc 0 lli 0x08796bf8 Segmentation fault $ lli phello.bc Hello from 0. Hello from 1. Hello from 2. Hello from 3. On Tue, Nov 17, 2009 at 2:52 AM, Nick Lewycky <nicholas at mxc.ca> wrote:> Timo Juhani Lindfors wrote: > >> 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? >> > > Thanks for the reminder. I recall looking at the patch but I didn't apply > it at the time because I couldn't figure out why the code above it used > errs() in one case and llvm_report_error in another. > > Nick >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091118/585c0a53/attachment.html>
Timo Juhani Lindfors
2009-Nov-18 12:07 UTC
[LLVMdev] lli -force-interpreter complains about external function
Nick Lewycky <nicholas at mxc.ca> writes:> Thanks for the reminder. I recall looking at the patch but I didn't > apply it at the time because I couldn't figure out why the code above > it used errs() in one case and llvm_report_error in another.What was the reason? (I think I too wondered that.)
Seemingly Similar 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