[LLVMdev] llvm-ld support of native libraries
Reid Spencer
rspencer at reidspencer.com
Mon May 7 22:10:12 PDT 2007
On Mon, 2007-05-07 at 23:45 -0500, Ryan M. Lefever wrote:
> What is the current status of llvm-ld's support of native libraries?
It should be working. We've fixed some issues with correct detection of
object/archive/shared object files in the last few weeks.
> I
> have a bytecode file that needs to link against librt.so. So, I ran:
>
> llvm-ld -native -o x.exe x.bc -L/usr/lib64 -lrt
>
> and I get the following error:
>
> /tmp/ccB7DGu1.o(.text+0x1a3): In function `main':
> : undefined reference to `clock_gettime'
> /tmp/ccB7DGu1.o(.text+0x6d8): In function `main':
> : undefined reference to `clock_gettime'
> collect2: ld returned 1 exit status
Have you verified that librt.so is in /usr/lib64 and that it contains
clock_gettime? This looks like a standard undefined reference message
meaning you haven't supplied sufficient arguments to llvm-ld to link the
program. Does a similar command line with gcc work?
>
> Is that error occurring because llvm-ld does not support native
> libraries.
No. Its occurring because the clock_gettime symbol can't be found. Note
that llvm-ld invokes the native linker (via gcc) to do the actual native
linking.
> I am able to use llc to turn x.bc into native assembly and
> gcc to link the natively assembly against librt.so to get an executable,
> but I was going to use the llvm native backend if possible.
That's another way to do it, but the way you described above should work
as well and should, in fact, do the same thing. That is, when you link
as given above, llvm-ld will:
1. convert x.bc into x.s via llc
2. assemble llc using gcc (which punts it to gas)
3. link using gcc with something like gcc -o x.exe x.o -L/usr/lib64 -lrt
Reid.
>
> Regards,
> Ryan
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list