Mailing List Archive

Best way to handle custom gcc patches for a CPU errata?
Hi!

I'm working on Linux for the Wii U [1], sporting the "Espresso" - a CPU
that unfortunately has an errata, requiring some extra instructions to
be added to atomic operations. I would like to build Gentoo with a
patched compiler that applies this workaround.

I've drafted up patches for gcc (and glibc) that apply the relevant
changes [2]. Right now they are enabled by setting -mcpu=espresso. There
is a similar errata in the PowerPC 405 that is handled the same way
upstream.

I am wondering what the best way to set this up for regular use is? I've
been using a custom target triple (powerpc-espresso-linux-gnu) and
EXTRA_ECONF="--with-cpu=espresso" (setting the default -mcpu), but this
seems suboptimal - it's very easy to miss the extra_econf when e.g. gcc
gets pulled in as a dep of some other package. I've made things work
with package.use flags [3] but it kinda feels like a kludge - is there a
better option?

My end goal is to ship a Gentoo image out to users that will allow them
to either emerge new packages on-device or target with crossdev/binpkgs.

I can think of a few other strategies:
- Apply the patches but not the EXTRA_ECONF, possibly using a generic
target triple (powerpc-unknown-linux-gnu) and ask users nicely to always
keep -mcpu=espresso in their CFLAGS. I worry that packages built without
that flag will cause data corruption, though.
- Modify the patches to unconditionally apply the workaround regardless
of -mcpu. Such a compiler would produce suboptimal (but presumably not
broken) code for all other targets.
- Find some way in the gcc build system to make
powerpc-espresso-linux-gnu synonymous with --with-cpu=espresso, since
Gentoo already handles the custom target triple just fine.

I would really appreciate any advice regarding the best approach for me
to take here. I'm a bit newer to Gentoo but it feels like a great fit
for this situation!

Ta,
~ashquarky

[1] https://linux-wiiu.org
[2] https://gitlab.com/linux-wiiu/smp-patches
[3] https://gitlab.com/linux-wiiu/smp-patches#using-gentoo