Friday, January 31, 2020

Re: [macppc] devel/llvm: add clang -msvr4-struct-return

On Thu, 30 Jan 2020 16:52:06 +0100
Jeremie Courreges-Anglas <jca@wxcvbn.org> wrote:

> Two things came to my mind regarding your diff:
>
> - on reviews.llvm.org you say this affects OpenBSD, NetBSD and FreeBSD,
> but your code changes the default for anything ELF+non-Linux:
>
> > ++ if (Triple.isOSBinFormatELF() && !Triple.isOSLinux())
> > ++ return true;
>
> Are there only four platforms supported? Would it be safer to
> explicitely change the default on *BSD?

PowerPC has 2 platforms, AIX and Darwin (Mac OS X), not using ELF.
These platforms don't work: LLVM doesn't support Darwin, LLVM 8.0.1
(in OpenBSD ports) mistakingly uses ELF for AIX, and LLVM git master
gives error like, "FramePointer is not implemented on AIX yet."

I recently found an email proposing gcc -msvr4-struct-return:
https://gcc.gnu.org/ml/gcc-patches/2001-11/msg01468.html

The System V ABI PowerPC (1995, elfspec_ppc.pdf) said to return small
structs in r3/r4, but GCC never implemented this until 2001. Because
this is an ABI change, the email proposed that Linux, NetBSD, FreeBSD
would stay on -maix-struct-return, but all other ELF targets would
switch to -msvr4-struct-return. (GCC doesn't target PowerPC OpenBSD;
our ports-gcc uses a patch to add the target.) I believe that NetBSD
and FreeBSD changed ABIs, so Linux is the last odd platform.

> - I guess you did not choose the name of the options randomly. Lazy
> question: were SVR4 and AIX the first users of those ABI variants?
> Or is there another reason?

IBM's AIX went first, and made an ABI for XCOFF.
Apple's Mac OS got the ABI from AIX.

Sun wrote the ELF ABI (1995), probably for Solaris (their distro of
System V Release 4), but mkLinux and NetBSD also used ELF.

--George

No comments:

Post a Comment