[LLVMdev] fPIC

Ryan M. Lefever lefever at crhc.uiuc.edu
Wed Nov 5 19:14:00 PST 2008


On my 32 bit linux box, things seam to work find, but on my 64 bit linux 
box I am getting problems.

I have the following c file (lib.c):
--------------------------------
#include <stdio.h>

void libmethod(){
   printf("libmethod()\n");
}
-------------------------------

I tried to get a shared library using the following commands:

llvm-gcc -emit-llvm -Wall -fPIC -c -o lib.opt.bc lib.c -O3

llvm-ld -native -Xlinker=-shared -Xlinker=-Wl,-soname,libmylb.so -o 
libmylb.so lib.opt.bc

The llvm-ld command fails with the following message:

/usr/bin/ld: /tmp/ccWOiWYc.o: relocation R_X86_64_32S against `a local 
symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/ccWOiWYc.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
llvm-ld:

Does anyone know what is going on?  Do I need to specify different options?

Thanks,
Ryan

Bill Wendling wrote:
> Yup!
> 
> -bw
> 
> On Nov 3, 2008, at 7:39 PM, Ryan M. Lefever wrote:
> 
>> Does llvm-gcc support the -fPIC option?  I am using LLVM on both 32  
>> bit
>> linux and 64 bit linux, if that matters.
>>
>> Regards,
>> Ryan
>>
>> -- 
>> Ryan M. Lefever  [http://www.crhc.uiuc.edu/~lefever/index.html]
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> _______________________________________________
> 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