hi, I compile a pthread program using llvmgcc, but when i run pthread.ll, it show: ------------------ [yue at RH9 test]$ llvmgcc pthread.c -o pthread.ll [yue at RH9 test]$ ls pthread pthread.c pthread.ll pthread.ll.bc [yue at RH9 test]$ ./pthread.ll Creating thread 0 WARNING: Cannot resolve fn 'pthread_create' using a dummy noop function instead! ERROR; return code from pthread_create() is -1073745164 [yue at RH9 test]$ -------------------- how to solve the problem? yueqiang 2003/12/24
On Tue, 23 Dec 2003, Kevin Gibbs wrote:> Try > llvmgcc pthread.c -o pthread.ll -pthread > > You have to link in the pthreads library, and I believe -pthread is all you > need on a redhat 9 box.Yup, in theory this should work. However, in practice it looks like it doesn't, on redhat 8 at least. The problem is that (in RH8) /usr/lib/libpthread.so is not actually a library, it's a linker script. Because of this you might need to edit the script generated by gccld (the pthread.ll file in your case) to pass '--load libpthread.so.0' into lli before the $0.bc argument. This should give you something like this: --- #!/bin/sh lli \ --load=/lib/libpthread.so.0 \ $0.bc $* --- I think that will work. If it doesn't, please let me know. You might have to adjust the .so file name to be whatever the linker script says, if necessary. -Chris> > -----Original Message----- > > From: llvmdev-admin at cs.uiuc.edu [mailto:llvmdev-admin at cs.uiuc.edu] On > > Behalf Of yue > > Sent: Tuesday, December 23, 2003 11:43 PM > > To: llvmdev at cs.uiuc.edu > > Subject: [LLVMdev] pthread? > > > > hi, > > > > I compile a pthread program using llvmgcc, but when i run pthread.ll, it > > show: > > ------------------ > > [yue at RH9 test]$ llvmgcc pthread.c -o pthread.ll > > [yue at RH9 test]$ ls > > pthread pthread.c pthread.ll pthread.ll.bc > > [yue at RH9 test]$ ./pthread.ll > > Creating thread 0 > > WARNING: Cannot resolve fn 'pthread_create' using a dummy noop function > > instead! > > ERROR; return code from pthread_create() is -1073745164 > > [yue at RH9 test]$ > > -------------------- > > how to solve the problem? > > > > yueqiang > > 2003/12/24 > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >-Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
I try to run lli with "--load=/lib/libpthread.so", but it shows: --------------------------------------------------- [yue at RH9 test]$ ./pthread.ll Error opening '/lib/libpthread.so.0': /lib/libpthread.so.0: symbol _errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference -load request ignored. Creating thread 0 WARNING: Cannot resolve fn 'pthread_create' using a dummy noop function instead! ERROR; return code from pthread_create() is -1073747260 ---------------------------------------------------- then try to run with "--load=/usr/lib/libpthread.so", it shows: -------------------------------------------------- [yue at RH9 test]$ ./pthread.ll Error opening '/usr/lib/libpthread.so': /usr/lib/libpthread.so: invalid ELF header -load request ignored. Creating thread 0 WARNING: Cannot resolve fn 'pthread_create' using a dummy noop function instead! ERROR; return code from pthread_create() is -1073745212 -------------------------------------------------------- yue wrote:> hi, > > I compile a pthread program using llvmgcc, but when i run pthread.ll, > it show: > ------------------ > [yue at RH9 test]$ llvmgcc pthread.c -o pthread.ll > [yue at RH9 test]$ ls > pthread pthread.c pthread.ll pthread.ll.bc > [yue at RH9 test]$ ./pthread.ll > Creating thread 0 > WARNING: Cannot resolve fn 'pthread_create' using a dummy noop > function instead! > ERROR; return code from pthread_create() is -1073745164 > [yue at RH9 test]$ > -------------------- > how to solve the problem? > > yueqiang > 2003/12/24 >
On Wed, 24 Dec 2003, yue wrote:> I try to run lli with "--load=/lib/libpthread.so", but it shows: > --------------------------------------------------- > [yue at RH9 test]$ ./pthread.ll > Error opening '/lib/libpthread.so.0': /lib/libpthread.so.0: symbol > _errno, version GLIBC_2.0 not defined in file libc.so.6 with link time > reference > -load request ignored.This is strange, I have no idea why this is happening. Maybe you have mixed versions of different libraries installed on your system? Maybe your compiled version of LLI is not up-to-date? I was able to use 'lli -load=libpthread.so.0 a.out.bc' and that worked for me, note the lack of an absolute path.> then try to run with "--load=/usr/lib/libpthread.so", it shows: > -------------------------------------------------- > [yue at RH9 test]$ ./pthread.ll > Error opening '/usr/lib/libpthread.so': /usr/lib/libpthread.so: invalid > ELF headerThat's because it is trying to use the linker script as a shared object and getting unhappy about it. It would be nice if LLVM supported linker scripts better, precisely to make these sorts of problems disappear, but noone has tackled that yet. Actually, while I'm thinking about it, I should throw a disclaimer in here. The JIT does not yet have locking in place to protect its internal data structures from multiple threads. Because of this you might get 'recursive compilation detected' aborts when you finally get your threaded program to load the correct libraries. As a work-around, you can compile the program with the 'llc' utility to native code, link it with the pthreads libraries, then execute it. Another advantage of this, is that it lets the GCC compiler driver parse the linker script and figure out what to do with it. To use this, try something like this: $ llvmgcc foo.c -o foo # or however you compile your program to .bc $ llc foo.bc -o foo.s $ gcc -pthread foo.s -o foo $ ./foo -Chris> yue wrote: > > > hi, > > > > I compile a pthread program using llvmgcc, but when i run pthread.ll, > > it show: > > ------------------ > > [yue at RH9 test]$ llvmgcc pthread.c -o pthread.ll > > [yue at RH9 test]$ ls > > pthread pthread.c pthread.ll pthread.ll.bc > > [yue at RH9 test]$ ./pthread.ll > > Creating thread 0 > > WARNING: Cannot resolve fn 'pthread_create' using a dummy noop > > function instead! > > ERROR; return code from pthread_create() is -1073745164 > > [yue at RH9 test]$ > > -------------------- > > how to solve the problem? > > > > yueqiang > > 2003/12/24 > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >-Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/