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

Re: PIE and static libraries



Hi Markus,

2016-09-12 8:51 GMT+02:00 Markus Wanner <markus@bluegap.ch>:
> On 09/12/2016 01:47 AM, Bálint Réczey wrote:
>> I have opened a bug to encourage PIC for static libraries in Policy, too.:
>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837478
>
> Thanks, cool.
>
> Is there any specific reason for not mentioning -fPIE in that request?
> That seems like a good middle-ground for static libraries.
>
> Reading up on the subject so far, I got the impression that most static
> libraries should be built with PIE, but not necessarily PIC (to allow
> building PIE(xecutable)s, but discourage creating shared libraries from
> those static ones.)

I don't see why should not we encourage using static libs in shared libs
and recommending PIC would also simplify the currently mandated build process:

10.2 Libraries
... (paragraph about shared libs requiring PIC)

As to the static libraries, the common case is not to have relocatable
code, since there is no benefit, unless in specific cases; therefore the
static version must not be compiled with the -fPIC flag. Any exception
to this rule should be discussed on the mailing list
debian-devel@lists.debian.org, and the reasons for compiling with the
-fPIC flag must be recorded in the file README.Debian. [86]

In other words, if both a shared and a static library is being built,
each source unit (*.c, for example, for C files) will need to be
compiled twice, for the normal case.
...

>
> To be honest, I didn't really check any use-case other than
> libsimgear-dev, which I'm concerned about.

There is a (still growing:-)) list in here which includes other PIE
releated issues:
https://udd.debian.org/cgi-bin/bts-usertags.cgi?tag=pie-bindnow-20160906&user=balint%40balintreczey.hu

Cheers,
Balint


Reply to: