powerpc64 clang 9 ABI vs. gcc ABI and clang V10 and FreeBSD 13: -msvr4-struct-return by default for clang in order to match gcc/g++?

Mark Millard marklmi at yahoo.com
Wed Feb 19 02:55:33 UTC 2020


There is a review on llvm.org for having clang match the gcc/g++ ABI
used for powerpc64 FreeBSD for what is now a known mismatch (at least
for clang 9 as it is for ELFv2):

https://reviews.llvm.org/D73290

In essence, clang 9 is using -maix-struct-return (stack space and a
pointer to it) which does not match what gcc/g++ is using (registers
holding the content). The register that hold the pointer in one leads
to problems for the mix when used as an address with values that are
not addresses.

Historically FreeBSD used -msvr4-struct-return style, matching gcc/g++.
Using -maix-struct-return style is new.

With https://svnweb.freebsd.org/base/projects/clang1000-import/ and
https://svnweb.freebsd.org/ports/head/devel/llvm10/ active, it might
be appropriate to to have the change adopted and be part of 13's
definition.

This would, of course, lead to another incompatible powerpc64 ABI
change before 13 freezes.


I originally ran into this using C++'s steady-clock's now return
values, leading to program crashes from the mismatched ABI's when
I had g++ using the FreeBSD system headers and libraries instead
of the gcc ones (so libc++ was in use, for example).


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-ppc mailing list