ppc64le and 32-bit LE userland compatibility
Tue Jun 2 02:03:33 GMT 2020
On Tue, Jun 2, 2020, at 03:42, Segher Boessenkool wrote:
> Hi Joseph,
> On Mon, Jun 01, 2020 at 09:28:25PM +0000, Joseph Myers wrote:
> > On Fri, 29 May 2020, Will Springer via Binutils wrote:
> > > Hey all, a couple of us over in #talos-workstation on freenode have been
> > > working on an effort to bring up a Linux PowerPC userland that runs in 32-bit
> > > little-endian mode, aka ppcle. As far as we can tell, no ABI has ever been
> > > designated for this (unless you count the patchset from a decade ago ), so
> > > it's pretty much uncharted territory as far as Linux is concerned. We want to
> > > sync up with libc and the relevant kernel folks to establish the best path
> > > forward.
> > As a general comment on the glibc side of things, if this is considered
> > like a new port, and it probably is, the same principles that apply to new
> > ports apply here.
> > There's a general discussion at
> > <https://sourceware.org/glibc/wiki/NewPorts>, although much of that is
> > only applicable when adding new CPU architecture support. More specific
> > points include that new 32-bit ports should default to 64-bit time and
> > file offsets from the start, with no support for 32-bit time or offsets
> > (meaning that if you want to use this with some kind of library call
> > translation, the library call translation will need to deal with
> > corresponding type size conversions).
> Either that, or use the same as BE 32-bit PowerPC Linux, I'd say (it
> won't make things worse, and if it is easier?) But preferably the
> newer, better, thing of course :-)
> > And a new port should not be added
> > that uses the IBM long double format. You can use IEEE binary128 long
> > double, possibly with an ABI similar to that used on powerpc64le, or can
> > use long double = double, but should not support IBM long double, and
> > preferably should only have one long double format rather than using the
> > glibc support for building with different options resulting in functions
> > for different long double formats being called.
> You cannot use IEEE QP float ("binary128") here, but more on that in a
> later post.
> (I so very much agree about the problems having more than one long
> double format -- on the other hand, you'll just share it with BE, and
> with the existing powerpcle-linux (sup)port).
Well, it'd be nice to use the opportunity to ditch the IBM long doubles altogether, since these get in the way for me in various places (for instance, GCC still can't constant-fold them, which breaks on constexpr in C++, as well as makes it impossible to e.g. enable the runtime/standard library for GDC in GCC as that heavily relies on the `real` type in D, which maps directly to `long double` and druntime/phobos heavily relies on constant folding of the `real` type being functional; there are also assorted libraries and applications in the common userland that don't like the IBM format for one reason or another)
That said, that's also problematic:
1) ppc64le is going to newly use IEEE754 binary128, so we're all good there - baseline mandates VSX, so at least passing them is fine, which is the important thing (actual binary128 instructions came with ISA 3.0 but that can be detected at runtime, at least in glibc) - ibm128 is then implemented via symvers/compat, which is fine.
2) ppc64 for now uses IBM 128-bit long double, so it's problematic. I don't care about ELFv1, as it's legacy and has tons of drawbacks on its own, and there's a whole legacy ecosystem relying on it; that said, a new ELFv2 port (let's say, with ld64.so.3 dynamic linker) could easily default to another long double format, without worrying about compat - I propose this format to be binary64, as it's already used by musl on BE/64 (allows projects such as `gcompat` to work) and thus is already implemented in all toolchains we care about and can easily be flipped on, and is fully compatible with all CPUs that can run ppc64 code, even without VMX/VSX
3) ppcle would be a new port (let's say ld.so.2), so it could default to a new format; binary64 would be good
4) that leaves ppc32/BE, which would be the only outlier - while I could probably implement compat in much the same way as ppc64le does with binary128 (bump symvers for math symbols, leave older symvers for existing binaries, change defaults), this would be divergent from the existing port; glibc/IBM probably won't want to switch this, and while I would definitely like to, maintaining a divergent downstream patchset seems non-ideal. There is some basis for this - glibc did use to use binary64 on ppc32 and ppc64 BE in the past, and the compatibility symbols are still there under the old symvers, but not quite sure what to do there.
More information about the Libc-alpha