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

Wink Saville wink at saville.com
Mon Feb 27 20:43:34 PST 2006


Chris Lattner wrote:
> 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. 
This didn't work for me:
llvm-ld -o t1.app t1.bc t1.a -L/opt/llvm-1.6/llvm-gcc/lib/ -lcrtend.a

I get two warning's about library 'crtend' missing

> Alternatively, instead of using llvm-ld, just use gccld to link like 
> this:
>
> llvm-gcc -o t1.app t1.bc t1.a
>
Yes this works, but not native
> ... 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.
Yes this works and doesn't generate the script but since I'm using an 
amd64 with linux the result doesn't run because I need the -m32.

>
> -Chris
>
Actually, the point of the above was to understand how the flow native 
and to see what difficulties I ran into.

Is it a bug that I get the "llvm-ld: warning: Cannot find library 
'crtend'"? If so, is it likely to be in llvm code and would it be 
something you'd let a neophyte to track down?

Wink





More information about the llvm-dev mailing list