-fPIC and x86_64

Quentin Spencer qspencer at ieee.org
Tue Aug 23 20:49:46 UTC 2005


Ed Hill wrote:

>On Tue, 2005-08-23 at 14:04 -0600, Orion Poplawski wrote:
>  
>
>>Jakub Jelinek wrote:
>>    
>>
>>>But in that case not just for x86_64, but for all architectures.
>>>If the library is small and is expected to be only linked into small shared
>>>libraries, -fpic can be used instead.
>>>What small means is architecture dependent, on i386/x86_64 -fpic/-fPIC are
>>>identical, on other arches it can mean e.g. 4K got entries limit or similar.
>>>      
>>>
>>But I don't know what shared libraries it will be link to, so shouldn't 
>>I use -fPIC to be safe?  Or are there other drawbacks?
>>    
>>
>
>Hi Orion,
>
>According to the GCC docs, -fpic and -fPIC are basically identical in
>i386 systems since they have no inherent limits on the GOT size.  There
>is, however, a limit on PowerPC systems!  So, in the interest of not
>wasting time on these fiddly annoyances that will only potentially bite
>Fedora ppc users, I'd skip -fpic and go straight to -fPIC.  Please!  ;-)
>
>And I think it would be nice if adding -fPIC was strongly recommended
>for all *.a libs since people almost inevitably want to use them (at
>some later date) to build shared libs.
>  
>

While we're on this topic, I have a related question. I've been looking 
at the Debian version of a package I'm working on, and in their 
buildscripts they build a static library without -fPIC and then rebuild 
with -fPIC for the shared library. It seems like unnecessary extra 
compilation. Is there any possible performance loss (or any other side 
effect) that can come from using -fPIC?

-Quentin




More information about the Fedora-maintainers mailing list