Hi, I have tried another way: ar rcs libsysdeputil.a sysdeputil.o gccld seems to recognize the file type. However, it stills find unresoved symbols which are actually the functions in sysdeputil.o (can be find out with `nm libsysdeputil.a`) The problem disappears if native gcc/ld tool chain is used. As another test, main.c: ----------------- extern void foo(); int main() { foo(); return 0; } ---------------- foo.c --------------- #include <stdio.h. void foo() { printf("hello\n"); return; } ---------------- And the command lines: llvm-gcc -c -o main.o main.c gcc -o foo.o foo.c ar rcs libfoo.a foo.o llvm-gcc -Wl,-native main.o -L. -lfoo It's *OK* Thanks in advance for solving my problem. :) And I personally think it may possiblely puzzle other users, maybe it deserves its place in FAQ or in man page for LLVM. On Friday 02 June 2006 13:13, Chris Lattner wrote:> On Fri, 2 Jun 2006, Nai Xia wrote: > > The Makefile is sth like this: > > > > vsftpd: $(OBJS) > > gccld -r -native -o vsftpd.o $(OBJS) -L/home/xianai/my_projects/llvm/cfrontend/x86/llvm-gcc/lib/ -lcrtend > > gcc -o vsftpd vsftpd.o sysdeputil.o `./vsf_findlibs.sh` > > > > > > But the gcc/ld still cannot find the reference to __main. > > Do I have to compile crtend to native to solve this problem? > > gccld -r doesn't work with -native. Also, you do need to link in crtend, > which doesn't happen with -r, only "producing an executable mode" links in > libraries. > > -Chris >-- Regards, Nai
On Fri, 2 Jun 2006, Nai Xia wrote:> And the command lines: > > llvm-gcc -c -o main.o main.c > gcc -o foo.o foo.c > ar rcs libfoo.a foo.o > llvm-gcc -Wl,-native main.o -L. -lfoo > > It's *OK* > > Thanks in advance for solving my problem. :) > And I personally think it may possiblely puzzle other users, > maybe it deserves its place in FAQ or in man page for LLVM.I agree that this is an ugly issue. You've basically fallen into the "llvmgcc3 doesn't work the way a normal compiler does" problem. If you use llvmgcc4, it is completely transparent, and works just like a native compiler, unless you provide the -emit-llvm switch. If you'd like for this stuff to work, I'd suggest *not* using the gccld "-native*" switches. They are really only built to work when the whole program is compiled with LLVM (ok, you can have native libraries, but no native .o files). If you'd like to link native .o files together with LLVM .o files, you should run llc/as/ld directly on the LLVM code to do things manually. -Chris -- http://nondot.org/sabre/ http://llvm.org/
I see. Thanks :) On Saturday 03 June 2006 01:37, Chris Lattner wrote:> On Fri, 2 Jun 2006, Nai Xia wrote: > > And the command lines: > > > > llvm-gcc -c -o main.o main.c > > gcc -o foo.o foo.c > > ar rcs libfoo.a foo.o > > llvm-gcc -Wl,-native main.o -L. -lfoo > > > > It's *OK* > > > > Thanks in advance for solving my problem. :) > > And I personally think it may possiblely puzzle other users, > > maybe it deserves its place in FAQ or in man page for LLVM. > > I agree that this is an ugly issue. You've basically fallen into the > "llvmgcc3 doesn't work the way a normal compiler does" problem. If you > use llvmgcc4, it is completely transparent, and works just like a native > compiler, unless you provide the -emit-llvm switch. > > If you'd like for this stuff to work, I'd suggest *not* using the gccld > "-native*" switches. They are really only built to work when the whole > program is compiled with LLVM (ok, you can have native libraries, but no > native .o files). If you'd like to link native .o files together with > LLVM .o files, you should run llc/as/ld directly on the LLVM code to do > things manually. > > -Chris >-- Regards, Nai
Possibly Parallel Threads
- [LLVMdev] Compiling natively vsftp with LLVM
- [LLVMdev] Compiling natively vsftp with LLVM
- [LLVMdev] Compiling natively vsftp with LLVM
- [LLVMdev] Revised patch to make gccld link native .so's
- [LLVMdev] [lld] Handling multiple -init/-fini command line options