[LLVMdev] Using llvm-gcc with a simple program and the '-c' option

Chris Lattner sabre at nondot.org
Mon Feb 27 12:55:27 PST 2006


On Sun, 26 Feb 2006, Wink Saville wrote:
> I then do the following in my makefile:
>
> llvm-gcc -c t1.c -o t1.bc
> llvm-gcc -c t1sub1.c -o t1sub1.bc
> llvm-gcc -c t1sub2.c -o t1sub2.bc
> llvm-ar r t1.a t1sub1.bc t1sub2.bc
> llvm-ar: creating t1.a
> llvm-ld -o t1.app t1.bc t1.a /opt/llvm-1.6/llvm-gcc/lib/libcrtend.a
> llvm-ld: warning: Cannot find library 'crtend'

Try passing "-L/opt/llvm-1.6/llvm-gcc/lib/ -lcrtend" to llvm-ld. 
Alternatively, instead of using llvm-ld, just use gccld to link like this:

llvm-gcc -o t1.app t1.bc t1.a

... which should work.

> llc t1.app.bc -o t1.app.s
> gcc -m32 t1.app.s -o t1

If you want a native app, try this:

llvm-gcc -o t1.app t1.bc t1.a -Wl,-native

... which will invoke llc and the assembler for you.  This will also fix 
the "script + bc" issue.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-dev mailing list