[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Don't use -fpic if library is too specialized?

From: Boris
Subject: Re: Don't use -fpic if library is too specialized?
Date: Thu, 28 Sep 2006 13:56:11 +0300

Paul Pluzhnikov wrote:
> "Boris" <> writes:
>> I'm reading as much about PIC as I can find in order to understand
>> if I should compile a library here with or without -fpic. After all
>> I tend to believe that in my case it's better not to use -fpic as 1)
>> for this library performance is critical and as 2) the library is
>> too specialized that it will be used by all kind of different
>> applications.
> Are you building a shared library, or an archive.

I'm building a shared library.

> If shared, note that on some platforms (e.g. Linux/x86_64) you simply
> can't build a DSO from non-PIC code (i.e. you'll have no choice).

Does this mean that g++ automatically compiles PIC code or that it aborts 
with an error unless you pass the option -fpic?

> [...]
>> If I assume that at any
>> time there is probably only one program running which makes use of
>> this library PIC doesn't make much sense
> If your code is statically linked into the main executable, you
> don't gain anything [1] from PIC even if there are multiple copies of
> the program running, or multiple programs that have your library
> linked in.

If I'm building a shared library and there is only one program running my 
library is linked in I don't gain anything either but have a better 
performance with non-PIC code - is this correct?

Thanks for your help,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]