On Tue, Jun 8, 2021 at 7:16 AM Richard Purdie <richard.purdie@linuxfoundation.org> wrote:
> > There were specific issues with gcc 4.8 and 4.9 which required separate sstate. Do we
> > know which gcc version switched the default and can we force older gcc's to use the
> > same default or does it not work? I'm wondering if we could split off a "nopic" verison
> > of sstate for example for the older gccs?
> >
> gcc 6 introduced an --enable-default-pie configure option, but I'm not exactly sure where
> between Ubuntu 16.04 and Ubuntu 18.04 they picked that configure option up.  Since packages
> based on the older gcc already exist in sstate, I think we would have to force the newer
> behavior on each affected package.
>
> I realize we can just swizzle the compiler flags on the affected packages to make things happy,
> but it seemed like this approach had at least been considered before, so I thought I would at least
> get some feedback.

As Andrea points out, we did fix this with a global include file which should have
handled the issue. Are you using a release which doesn't have that or not using
the include through your own custom distro?

Yes indeed, nice find.  bitbake -e confirms I'm including uninative-flags.inc.  I do think this is exactly the
same issue, but there's a different set of dependencies involved in my chain.  As someone suggested earlier,
I can force -fPIE on the packages where this is a problem, so I could of course do something similar for those
packages.

But I still feel like there's an underlying uninative limitation that's not being addressed, or highlighted.  For example,
the SSTATE_MIRRORS documentation seems to imply that differentiating between uninative based on native gcc
version is the normal/correct behavior, even though it's clear to me now that the example was chosen specifically
for the 4.8/4.9 issue, not just the general case.

"When pointing to sstate build artifacts on another machine that uses a different GCC version for native builds,
you must configure SSTATE_MIRROR with a regular expression that maps local search paths to server paths.
The paths need to take into account NATIVELSBSTRING set by the uninative class."
 - https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#var-SSTATE_MIRRORS

But I suppose even similar versions of gcc across different supported distros could be configured differently.
For example, warrior claims support for Ubuntu 16.04, 18.04, and Fedora 28, but only Ubuntu 18.04 seems to
use --enable-default-pie based on gcc -v.  (Even newer Fedoras seem to not use this flag.)

I guess we could have a "nopic" split like you suggested.  Or maybe uninative itself should be hashed against
the native gcc configure args and version, since version by itself also doesn't seem to be sufficient based on the
Fedora example above.  Neither one of those sounds particularly appealing the more I think about it, so maybe
I'll just opt for fixing the packages like we've done for binutils-native.