Discussion:
[musl] [PATCH] powerpc64le: Add single instruction math functions
David Edelsohn
2017-06-21 14:53:13 UTC
Permalink
The following two patches are a start at single instruction math
functions for PowerPC64 architecture. Although PPC64LE Linux and
ELFv2 ABI require Power8 as the minimum architecture, I have added
guards that fallback to C code for earlier architectures.

Thanks, David
Rich Felker
2017-06-23 19:35:33 UTC
Permalink
Post by David Edelsohn
The following two patches are a start at single instruction math
functions for PowerPC64 architecture. Although PPC64LE Linux and
ELFv2 ABI require Power8 as the minimum architecture, I have added
guards that fallback to C code for earlier architectures.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64, and I
think we have users of both (people running it on old powerbooks,
etc.).

Am I reading correctly that sqrt, fma, and fabs are available even in
the lowest powerpc64 ISA, and don't need preprocessor conditionals?

Rich
David Edelsohn
2017-06-23 19:53:56 UTC
Permalink
Post by Rich Felker
Post by David Edelsohn
The following two patches are a start at single instruction math
functions for PowerPC64 architecture. Although PPC64LE Linux and
ELFv2 ABI require Power8 as the minimum architecture, I have added
guards that fallback to C code for earlier architectures.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64, and I
think we have users of both (people running it on old powerbooks,
etc.).
Am I reading correctly that sqrt, fma, and fabs are available even in
the lowest powerpc64 ISA, and don't need preprocessor conditionals?
fabs and fma are part of the base ISA for Power processors that
include floating point support. fsqrt originally was optional feature
in the distant past (General Purpose group of optional instructions),
but is required in the ISA for Power processors.

Thanks, David
A. Wilcox
2017-06-24 00:46:38 UTC
Permalink
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
The following two patches are a start at single instruction
math functions for PowerPC64 architecture. Although PPC64LE
Linux and ELFv2 ABI require Power8 as the minimum
architecture, I have added guards that fallback to C code for
earlier architectures.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64,
and I think we have users of both (people running it on old
powerbooks, etc.).
Am I reading correctly that sqrt, fma, and fabs are available
even in the lowest powerpc64 ISA, and don't need preprocessor
conditionals?
fabs and fma are part of the base ISA for Power processors that
include floating point support. fsqrt originally was optional
feature in the distant past (General Purpose group of optional
instructions), but is required in the ISA for Power processors.
Thanks, David
Chiming in as one of the heavy users/developers involved with musl/ppc.

I can confirm FSQRT exists on the oldest PPC64 chip I have - a 970FX
from 2003 - but it is indeed optional. (I didn't bother checking the
actual IBM chips because they're all on the higher end.) The Linux
kernel actually has support for emulating the instruction on PowerPC
chips where it wasn't implemented. See arch/powerpc/math-emu/fsqrt.c
in the kernel tree.

It depends on CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED (or
CONFIG_MATH_EMULATION_FULL), but most (all?) distros that ship PPC
kernels have that knob turned on, as far as I can tell.

So this should be safe. The worst case scenario is that distros would
need to twiddle a config knob in the kernel.

All the best,
- --arw

- --
A. Wilcox (awilfox)
Project Lead, Adélie Linux
http://adelielinux.org
Rich Felker
2017-06-24 00:55:39 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
The following two patches are a start at single instruction
math functions for PowerPC64 architecture. Although PPC64LE
Linux and ELFv2 ABI require Power8 as the minimum
architecture, I have added guards that fallback to C code for
earlier architectures.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64,
and I think we have users of both (people running it on old
powerbooks, etc.).
Am I reading correctly that sqrt, fma, and fabs are available
even in the lowest powerpc64 ISA, and don't need preprocessor
conditionals?
fabs and fma are part of the base ISA for Power processors that
include floating point support. fsqrt originally was optional
feature in the distant past (General Purpose group of optional
instructions), but is required in the ISA for Power processors.
Thanks, David
Chiming in as one of the heavy users/developers involved with musl/ppc.
I can confirm FSQRT exists on the oldest PPC64 chip I have - a 970FX
from 2003 - but it is indeed optional. (I didn't bother checking the
actual IBM chips because they're all on the higher end.) The Linux
kernel actually has support for emulating the instruction on PowerPC
chips where it wasn't implemented. See arch/powerpc/math-emu/fsqrt.c
in the kernel tree.
It depends on CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED (or
CONFIG_MATH_EMULATION_FULL), but most (all?) distros that ship PPC
kernels have that knob turned on, as far as I can tell.
So this should be safe. The worst case scenario is that distros would
need to twiddle a config knob in the kernel.
All the best,
Thanks for the feedback. If it ends up being problematic, but gcc has
a way to tell if -march is for a model with or without it, please feel
free to submit a patch to make the use conditional.

Rich
David Edelsohn
2017-06-24 03:05:08 UTC
Permalink
Note that I only added the optimizations to the "powerpc64" port, not
the "powerpc" port. The powerpc64 port only support PPC64LE Linux,
which does not include PPC970. The comments about emulation are not
relevant to the "powerpc64" port.

If someone wants to copy the support to "powerpc" and add the
additional tests, that's fine.

Thanks, David
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
The following two patches are a start at single instruction
math functions for PowerPC64 architecture. Although PPC64LE
Linux and ELFv2 ABI require Power8 as the minimum
architecture, I have added guards that fallback to C code for
earlier architectures.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64,
and I think we have users of both (people running it on old
powerbooks, etc.).
Am I reading correctly that sqrt, fma, and fabs are available
even in the lowest powerpc64 ISA, and don't need preprocessor
conditionals?
fabs and fma are part of the base ISA for Power processors that
include floating point support. fsqrt originally was optional
feature in the distant past (General Purpose group of optional
instructions), but is required in the ISA for Power processors.
Thanks, David
Chiming in as one of the heavy users/developers involved with musl/ppc.
I can confirm FSQRT exists on the oldest PPC64 chip I have - a 970FX
from 2003 - but it is indeed optional. (I didn't bother checking the
actual IBM chips because they're all on the higher end.) The Linux
kernel actually has support for emulating the instruction on PowerPC
chips where it wasn't implemented. See arch/powerpc/math-emu/fsqrt.c
in the kernel tree.
It depends on CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED (or
CONFIG_MATH_EMULATION_FULL), but most (all?) distros that ship PPC
kernels have that knob turned on, as far as I can tell.
So this should be safe. The worst case scenario is that distros would
need to twiddle a config knob in the kernel.
All the best,
- --arw
- --
A. Wilcox (awilfox)
Project Lead, Adélie Linux
http://adelielinux.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJZTbZrAAoJEMspy1GSK50UPQIQAJS//JXGNUSjHtlOsK2ngxTz
0lOFPDSMTJHmTTXVGJIfoM/Rw0NtAKO6I9+eBbi08eN+Bmh6swRDK+/WQeIft8xx
Ayyi0fCNFhrEFLCc/M+SE5cwSym2gD7o0XyjNGhi5OM4rqOCybHUzTk5KW2Yxoyr
MUG7tqFgXCX8LOkWauGDkAmr9A6NjCN6GZazR7ubrsqId7KRxPGUtZRNZhfl+/cQ
sR5TcTF1yy1Ify6D0wyHIJlIdQPE65i+L+lAr9FGQSNl/NdOQA56hRiijCLwhMNJ
GNSGS6xPMWX0I7bV/gas15CRmJZyNC5sc+5Gm61/wToHgsclYVWJNJ52NXfSEWCA
LzEBfZ+6xoZgKQqBDumGEPSRoaRp8sYTTv5mgmlMBs76mOvjyd8j1p9gYrfzFoPx
Th1EX/CAlgUq84f2Nx1MyDq47ukeJKjWEGfsJe3+yUHYYpENYIKYgvKfx01UGkqR
vx7Cshtz6zjhadruxWAkQ3oqEJwJOfbBXKCITUMuUxFLHK47Ij4yJ/VZaAwiasLn
9zcTEtsq+Iu4xj/drNNPzVm2KbHTDfcKaQynowvuOx9KgyOpv+UprDXr2Koi5SCD
5+jS26QzcflGOF6WLvY+pKbDO3l1GPRHc57MhPcjJVVdYWE2NoVbcq+BhYw9ljTq
KIiCkOVyagFRViWyrzvO
=eogy
-----END PGP SIGNATURE-----
Rich Felker
2017-06-24 03:32:39 UTC
Permalink
Post by David Edelsohn
Note that I only added the optimizations to the "powerpc64" port, not
the "powerpc" port. The powerpc64 port only support PPC64LE Linux,
which does not include PPC970. The comments about emulation are not
relevant to the "powerpc64" port.
If someone wants to copy the support to "powerpc" and add the
additional tests, that's fine.
The musl powerpc64 arch is for both little and big endian powerpc64
linux, and supports ppc970. It uses the "elfv2" abi for both, but does
not impose any mimimum isa level limit like the official elfv2 abi
docs mandate. Since we did not have any existing support for the
legacy abi traditionally used on big endian, and since we needed
something without double-double, the obvious clean choice was to use
the new abi for both, but there was (and is) interest in running on
older hardware than power8.

Rich
Post by David Edelsohn
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
The following two patches are a start at single instruction
math functions for PowerPC64 architecture. Although PPC64LE
Linux and ELFv2 ABI require Power8 as the minimum
architecture, I have added guards that fallback to C code for
earlier architectures.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64,
and I think we have users of both (people running it on old
powerbooks, etc.).
Am I reading correctly that sqrt, fma, and fabs are available
even in the lowest powerpc64 ISA, and don't need preprocessor
conditionals?
fabs and fma are part of the base ISA for Power processors that
include floating point support. fsqrt originally was optional
feature in the distant past (General Purpose group of optional
instructions), but is required in the ISA for Power processors.
Thanks, David
Chiming in as one of the heavy users/developers involved with musl/ppc.
I can confirm FSQRT exists on the oldest PPC64 chip I have - a 970FX
from 2003 - but it is indeed optional. (I didn't bother checking the
actual IBM chips because they're all on the higher end.) The Linux
kernel actually has support for emulating the instruction on PowerPC
chips where it wasn't implemented. See arch/powerpc/math-emu/fsqrt.c
in the kernel tree.
It depends on CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED (or
CONFIG_MATH_EMULATION_FULL), but most (all?) distros that ship PPC
kernels have that knob turned on, as far as I can tell.
So this should be safe. The worst case scenario is that distros would
need to twiddle a config knob in the kernel.
All the best,
- --arw
- --
A. Wilcox (awilfox)
Project Lead, Adélie Linux
http://adelielinux.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJZTbZrAAoJEMspy1GSK50UPQIQAJS//JXGNUSjHtlOsK2ngxTz
0lOFPDSMTJHmTTXVGJIfoM/Rw0NtAKO6I9+eBbi08eN+Bmh6swRDK+/WQeIft8xx
Ayyi0fCNFhrEFLCc/M+SE5cwSym2gD7o0XyjNGhi5OM4rqOCybHUzTk5KW2Yxoyr
MUG7tqFgXCX8LOkWauGDkAmr9A6NjCN6GZazR7ubrsqId7KRxPGUtZRNZhfl+/cQ
sR5TcTF1yy1Ify6D0wyHIJlIdQPE65i+L+lAr9FGQSNl/NdOQA56hRiijCLwhMNJ
GNSGS6xPMWX0I7bV/gas15CRmJZyNC5sc+5Gm61/wToHgsclYVWJNJ52NXfSEWCA
LzEBfZ+6xoZgKQqBDumGEPSRoaRp8sYTTv5mgmlMBs76mOvjyd8j1p9gYrfzFoPx
Th1EX/CAlgUq84f2Nx1MyDq47ukeJKjWEGfsJe3+yUHYYpENYIKYgvKfx01UGkqR
vx7Cshtz6zjhadruxWAkQ3oqEJwJOfbBXKCITUMuUxFLHK47Ij4yJ/VZaAwiasLn
9zcTEtsq+Iu4xj/drNNPzVm2KbHTDfcKaQynowvuOx9KgyOpv+UprDXr2Koi5SCD
5+jS26QzcflGOF6WLvY+pKbDO3l1GPRHc57MhPcjJVVdYWE2NoVbcq+BhYw9ljTq
KIiCkOVyagFRViWyrzvO
=eogy
-----END PGP SIGNATURE-----
A. Wilcox
2017-06-24 03:38:46 UTC
Permalink
Post by David Edelsohn
Note that I only added the optimizations to the "powerpc64" port,
not the "powerpc" port. The powerpc64 port only support PPC64LE
Linux, which does not include PPC970. The comments about emulation
are not relevant to the "powerpc64" port.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64, and I
think we have users of both (people running it on old powerbooks,
etc.).
These two statements contradict each other. Also, I have made a very
minimal big-endian build of musl for the ppc64 architecture, but I
haven't had any time to test it.

There was never a 64-bit PowerPC laptop that I am aware; the highest
spec PowerPC laptop would have been a Daystar with a 32-bit MPC7448.
However, IBM, Apple, Tyan, and a few other manufacturers have released
big-endian 64-bit PowerPC hardware in both workstation and server form.

Let us also not forget that LoPAPR[1] defines (at R1-2.7-1 in my copy,
version 1.1 dated 24 March 2016) that Power Architecture platforms
"must by default operate with Big-Endian addressing".

Are you aware of any little-endian specific code in musl/powerpc64? I
assume that libc-test would probably catch most of it when I am able
to run it, but until then, it would be nice to know if there is
anything I need to work on in the meantime.

Best,
- --arw


[1]: https://da.gd/LoPAPR

- --
A. Wilcox (awilfox)
Project Lead, Adélie Linux
http://adelielinux.org
David Edelsohn
2017-06-24 20:53:58 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Post by David Edelsohn
Note that I only added the optimizations to the "powerpc64" port,
not the "powerpc" port. The powerpc64 port only support PPC64LE
Linux, which does not include PPC970. The comments about emulation
are not relevant to the "powerpc64" port.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64, and I
think we have users of both (people running it on old powerbooks,
etc.).
The ABIs are not endian-specific. ELFv1 can operate as little endian
(and did for a brief period as a transition), ELFv2 can operate as big
endian. PowerPC64 Linux only will be 64 bit little endian going
forward, although the existing big endian, ELFv1 Linux distributions
will continue to be supported. There is no infrastructure or
distribution into which a PPC64BE ELFv2 libc can be installed.

A PPC64 big endian ELFv2 port is an interesting exercise, but does not
match or interact with any other Linux distributions or toolchains.
All of the PPC64 BE Linux ports are based on ELFv1 and have no
intention of changing.

I am not exactly certain what FreeBSD is planning.
These two statements contradict each other. Also, I have made a very
minimal big-endian build of musl for the ppc64 architecture, but I
haven't had any time to test it.
There was never a 64-bit PowerPC laptop that I am aware; the highest
spec PowerPC laptop would have been a Daystar with a 32-bit MPC7448.
However, IBM, Apple, Tyan, and a few other manufacturers have released
big-endian 64-bit PowerPC hardware in both workstation and server form.
Let us also not forget that LoPAPR[1] defines (at R1-2.7-1 in my copy,
version 1.1 dated 24 March 2016) that Power Architecture platforms
"must by default operate with Big-Endian addressing".
I think that you're inferring too much into this statement. The
platform has to interoperate with big-endian addressing, especially
for firmware that assumes big endian, but that does not mean that
operating systems must support big endian user space applications.
Are you aware of any little-endian specific code in musl/powerpc64? I
assume that libc-test would probably catch most of it when I am able
to run it, but until then, it would be nice to know if there is
anything I need to work on in the meantime.
The PPC64 port of Musl does not assume little endian addressing, but
Musl currently only supports ELFv2. All of the toolchains and
operating systems that support ELFv2 are little endian. All of the
big endian toolchains and operating systems are designed for ELFv1.
There is no overlap.

I added the macro tests for portability and completeness.

The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.

Thanks, David
Rich Felker
2017-06-24 22:44:06 UTC
Permalink
Post by David Edelsohn
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Post by David Edelsohn
Note that I only added the optimizations to the "powerpc64" port,
not the "powerpc" port. The powerpc64 port only support PPC64LE
Linux, which does not include PPC970. The comments about emulation
are not relevant to the "powerpc64" port.
Indeed, musl uses the ELFv2 ABI (minus its gratuitous mandate of
minimum ISA level) for both little and big endian powerpc64, and I
think we have users of both (people running it on old powerbooks,
etc.).
The ABIs are not endian-specific. ELFv1 can operate as little endian
(and did for a brief period as a transition), ELFv2 can operate as big
endian. PowerPC64 Linux only will be 64 bit little endian going
forward, although the existing big endian, ELFv1 Linux distributions
will continue to be supported. There is no infrastructure or
distribution into which a PPC64BE ELFv2 libc can be installed.
Any distro that builds from source and uses musl should work. I
suspect Sabotage can do it. Rob Landley's minimal mkroot builds should
also get you a system you can boot.
Post by David Edelsohn
A PPC64 big endian ELFv2 port is an interesting exercise, but does not
match or interact with any other Linux distributions or toolchains.
That's already the case if you're using musl anyway, and part of why
the decision made sense.
Post by David Edelsohn
All of the PPC64 BE Linux ports are based on ELFv1 and have no
intention of changing.
I think the kernel simply supports both ELFv1 and ELFv2 userspace
anyway and doesn't care what binaries you run, though I didn't check.
The only place where it could care anyway is the function pointers
used for signal handlers.
Post by David Edelsohn
Are you aware of any little-endian specific code in musl/powerpc64? I
assume that libc-test would probably catch most of it when I am able
to run it, but until then, it would be nice to know if there is
anything I need to work on in the meantime.
The PPC64 port of Musl does not assume little endian addressing, but
Musl currently only supports ELFv2. All of the toolchains and
operating systems that support ELFv2 are little endian. All of the
big endian toolchains and operating systems are designed for ELFv1.
There is no overlap.
git clone https://github.com/richfelker/musl-cross-make.git \
&& cd musl-cross-make && make TARGET=powerpc64-linux-musl

There are no patches needed for the ABI to work, just --with-abi=elfv2
which musl-cross-make always uses for ppc64. qemu-ppc64 (user level)
runs the binaries it produces just fine. I don't have actual hardware
or a kernel for system emulation handy but I don't see any reason to
expect it not to work.
Post by David Edelsohn
I added the macro tests for portability and completeness.
The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.
I guess "supported" is the key word here, in particular whose
perspective you're asking that something be supported from.

Rich
A. Wilcox
2017-06-24 23:57:23 UTC
Permalink
On Fri, Jun 23, 2017 at 11:38 PM, A. Wilcox
ELFv1 can operate as little endian (and did for a brief period as
a transition), ELFv2 can operate as big endian. PowerPC64 Linux
only will be 64 bit little endian going forward, although the
existing big endian, ELFv1 Linux distributions will continue to be
supported. There is no infrastructure or distribution into which
a PPC64BE ELFv2 libc can be installed.
Is there a technical reason why PowerPC64 Linux will only be
little-endian? Do the Power8 / Power9 chips not support BE mode for
Linux officially?

I have an IRC log where I was chatting with an IBM engineer and they
said there is no reason P8/P9 can't run Linux in BE mode. The only
reason to run LE mode is for better GPU support since most of the
Radeons run their framebuffers in that mode (so you'd have much better
performance, esp when using them for GPGPU). But that could have been
then, and not now, since that conversation was almost a year ago.
A PPC64 big endian ELFv2 port is an interesting exercise, but does
not match or interact with any other Linux distributions or
toolchains. All of the PPC64 BE Linux ports are based on ELFv1 and
have no intention of changing.
Except those based on musl? I mean, we at Adélie haven't /shipped/
anything PPC64 yet, but I have very good reasons for that (and will
get to them later in this email).
I am not exactly certain what FreeBSD is planning.
https://svnweb.freebsd.org/base?view=revision&revision=291668

FreeBSD supports either ABI in either endianness, but defaults to
ELFv2 for both BE and LE with any compiler that supports it.
Post by A. Wilcox
Let us also not forget that LoPAPR[1] defines (at R1-2.7-1 in my
copy, version 1.1 dated 24 March 2016) that Power Architecture
platforms "must by default operate with Big-Endian addressing".
I think that you're inferring too much into this statement. The
platform has to interoperate with big-endian addressing, especially
for firmware that assumes big endian, but that does not mean that
operating systems must support big endian user space applications.
To me, the standard is completely clear that the operating system
(this being the kernel, i.e. Linux itself, and base userland, i.e.
musl) needs to support both to be compliant with the LoPAPR standard;
at least §2.7, §4.2.3, §B.5.1.

Of course, each distro can pick what it wants to support, what tool
chain to use, and so on. But the base system needs to support both.
Post by A. Wilcox
Are you aware of any little-endian specific code in
musl/powerpc64? I assume that libc-test would probably catch
most of it when I am able to run it, but until then, it would be
nice to know if there is anything I need to work on in the
meantime.
The PPC64 port of Musl does not assume little endian addressing,
but Musl currently only supports ELFv2. All of the toolchains and
operating systems that support ELFv2 are little endian. All of
the big endian toolchains and operating systems are designed for
ELFv1. There is no overlap.
Except Adélie, Sabotage, and anyone who is creating their own
environment without using a distribution. Or are you saying that GCC
assumes LE with ELFv2?

That is the primary reason I haven't shipped any PPC64 image yet. In
addition to the usual badness of porting an entire distro worth of
packages to a platform nobody has really used yet (had a similar time
with musl on MIPS64 and 32-bit PowerPC), I'm a bit uneasy on the
toolchain itself being able to understand what Rich has said. Since
ELFv2 says that Power8 is the minimum ISA, gcc can do whatever it
wants, and I'm not sure if -mcpu=power6 (specific lower ISA) or
- -mcpu=powerpc64 (generic) will affect its code output when it sees
- -mabi=elfv2. So I'm going to need to put any PPC64 image through a
much more rigorous test than I did any other platform.
I added the macro tests for portability and completeness.
The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.
Except Rich specifically said that he did not want an ELFv1 port for
64-bit PowerPC when I asked him, so I don't think that's going to happen
.

Again, do you have a _technical_ reason that I cannot spend next
weekend making a PPC64 BE image using musl + ELFv2 ABI? Or is this
political / community in nature?

I apologise if my words seem strong, but I do not take this lightly.
We have a number of users clamouring for us to save their older PPC64
hardware from unmaintained AIX, unmaintained Debian, or in some cases
ten-or-more year old fruity OSes. I obviously do not expect ABI
compatibility with decades-old non-Linux Unixes. However, if there
needs to be an ELFv1 port for a technical reason, I may have to
investigate maintaining the port myself.

Regards,
- --arw


- --
A. Wilcox (awilfox)
Project Lead, Adélie Linux
http://adelielinux.org
Rich Felker
2017-06-25 00:10:24 UTC
Permalink
Post by A. Wilcox
Except Adélie, Sabotage, and anyone who is creating their own
environment without using a distribution. Or are you saying that GCC
assumes LE with ELFv2?
That is the primary reason I haven't shipped any PPC64 image yet. In
addition to the usual badness of porting an entire distro worth of
packages to a platform nobody has really used yet (had a similar time
with musl on MIPS64 and 32-bit PowerPC), I'm a bit uneasy on the
toolchain itself being able to understand what Rich has said. Since
ELFv2 says that Power8 is the minimum ISA, gcc can do whatever it
wants, and I'm not sure if -mcpu=power6 (specific lower ISA) or
- -mcpu=powerpc64 (generic) will affect its code output when it sees
- -mabi=elfv2. So I'm going to need to put any PPC64 image through a
much more rigorous test than I did any other platform.
I don't see any reason GCC would introduce a problem here. It should
always honor -march, and the default -march for the
powerpc64-linux-musl (elfv2 of course) toolchain I just built seems to
be POWER4 according to the predefined macros.
Post by A. Wilcox
Post by David Edelsohn
I added the macro tests for portability and completeness.
The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.
Except Rich specifically said that he did not want an ELFv1 port for
64-bit PowerPC when I asked him, so I don't think that's going to happen
To clarify, my view is that it does not make sense to add a new port
that differs only in ABI, unless it's an ABI variant that's actually
necessary for reasonable support of some actual hardware (like
softfloat, fdpic for nommu, etc.). That is not the case here.

Also, note that it's not like glibc-linked elfv1 ppc64 binaries would
be safe to use with musl even if we did have such a port; at the very
least the representation of long double would have to mismatch (just
like it does on 32-bit powerpc).
Post by A. Wilcox
Again, do you have a _technical_ reason that I cannot spend next
weekend making a PPC64 BE image using musl + ELFv2 ABI? Or is this
political / community in nature?
I think it's mostly just a misunderstanding. It may have started out
from political decisions, but I don't think people are _trying_ to be
political about it at this point.

Rich
Rich Felker
2017-06-25 01:41:51 UTC
Permalink
Post by Rich Felker
Post by A. Wilcox
Except Adélie, Sabotage, and anyone who is creating their own
environment without using a distribution. Or are you saying that GCC
assumes LE with ELFv2?
That is the primary reason I haven't shipped any PPC64 image yet. In
addition to the usual badness of porting an entire distro worth of
packages to a platform nobody has really used yet (had a similar time
with musl on MIPS64 and 32-bit PowerPC), I'm a bit uneasy on the
toolchain itself being able to understand what Rich has said. Since
ELFv2 says that Power8 is the minimum ISA, gcc can do whatever it
wants, and I'm not sure if -mcpu=power6 (specific lower ISA) or
- -mcpu=powerpc64 (generic) will affect its code output when it sees
- -mabi=elfv2. So I'm going to need to put any PPC64 image through a
much more rigorous test than I did any other platform.
I don't see any reason GCC would introduce a problem here. It should
always honor -march, and the default -march for the
powerpc64-linux-musl (elfv2 of course) toolchain I just built seems to
be POWER4 according to the predefined macros.
I just did a quick review (grep -r ELFv2 gcc/config/rs6000) and I
don't see anything that would cause gcc to generate code for a
different isa level than it otherwise would. The option purely
controls the calling convention and related issues.

One unfortunate thing I did discover in the process is that neither
powerpc64 ABI admits sibcall (tail call) to a function that's not
local (static or hidden/protected). This is a consequence of the ABI
GOT register being call-preserved rather than call-clobbered. This is
a common design issue (mistake IMO) affecting several archs, including
SH in the default ABI (but not in the FDPIC ABI, which made the choice
to change the GOT register to call-clobbered).

Rich
David Edelsohn
2017-06-29 13:49:34 UTC
Permalink
Post by Rich Felker
Post by A. Wilcox
Except Adélie, Sabotage, and anyone who is creating their own
environment without using a distribution. Or are you saying that GCC
assumes LE with ELFv2?
That is the primary reason I haven't shipped any PPC64 image yet. In
addition to the usual badness of porting an entire distro worth of
packages to a platform nobody has really used yet (had a similar time
with musl on MIPS64 and 32-bit PowerPC), I'm a bit uneasy on the
toolchain itself being able to understand what Rich has said. Since
ELFv2 says that Power8 is the minimum ISA, gcc can do whatever it
wants, and I'm not sure if -mcpu=power6 (specific lower ISA) or
- -mcpu=powerpc64 (generic) will affect its code output when it sees
- -mabi=elfv2. So I'm going to need to put any PPC64 image through a
much more rigorous test than I did any other platform.
I don't see any reason GCC would introduce a problem here. It should
always honor -march, and the default -march for the
powerpc64-linux-musl (elfv2 of course) toolchain I just built seems to
be POWER4 according to the predefined macros.
Post by A. Wilcox
Post by David Edelsohn
I added the macro tests for portability and completeness.
The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.
Except Rich specifically said that he did not want an ELFv1 port for
64-bit PowerPC when I asked him, so I don't think that's going to happen
To clarify, my view is that it does not make sense to add a new port
that differs only in ABI, unless it's an ABI variant that's actually
necessary for reasonable support of some actual hardware (like
softfloat, fdpic for nommu, etc.). That is not the case here.
A colleague of mine reminded me that ELFv2 ABI specifies POWER8 as the
minimum hardware (not little-endian). The implementation of ELFv2 can
operate on earlier hardware, but binaries may not be forward
compatible because of VSX. Because of the calling convention of VSX
registers in ELFv2, the stack may be corrupted if an application built
without VSX support is linked with a library that does support VSX.
One cannot mix and match musl libc built for POWER4 or PPC970 and musl
libc built for POWER7.

Thanks, David
Rich Felker
2017-06-29 16:05:44 UTC
Permalink
Post by David Edelsohn
Post by Rich Felker
Post by A. Wilcox
Except Adélie, Sabotage, and anyone who is creating their own
environment without using a distribution. Or are you saying that GCC
assumes LE with ELFv2?
That is the primary reason I haven't shipped any PPC64 image yet. In
addition to the usual badness of porting an entire distro worth of
packages to a platform nobody has really used yet (had a similar time
with musl on MIPS64 and 32-bit PowerPC), I'm a bit uneasy on the
toolchain itself being able to understand what Rich has said. Since
ELFv2 says that Power8 is the minimum ISA, gcc can do whatever it
wants, and I'm not sure if -mcpu=power6 (specific lower ISA) or
- -mcpu=powerpc64 (generic) will affect its code output when it sees
- -mabi=elfv2. So I'm going to need to put any PPC64 image through a
much more rigorous test than I did any other platform.
I don't see any reason GCC would introduce a problem here. It should
always honor -march, and the default -march for the
powerpc64-linux-musl (elfv2 of course) toolchain I just built seems to
be POWER4 according to the predefined macros.
Post by A. Wilcox
Post by David Edelsohn
I added the macro tests for portability and completeness.
The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.
Except Rich specifically said that he did not want an ELFv1 port for
64-bit PowerPC when I asked him, so I don't think that's going to happen
To clarify, my view is that it does not make sense to add a new port
that differs only in ABI, unless it's an ABI variant that's actually
necessary for reasonable support of some actual hardware (like
softfloat, fdpic for nommu, etc.). That is not the case here.
A colleague of mine reminded me that ELFv2 ABI specifies POWER8 as the
minimum hardware (not little-endian).
This is a gratuitous requirement and has nothing to do with the
meaning of ELFv2 we're using (and likewise not with the gcc
--with-abi=elfv2).
Post by David Edelsohn
The implementation of ELFv2 can
operate on earlier hardware, but binaries may not be forward
compatible because of VSX. Because of the calling convention of VSX
registers in ELFv2, the stack may be corrupted if an application built
without VSX support is linked with a library that does support VSX.
One cannot mix and match musl libc built for POWER4 or PPC970 and musl
libc built for POWER7.
I don't think this is accurate. If it is then it's a serious bug we
need to fix, and it should have been discussed at the time the port
was added...

Can you provide a citation for the usage of VSX registers in the
calling convention, and how you think that affects the stack?

Rich
David Edelsohn
2017-06-29 17:00:51 UTC
Permalink
Post by Rich Felker
Post by David Edelsohn
Post by Rich Felker
Post by A. Wilcox
Except Adélie, Sabotage, and anyone who is creating their own
environment without using a distribution. Or are you saying that GCC
assumes LE with ELFv2?
That is the primary reason I haven't shipped any PPC64 image yet. In
addition to the usual badness of porting an entire distro worth of
packages to a platform nobody has really used yet (had a similar time
with musl on MIPS64 and 32-bit PowerPC), I'm a bit uneasy on the
toolchain itself being able to understand what Rich has said. Since
ELFv2 says that Power8 is the minimum ISA, gcc can do whatever it
wants, and I'm not sure if -mcpu=power6 (specific lower ISA) or
- -mcpu=powerpc64 (generic) will affect its code output when it sees
- -mabi=elfv2. So I'm going to need to put any PPC64 image through a
much more rigorous test than I did any other platform.
I don't see any reason GCC would introduce a problem here. It should
always honor -march, and the default -march for the
powerpc64-linux-musl (elfv2 of course) toolchain I just built seems to
be POWER4 according to the predefined macros.
Post by A. Wilcox
Post by David Edelsohn
I added the macro tests for portability and completeness.
The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.
Except Rich specifically said that he did not want an ELFv1 port for
64-bit PowerPC when I asked him, so I don't think that's going to happen
To clarify, my view is that it does not make sense to add a new port
that differs only in ABI, unless it's an ABI variant that's actually
necessary for reasonable support of some actual hardware (like
softfloat, fdpic for nommu, etc.). That is not the case here.
A colleague of mine reminded me that ELFv2 ABI specifies POWER8 as the
minimum hardware (not little-endian).
This is a gratuitous requirement and has nothing to do with the
meaning of ELFv2 we're using (and likewise not with the gcc
--with-abi=elfv2).
2.1.1. Processor Architecture

This ABI is predicated on, at a minimum, Power ISA version 2.7 and
contains additional implementation characteristics.
Post by Rich Felker
Post by David Edelsohn
The implementation of ELFv2 can
operate on earlier hardware, but binaries may not be forward
compatible because of VSX. Because of the calling convention of VSX
registers in ELFv2, the stack may be corrupted if an application built
without VSX support is linked with a library that does support VSX.
One cannot mix and match musl libc built for POWER4 or PPC970 and musl
libc built for POWER7.
I don't think this is accurate. If it is then it's a serious bug we
need to fix, and it should have been discussed at the time the port
was added...
This is not an implementation detail in the library, it is the calling
convention in the compilers.
Post by Rich Felker
Can you provide a citation for the usage of VSX registers in the
calling convention, and how you think that affects the stack?
Table 2.22 Vector Register Roles in Section 2.2.1.1 Register Roles.
The definition of volatile and non-volatile registers for vector
registers affects the amount of stack allocated and the saving of
non-volatile registers.


What is the status of the PPC64LE math optimization patch?

Thanks, David
Rich Felker
2017-06-29 17:59:26 UTC
Permalink
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
A colleague of mine reminded me that ELFv2 ABI specifies POWER8 as the
minimum hardware (not little-endian).
This is a gratuitous requirement and has nothing to do with the
meaning of ELFv2 we're using (and likewise not with the gcc
--with-abi=elfv2).
2.1.1. Processor Architecture
This ABI is predicated on, at a minimum, Power ISA version 2.7 and
contains additional implementation characteristics.
Yes, I understand that it's there but this "requirement" is orthogonal
to the actual interface boundaries the ABI defines. ARM's EABI has a
similar gratuitous baseline of v4t; the compiler can satisfy all the
interface boundary requirements even on v4 and probably lower if it
wants to, but nobody has implemented that.
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
The implementation of ELFv2 can
operate on earlier hardware, but binaries may not be forward
compatible because of VSX. Because of the calling convention of VSX
registers in ELFv2, the stack may be corrupted if an application built
without VSX support is linked with a library that does support VSX.
One cannot mix and match musl libc built for POWER4 or PPC970 and musl
libc built for POWER7.
I don't think this is accurate. If it is then it's a serious bug we
need to fix, and it should have been discussed at the time the port
was added...
This is not an implementation detail in the library, it is the calling
convention in the compilers.
Post by Rich Felker
Can you provide a citation for the usage of VSX registers in the
calling convention, and how you think that affects the stack?
Table 2.22 Vector Register Roles in Section 2.2.1.1 Register Roles.
The definition of volatile and non-volatile registers for vector
registers affects the amount of stack allocated and the saving of
non-volatile registers.
Are you saying the caller has to allocate space that the callee might
use to preseve call-saved registers it wants to use, and that the
amount saved depends on ISA level? If so I'll look for the associated
logic in GCC and see what it's doing. If that's the case it should be
reserving space regardless of whether it's built for an ISA level with
the registers or not.
Post by David Edelsohn
What is the status of the PPC64LE math optimization patch?
It's merged, I just forgot to push. So is the s390x one. Pushing now.

Rich
David Edelsohn
2017-06-30 01:07:16 UTC
Permalink
Post by Rich Felker
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
A colleague of mine reminded me that ELFv2 ABI specifies POWER8 as the
minimum hardware (not little-endian).
This is a gratuitous requirement and has nothing to do with the
meaning of ELFv2 we're using (and likewise not with the gcc
--with-abi=elfv2).
2.1.1. Processor Architecture
This ABI is predicated on, at a minimum, Power ISA version 2.7 and
contains additional implementation characteristics.
Yes, I understand that it's there but this "requirement" is orthogonal
to the actual interface boundaries the ABI defines. ARM's EABI has a
similar gratuitous baseline of v4t; the compiler can satisfy all the
interface boundary requirements even on v4 and probably lower if it
wants to, but nobody has implemented that.
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
The implementation of ELFv2 can
operate on earlier hardware, but binaries may not be forward
compatible because of VSX. Because of the calling convention of VSX
registers in ELFv2, the stack may be corrupted if an application built
without VSX support is linked with a library that does support VSX.
One cannot mix and match musl libc built for POWER4 or PPC970 and musl
libc built for POWER7.
I don't think this is accurate. If it is then it's a serious bug we
need to fix, and it should have been discussed at the time the port
was added...
This is not an implementation detail in the library, it is the calling
convention in the compilers.
Post by Rich Felker
Can you provide a citation for the usage of VSX registers in the
calling convention, and how you think that affects the stack?
Table 2.22 Vector Register Roles in Section 2.2.1.1 Register Roles.
The definition of volatile and non-volatile registers for vector
registers affects the amount of stack allocated and the saving of
non-volatile registers.
Are you saying the caller has to allocate space that the callee might
use to preseve call-saved registers it wants to use, and that the
amount saved depends on ISA level? If so I'll look for the associated
logic in GCC and see what it's doing. If that's the case it should be
reserving space regardless of whether it's built for an ISA level with
the registers or not.
I thought that there was a change in the volatile status of the VSR
registers. I'm don't remember if this affected the stack frame or
stdarg. There was some corner case.

How can the toolchain save space for registers that it doesn't know about?

- David
Rich Felker
2017-06-30 02:11:23 UTC
Permalink
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
A colleague of mine reminded me that ELFv2 ABI specifies POWER8 as the
minimum hardware (not little-endian).
This is a gratuitous requirement and has nothing to do with the
meaning of ELFv2 we're using (and likewise not with the gcc
--with-abi=elfv2).
2.1.1. Processor Architecture
This ABI is predicated on, at a minimum, Power ISA version 2.7 and
contains additional implementation characteristics.
Yes, I understand that it's there but this "requirement" is orthogonal
to the actual interface boundaries the ABI defines. ARM's EABI has a
similar gratuitous baseline of v4t; the compiler can satisfy all the
interface boundary requirements even on v4 and probably lower if it
wants to, but nobody has implemented that.
Post by David Edelsohn
Post by Rich Felker
Post by David Edelsohn
The implementation of ELFv2 can
operate on earlier hardware, but binaries may not be forward
compatible because of VSX. Because of the calling convention of VSX
registers in ELFv2, the stack may be corrupted if an application built
without VSX support is linked with a library that does support VSX.
One cannot mix and match musl libc built for POWER4 or PPC970 and musl
libc built for POWER7.
I don't think this is accurate. If it is then it's a serious bug we
need to fix, and it should have been discussed at the time the port
was added...
This is not an implementation detail in the library, it is the calling
convention in the compilers.
Post by Rich Felker
Can you provide a citation for the usage of VSX registers in the
calling convention, and how you think that affects the stack?
Table 2.22 Vector Register Roles in Section 2.2.1.1 Register Roles.
The definition of volatile and non-volatile registers for vector
registers affects the amount of stack allocated and the saving of
non-volatile registers.
Are you saying the caller has to allocate space that the callee might
use to preseve call-saved registers it wants to use, and that the
amount saved depends on ISA level? If so I'll look for the associated
logic in GCC and see what it's doing. If that's the case it should be
reserving space regardless of whether it's built for an ISA level with
the registers or not.
I thought that there was a change in the volatile status of the VSR
registers. I'm don't remember if this affected the stack frame or
stdarg. There was some corner case.
How can the toolchain save space for registers that it doesn't know about?
Normally (on clean ABIs), the caller is not responsible for setting up
room on the stack for the callee to backup call-saved registers it may
want to use. Rather, the callee does this, and therefore it can choose
the exact amount of space for the actual registers it wants to spill.
If the caller is responsible for allocating the stack space into which
the callee might need to spill, this both wastes lots of stack space
(when the callee doesn't actually need to spill much or anything) and
introduces ABI breakage whenever new call-saved registers are added.

I suspect the PPC64 ELFv2 ABI is doing all this right. On page 44 I
found:

"For the purpose of function calls, the right half of VSX registers,
corresponding to the classic floating-point registers (that is, vsr0 -
vsr31), is volatile."

Which suggests they put some attention into not breaking things when
the caller and callee are working with different ISA levels.

Rich
David Edelsohn
2017-06-25 03:24:59 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On Fri, Jun 23, 2017 at 11:38 PM, A. Wilcox
ELFv1 can operate as little endian (and did for a brief period as
a transition), ELFv2 can operate as big endian. PowerPC64 Linux
only will be 64 bit little endian going forward, although the
existing big endian, ELFv1 Linux distributions will continue to be
supported. There is no infrastructure or distribution into which
a PPC64BE ELFv2 libc can be installed.
Is there a technical reason why PowerPC64 Linux will only be
little-endian? Do the Power8 / Power9 chips not support BE mode for
Linux officially?
The processors support operation in either endian mode.
I have an IRC log where I was chatting with an IBM engineer and they
said there is no reason P8/P9 can't run Linux in BE mode. The only
reason to run LE mode is for better GPU support since most of the
Radeons run their framebuffers in that mode (so you'd have much better
performance, esp when using them for GPGPU). But that could have been
then, and not now, since that conversation was almost a year ago.
A PPC64 big endian ELFv2 port is an interesting exercise, but does
not match or interact with any other Linux distributions or
toolchains. All of the PPC64 BE Linux ports are based on ELFv1 and
have no intention of changing.
Except those based on musl? I mean, we at Adélie haven't /shipped/
anything PPC64 yet, but I have very good reasons for that (and will
get to them later in this email).
Because the PowerPC software ecosystem is based on and designed to
those assumptions. All of the JITs are based on that. All of the
optimized libraries are based on that. All of the hand-written
assembly code is based on that.

Some test ABI and endianness separately, some don't. It definitely is
less well tested, if at all.

You can do whatever you want, but it has been difficult enough fixing
all of the poor assumptions in the entire Open Source and proprietary
source ecosystem for the change to PPC64LE ELFv2. If you and Adelie
want to take on that challenge for PPC64BE ELFv2, great. The
OpenPower Foundation and its members are not going to fight that
battle.
I am not exactly certain what FreeBSD is planning.
https://svnweb.freebsd.org/base?view=revision&revision=291668
FreeBSD supports either ABI in either endianness, but defaults to
ELFv2 for both BE and LE with any compiler that supports it.
And this is why FreeBSD remains challenged. As I wrote above, all of
the PPC64BE software ecosystem is written for ELFv1, so this cuts off
FreeBSD from that entire ecosystem. Even packages in the FreeBSD
ports won't build and work correctly because the code for PPC assumes
the endianness and the ABI.
Post by A. Wilcox
Let us also not forget that LoPAPR[1] defines (at R1-2.7-1 in my
copy, version 1.1 dated 24 March 2016) that Power Architecture
platforms "must by default operate with Big-Endian addressing".
I think that you're inferring too much into this statement. The
platform has to interoperate with big-endian addressing, especially
for firmware that assumes big endian, but that does not mean that
operating systems must support big endian user space applications.
To me, the standard is completely clear that the operating system
(this being the kernel, i.e. Linux itself, and base userland, i.e.
musl) needs to support both to be compliant with the LoPAPR standard;
at least §2.7, §4.2.3, §B.5.1.
The sections refer to the processor and the platform, not the OSes and
user applications. Boot and RTAS (runtime abstraction services) is
big endian. The hypervisor may be big endian. The OS must be able to
interact with the system -- the underlying system -- in big endian
order. It says nothing about presenting a big endian environment to
user programs.
Of course, each distro can pick what it wants to support, what tool
chain to use, and so on. But the base system needs to support both.
Post by A. Wilcox
Are you aware of any little-endian specific code in
musl/powerpc64? I assume that libc-test would probably catch
most of it when I am able to run it, but until then, it would be
nice to know if there is anything I need to work on in the
meantime.
The PPC64 port of Musl does not assume little endian addressing,
but Musl currently only supports ELFv2. All of the toolchains and
operating systems that support ELFv2 are little endian. All of
the big endian toolchains and operating systems are designed for
ELFv1. There is no overlap.
Except Adélie, Sabotage, and anyone who is creating their own
environment without using a distribution. Or are you saying that GCC
assumes LE with ELFv2?
GCC doesn't assume LE = ELFv2, but not all code generation for PPC is
that flexible.
That is the primary reason I haven't shipped any PPC64 image yet. In
addition to the usual badness of porting an entire distro worth of
packages to a platform nobody has really used yet (had a similar time
with musl on MIPS64 and 32-bit PowerPC), I'm a bit uneasy on the
toolchain itself being able to understand what Rich has said. Since
ELFv2 says that Power8 is the minimum ISA, gcc can do whatever it
wants, and I'm not sure if -mcpu=power6 (specific lower ISA) or
- -mcpu=powerpc64 (generic) will affect its code output when it sees
- -mabi=elfv2. So I'm going to need to put any PPC64 image through a
much more rigorous test than I did any other platform.
I added the macro tests for portability and completeness.
The only ports of Musl that will function on existing, supported,
big-endian PowerPC systems are the 32 bit "powerpc" port and an
unimplemented PPC64 BE ELFv1 port.
Except Rich specifically said that he did not want an ELFv1 port for
64-bit PowerPC when I asked him, so I don't think that's going to happen
.
Again, do you have a _technical_ reason that I cannot spend next
weekend making a PPC64 BE image using musl + ELFv2 ABI? Or is this
political / community in nature?
I apologise if my words seem strong, but I do not take this lightly.
We have a number of users clamouring for us to save their older PPC64
hardware from unmaintained AIX, unmaintained Debian, or in some cases
ten-or-more year old fruity OSes. I obviously do not expect ABI
compatibility with decades-old non-Linux Unixes. However, if there
needs to be an ELFv1 port for a technical reason, I may have to
investigate maintaining the port myself.
As I wrote above, the entire external ecosystem makes the endianness /
ABI assumption. Golang assumes this. OpenJDK assumes this. ATLAS
BLAS and OpenBLAS assume this. GMP assumes this. PyPy assumes this.
Mono assumes this. libffi assumes this. Erlang probably assumes this.
FFMPEG, x264, libvpx assume this. MongoDB may assume this. NVIDIA
nvcc assumes this. Etc., etc., etc.

It's not that the packages fundamentally cannot be fixed, but the
FLOSS ecosystem is much larger, richer, complex and more
interdependent. If one wants to create an embedded system, one can
exert control over the entire software ecosystem. For a
Linux-compatible system, one cannot.

If you accept that some parts of the software ecosystem simply won't
build or function correctly for your system and configuration, or some
packages randomly will stop building or stop functioning correctly
after a package is updated, fine. If you want to track it all down,
fine. I hope that you are incorporating all of that into the price
that you are charging your customers and that they understand the
additional risk. When you and your customers rely on the larger Linux
ecosystem, you are relying on a lot of assets and resources outside of
your control.

Thanks, David
Rich Felker
2017-06-25 14:28:21 UTC
Permalink
Post by David Edelsohn
Post by A. Wilcox
Except those based on musl? I mean, we at Adélie haven't /shipped/
anything PPC64 yet, but I have very good reasons for that (and will
get to them later in this email).
Because the PowerPC software ecosystem is based on and designed to
those assumptions. All of the JITs are based on that. All of the
optimized libraries are based on that. All of the hand-written
assembly code is based on that.
Some test ABI and endianness separately, some don't. It definitely is
less well tested, if at all.
You can do whatever you want, but it has been difficult enough fixing
all of the poor assumptions in the entire Open Source and proprietary
source ecosystem for the change to PPC64LE ELFv2. If you and Adelie
want to take on that challenge for PPC64BE ELFv2, great. The
OpenPower Foundation and its members are not going to fight that
battle.
I see where you're coming from, but I don't see where it's
significantly harder than fighting with and fixing software that
doesn't work with musl due to gratuitous (or sometimes moderately
reasonable) glibcisms. Having this type of ABI issue increases the
number of such cases a bit, but I don't expect it to be a significant
portion of the overall work.
Post by David Edelsohn
Post by A. Wilcox
I apologise if my words seem strong, but I do not take this lightly.
We have a number of users clamouring for us to save their older PPC64
hardware from unmaintained AIX, unmaintained Debian, or in some cases
ten-or-more year old fruity OSes. I obviously do not expect ABI
compatibility with decades-old non-Linux Unixes. However, if there
needs to be an ELFv1 port for a technical reason, I may have to
investigate maintaining the port myself.
As I wrote above, the entire external ecosystem makes the endianness /
ABI assumption. Golang assumes this. OpenJDK assumes this. ATLAS
BLAS and OpenBLAS assume this. GMP assumes this. PyPy assumes this.
Mono assumes this. libffi assumes this. Erlang probably assumes this.
FFMPEG, x264, libvpx assume this. MongoDB may assume this. NVIDIA
nvcc assumes this. Etc., etc., etc.
Several of these are trivially fixed with --disable-asm or similar --
at least gmp, ffmpeg, x264, and libvpx should fall in that category.
Obviously it's desirable to get the asm working to improve
performance, but it can be done incrementally. It also should be
possible to heuristically test for this kind of thing by grepping for
ppc64 asm function prologue in the sources.

Only stuff that actually does codegen (compilers, jits, etc.) has a
fundamental reason to be affected, and for the most part fixing it
should just be a matter of fixing the conditionals that look for
endianness to look for _CALL_ELF==2 where that's what they really
meant to do.
Post by David Edelsohn
It's not that the packages fundamentally cannot be fixed, but the
FLOSS ecosystem is much larger, richer, complex and more
interdependent. If one wants to create an embedded system, one can
exert control over the entire software ecosystem. For a
Linux-compatible system, one cannot.
If you accept that some parts of the software ecosystem simply won't
build or function correctly for your system and configuration, or some
packages randomly will stop building or stop functioning correctly
after a package is updated, fine.
These are already risks inherent in using a musl-based system with
upstream packages that are developed on glibc and don't pay attention
to portability issues. We have a very good history of the distros
using musl making efforts to patch these kinds of things, send patchs
upstream, and educate upstreams without attacking or patronizing them.
Sometimes upstream regressions happen, but adequate testing should
catch them.

Rich
David Edelsohn
2017-06-25 14:56:14 UTC
Permalink
Post by Rich Felker
Post by David Edelsohn
Post by A. Wilcox
Except those based on musl? I mean, we at Adélie haven't /shipped/
anything PPC64 yet, but I have very good reasons for that (and will
get to them later in this email).
Because the PowerPC software ecosystem is based on and designed to
those assumptions. All of the JITs are based on that. All of the
optimized libraries are based on that. All of the hand-written
assembly code is based on that.
Some test ABI and endianness separately, some don't. It definitely is
less well tested, if at all.
You can do whatever you want, but it has been difficult enough fixing
all of the poor assumptions in the entire Open Source and proprietary
source ecosystem for the change to PPC64LE ELFv2. If you and Adelie
want to take on that challenge for PPC64BE ELFv2, great. The
OpenPower Foundation and its members are not going to fight that
battle.
I see where you're coming from, but I don't see where it's
significantly harder than fighting with and fixing software that
doesn't work with musl due to gratuitous (or sometimes moderately
reasonable) glibcisms. Having this type of ABI issue increases the
number of such cases a bit, but I don't expect it to be a significant
portion of the overall work.
Post by David Edelsohn
Post by A. Wilcox
I apologise if my words seem strong, but I do not take this lightly.
We have a number of users clamouring for us to save their older PPC64
hardware from unmaintained AIX, unmaintained Debian, or in some cases
ten-or-more year old fruity OSes. I obviously do not expect ABI
compatibility with decades-old non-Linux Unixes. However, if there
needs to be an ELFv1 port for a technical reason, I may have to
investigate maintaining the port myself.
As I wrote above, the entire external ecosystem makes the endianness /
ABI assumption. Golang assumes this. OpenJDK assumes this. ATLAS
BLAS and OpenBLAS assume this. GMP assumes this. PyPy assumes this.
Mono assumes this. libffi assumes this. Erlang probably assumes this.
FFMPEG, x264, libvpx assume this. MongoDB may assume this. NVIDIA
nvcc assumes this. Etc., etc., etc.
Several of these are trivially fixed with --disable-asm or similar --
at least gmp, ffmpeg, x264, and libvpx should fall in that category.
Obviously it's desirable to get the asm working to improve
performance, but it can be done incrementally. It also should be
possible to heuristically test for this kind of thing by grepping for
ppc64 asm function prologue in the sources.
Only stuff that actually does codegen (compilers, jits, etc.) has a
fundamental reason to be affected, and for the most part fixing it
should just be a matter of fixing the conditionals that look for
endianness to look for _CALL_ELF==2 where that's what they really
meant to do.
Post by David Edelsohn
It's not that the packages fundamentally cannot be fixed, but the
FLOSS ecosystem is much larger, richer, complex and more
interdependent. If one wants to create an embedded system, one can
exert control over the entire software ecosystem. For a
Linux-compatible system, one cannot.
If you accept that some parts of the software ecosystem simply won't
build or function correctly for your system and configuration, or some
packages randomly will stop building or stop functioning correctly
after a package is updated, fine.
These are already risks inherent in using a musl-based system with
upstream packages that are developed on glibc and don't pay attention
to portability issues. We have a very good history of the distros
using musl making efforts to patch these kinds of things, send patchs
upstream, and educate upstreams without attacking or patronizing them.
Sometimes upstream regressions happen, but adequate testing should
catch them.
Rich,

I am not arguing against big-endian PowerPC nor a powerpc64 BE ELFv2
port of musl nor building powerpc64 BE ELFv2 Linux. Mr. Wilcox asked
about the technical challenges and I replied.

The companies backing OpenPower have chosen a particular direction and
they are investing resources in that direction. The developers, most
of whom work for those companies and their partners, are working in
that direction. Most of the paid developers will not invest a lot of
time and effort in BE functionality and support. PowerPC already is a
small market, so further fragmentation isn't helpful. Without
corporate backing, the creation of an alternate Linux configuration
and ecosystem is a Herculean task.

Again, I am not and never was arguing against Mr. Wilcox's plans nor
against including powerpc64 BE ELFv2 support in musl libc. As I wrote
when I submitted the patch, I added the macro tests for completeness
and to allow future flexibility.

Thanks, David
A. Wilcox
2018-09-27 22:53:01 UTC
Permalink
A little update for those interested.
Post by Rich Felker
Post by David Edelsohn
Except those based on musl? I mean, we at Adélie haven't /shipped/
anything PPC64 yet, but I have very good reasons for that (and will
get to them later in this email).
We have definitely shipped on PPC64 now. We were actually the first
distro in history (to my knowledge) to ship musl on PPC64.

That's PPC64, as in 64-bit big endian PowerPC.

KDE, LXQt, Firefox, Thunderbird, the whole lot. I'm using it on an iMac
G5, several G5 towers, and a Talos 2. I actually threw out my last
x86_64 system once the Talos 2 arrived.
Post by Rich Felker
Post by David Edelsohn
You can do whatever you want, but it has been difficult enough fixing
all of the poor assumptions in the entire Open Source and proprietary
source ecosystem for the change to PPC64LE ELFv2. If you and Adelie
want to take on that challenge for PPC64BE ELFv2, great. The
OpenPower Foundation and its members are not going to fight that
battle.
Keep talking like you speak for the Foundation...

https://twitter.com/hughhalf/status/1027109176563064833
Post by Rich Felker
I see where you're coming from, but I don't see where it's
significantly harder than fighting with and fixing software that
doesn't work with musl due to gratuitous (or sometimes moderately
reasonable) glibcisms. Having this type of ABI issue increases the
number of such cases a bit, but I don't expect it to be a significant
portion of the overall work.
Rich is correct; it hasn't been significant, and it has been very little
challenge when something is broken.
Post by Rich Felker
Post by David Edelsohn
I apologise if my words seem strong, but I do not take this lightly.
We have a number of users clamouring for us to save their older PPC64
hardware from unmaintained AIX, unmaintained Debian, or in some cases
ten-or-more year old fruity OSes. I obviously do not expect ABI
compatibility with decades-old non-Linux Unixes. However, if there
needs to be an ELFv1 port for a technical reason, I may have to
investigate maintaining the port myself.
As I wrote above, the entire external ecosystem makes the endianness /
ABI assumption. Golang assumes this. OpenJDK assumes this. ATLAS
BLAS and OpenBLAS assume this. GMP assumes this. PyPy assumes this.
Mono assumes this. libffi assumes this. Erlang probably assumes this.
FFMPEG, x264, libvpx assume this. MongoDB may assume this. NVIDIA
nvcc assumes this. Etc., etc., etc.
* Golang: incorrect. The code is written correctly, and Go runs
properly on BE PPC64 (though not correctly; this is unrelated to ELF ABI).

* OpenJDK: correct, patch is fermenting.

* BLAS/OpenBLAS: untested as of yet.

* GMP: incorrect. Works fine and passes all tests on musl without any
patching.

* PyPy: incorrect, as above.

* Mono: incorrect, as above.

* libffi: incorrect, but did require patching for musl's insistence on
using IEEE long doubles instead of IBM long doubles.

* FFmpeg, x264: incorrect. Work fine, though did need a single patch to
make AltiVec support build properly; this affected ppc32 and ppc64/ELFv1
as well.

* libvpx: does not support PowerPC in any capacity anyway.

* MongoDB: untested as of yet.

* NVIDIA nvcc: violates our package policy in many ways, proprietary
license being the largest. Also requires LE as far as I can tell, so
completely orthogonal to supporting BE.
Post by Rich Felker
Several of these are trivially fixed with --disable-asm or similar --
at least gmp, ffmpeg, x264, and libvpx should fall in that category.
Obviously it's desirable to get the asm working to improve
performance, but it can be done incrementally. It also should be
possible to heuristically test for this kind of thing by grepping for
ppc64 asm function prologue in the sources.
The only --disable-asm required was OpenSSL, and we have a patch
fermenting to fix that as well. (Most of their checks use _CALL_ELF
correctly, but a few do not.)
Post by Rich Felker
Only stuff that actually does codegen (compilers, jits, etc.) has a
fundamental reason to be affected, and for the most part fixing it
should just be a matter of fixing the conditionals that look for
endianness to look for _CALL_ELF==2 where that's what they really
meant to do.
One semi-important JIT that wasn't named was ORC, which is used by
gstreamer to help multimedia performance. I assume that wasn't named
because nobody merged LE support either?

We managed to patch it for ELFv2 cleanly, supporting both musl in BE
*and* all the ELFv2 LE distros including glibc. :)

We're also about to land a Valgrind patch to support ELFv2 on BE. I
believe the last major issue that we haven't yet sent upstream is
OpenJDK. (OpenSSL is a performance regression, but functionally complete.)
Post by Rich Felker
Post by David Edelsohn
It's not that the packages fundamentally cannot be fixed, but the
FLOSS ecosystem is much larger, richer, complex and more
interdependent. If one wants to create an embedded system, one can
exert control over the entire software ecosystem. For a
Linux-compatible system, one cannot.
If you accept that some parts of the software ecosystem simply won't
build or function correctly for your system and configuration, or some
packages randomly will stop building or stop functioning correctly
after a package is updated, fine.
We do not accept that in the slightest. And neither should anyone else.

We accept that parts of the software ecosystem need to be *fixed*.

Best to you and yours,
--arw
--
A. Wilcox (awilfox)
Project Lead, Adélie Linux
https://www.adelielinux.org
Loading...