fPIC

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

fPIC

Ryan M. Lefever
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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: fPIC

Bill Wendling
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
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: fPIC

Anton Korobeynikov-2
In reply to this post by Ryan M. Lefever
Hello, Ryan

> Does llvm-gcc support the -fPIC option?  I am using LLVM on both 32 bit
> linux and 64 bit linux, if that matters.
Yes, PIC works without any problems on both

>
> Regards,
> Ryan
>
> --
> Ryan M. Lefever  [http://www.crhc.uiuc.edu/~lefever/index.html]
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: fPIC

Ryan M. Lefever
In reply to this post by Bill Wendling
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
>> [hidden email]         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: fPIC

Ryan M. Lefever
After looking through the README for the llvm gcc frontend, it says:
-----------------------------------------------------------------------
X86-64/AMD-64/EM64-T for any OS other than Darwin/Mac OS X:

When targeting non-darwin X86-64/AMD-64/EM64-T, configure with
--disable-shared.  The LLVM X86-64 backend doesn't support PIC codegen on
non-darwin systems yet.  If you get a build error, try configuring with
--disable-multilib.
-----------------------------------------------------------------------

Indeed, when I built the frontend I had to use the --disable-shared
option.  So, I guess that is my problem.  The excerpt above seams to
indicate that llvm does not support PIC generation on 64 bit linux.  If
I'm missing something, please let me know.

Regards,
Ryan


Ryan M. Lefever wrote:

> 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
>>> [hidden email]         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> _______________________________________________
>> LLVM Developers mailing list
>> [hidden email]         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: fPIC

Anton Korobeynikov-2
Hello, Ryan

> After looking through the README for the llvm gcc frontend, it says:
2.4 Release should be ok - I think I fixed remaining issues. If this
still happens for you - this is clearly a bug, please fill PR.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev