Mailing List Archive

What does the pic USE flag do these days?
Hi,

One of the differences between gentoo standard and hardened profiles is
the pic use flag.

I wonder what it does and if it has any meaning these days. From what I
understand in any modern-day Linux system position independent code
(pic) is always used, as we have ASLR and pie executables (in Gentoo
since 17.0 profiles).

In many cases it seems to disable assembly optimizations, often with
comments indicating that the assembly is not "pic friendly" (e.g. gzip
useflag description says "disable optimized assembly code that is not
PIC friendly").

If the flag just disables assembly optimizations then I wonder if it
should be renamed (or if we need it at all - in case these assembly
optimizations have no downsides).


--
Hanno Böck
https://hboeck.de/

mail/jabber: hanno@hboeck.de
GPG: FE73757FA60E4E21B937579FA5880072BBB51E42
Re: What does the pic USE flag do these days? [ In reply to ]
On Wed, 19 Sep 2018 09:24:27 +0200
Hanno Böck <hanno@hboeck.de> wrote:

> If the flag just disables assembly optimizations then I wonder if it
> should be renamed (or if we need it at all - in case these assembly
> optimizations have no downsides).

Many (all?) of the ebuilds with this flag do indeed only disable
assembly snippets, and most of them only do this on 32-bit x86 (gzip
being the prominent exception).

I haven't looked at any code yet, but I think it could be a good idea
to just remove the flag (and hard-wire it to true in the cases where it
only affects x86-32, examine the situation a bit further for gzip).

Cheers,
Luis Ressel
Re: What does the pic USE flag do these days? [ In reply to ]
On Fri, 21 Sep 2018 00:16:48 +0100
Luis Ressel <aranea@aixah.de> wrote:

> On Wed, 19 Sep 2018 09:24:27 +0200
> Hanno Böck <hanno@hboeck.de> wrote:
>
> > If the flag just disables assembly optimizations then I wonder if it
> > should be renamed (or if we need it at all - in case these assembly
> > optimizations have no downsides).
>
> Many (all?) of the ebuilds with this flag do indeed only disable
> assembly snippets, and most of them only do this on 32-bit x86 (gzip
> being the prominent exception).

And ffmpeg and mesa.

In ffmpeg the flag description says:
"Force shared libraries to be built as PIC (this is slower)"

Which confuses me - I thought shared libraries are always PIC.

It looks to me these are all historic leftovers, but I'd like to
understand it better before I open bugs asking for removal of these
flags.

--
Hanno Böck
https://hboeck.de/

mail/jabber: hanno@hboeck.de
GPG: FE73757FA60E4E21B937579FA5880072BBB51E42
Re: What does the pic USE flag do these days? [ In reply to ]
? ??, 27/09/2018 ? 15:45 +0200, Hanno Böck ?????:
> On Fri, 21 Sep 2018 00:16:48 +0100
> Luis Ressel <aranea@aixah.de> wrote:
>
> > On Wed, 19 Sep 2018 09:24:27 +0200
> > Hanno Böck <hanno@hboeck.de> wrote:
> >
> > > If the flag just disables assembly optimizations then I wonder if
> > > it
> > > should be renamed (or if we need it at all - in case these
> > > assembly
> > > optimizations have no downsides).
> >
> > Many (all?) of the ebuilds with this flag do indeed only disable
> > assembly snippets, and most of them only do this on 32-bit x86
> > (gzip
> > being the prominent exception).
>
> And ffmpeg and mesa.
>
> In ffmpeg the flag description says:
> "Force shared libraries to be built as PIC (this is slower)"
>
> Which confuses me - I thought shared libraries are always PIC.
>
> It looks to me these are all historic leftovers, but I'd like to
> understand it better before I open bugs asking for removal of these
> flags.

IIRC the main issue was a limited general purpose register set on x86
architecture.
https://wiki.gentoo.org/wiki/Hardened/Toolchain#Issues_with_PIEs

"Occasionally application code will fail to compile with -fPIE. If this
happens it is usually down to non-position-independent assembler code,
and is most prevelant on X86 which has a limited general purpose
register set."

I guess a lot of programs was fixed since then. For example currently I
don't see any problems when building mesa with USE=-pic on x86_32.