David, Here comes the inevitable followup.. I broke backwards compatibility when adding an extra field to ffi_cif. I'd like to import again from upstream, where I've already fixed the problem.
https://sourceware.org/ml/libffi-discuss/2013/msg00220.html Actually, it's not a straight import because many files outside of libffi/src/powerpc/ have diverged, but fortunately for me, not significantly. For the record, I've shown the files that need patching below. Identical patches went in upstream (except for formatting differences in Makefile.am). Bootstrapped etc. powerpc64-linux and powerpc64le-linux. OK to apply? libffi/ * src/powerpc/ffitarget.h: Import from upstream. * src/powerpc/ffi_powerpc.h: Likewise. * src/powerpc/ffi.c: Likewise. * src/powerpc/ffi_sysv.c: Likewise. * src/powerpc/ffi_linux64.c: Likewise. * src/powerpc/sysv.S: Likewise. * src/powerpc/ppc_closure.S: Likewise. * src/powerpc/linux64.S: Likewise. * src/powerpc/linux64_closure.S: Likewise. * src/types.c: Likewise. * Makefile.am (EXTRA_DIST): Add new src/powerpc files. (nodist_libffi_la_SOURCES <POWERPC, POWERPC_FREEBSD>): Likewise. * configure.ac (HAVE_LONG_DOUBLE_VARIANT): Define for powerpc. * include/ffi.h.in (ffi_prep_types): Declare. * src/prep_cif.c (ffi_prep_cif_core): Call ffi_prep_types. * configure: Regenerate. * fficonfig.h.in: Regenerate. * Makefile.in: Regenerate. * man/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. Index: libffi/include/ffi.h.in =================================================================== --- libffi/include/ffi.h.in (revision 205058) +++ libffi/include/ffi.h.in (working copy) @@ -207,6 +207,11 @@ #endif } ffi_cif; +#if HAVE_LONG_DOUBLE_VARIANT +/* Used to adjust size/alignment of ffi types. */ +void ffi_prep_types (ffi_abi abi); +# endif + /* Used internally, but overridden by some architectures */ ffi_status ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, Index: libffi/src/prep_cif.c =================================================================== --- libffi/src/prep_cif.c (revision 205058) +++ libffi/src/prep_cif.c (working copy) @@ -126,6 +126,10 @@ cif->flags = 0; +#if HAVE_LONG_DOUBLE_VARIANT + ffi_prep_types (abi); +#endif + /* Initialize the return type if necessary */ if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK)) return FFI_BAD_TYPEDEF; Index: libffi/configure.ac =================================================================== --- libffi/configure.ac (revision 205058) +++ libffi/configure.ac (working copy) @@ -65,6 +65,7 @@ AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite) TARGETDIR="unknown" +HAVE_LONG_DOUBLE_VARIANT=0 case "$host" in aarch64*-*-*) TARGET=AARCH64; TARGETDIR=aarch64 @@ -162,6 +163,7 @@ powerpc*-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc + HAVE_LONG_DOUBLE_VARIANT=1 ;; powerpc-*-amigaos*) TARGET=POWERPC; TARGETDIR=powerpc @@ -177,6 +179,7 @@ ;; powerpc-*-freebsd* | powerpc-*-openbsd*) TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc + HAVE_LONG_DOUBLE_VARIANT=1 ;; powerpc64-*-freebsd*) TARGET=POWERPC; TARGETDIR=powerpc @@ -273,14 +276,20 @@ # Also AC_SUBST this variable for ffi.h. if test -z "$HAVE_LONG_DOUBLE"; then HAVE_LONG_DOUBLE=0 - if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then - if test $ac_cv_sizeof_long_double != 0; then + if test $ac_cv_sizeof_long_double != 0; then + if test $HAVE_LONG_DOUBLE_VARIANT != 0; then + AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type]) HAVE_LONG_DOUBLE=1 - AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double]) + else + if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then + HAVE_LONG_DOUBLE=1 + AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double]) + fi fi fi fi AC_SUBST(HAVE_LONG_DOUBLE) +AC_SUBST(HAVE_LONG_DOUBLE_VARIANT) AC_C_BIGENDIAN Index: libffi/Makefile.am =================================================================== --- libffi/Makefile.am (revision 205058) +++ libffi/Makefile.am (working copy) @@ -15,10 +15,12 @@ src/ia64/unix.S src/mips/ffi.c src/mips/n32.S src/mips/o32.S \ src/mips/ffitarget.h src/m32r/ffi.c src/m32r/sysv.S \ src/m32r/ffitarget.h src/m68k/ffi.c src/m68k/sysv.S \ - src/m68k/ffitarget.h src/powerpc/ffi.c src/powerpc/sysv.S \ - src/powerpc/linux64.S src/powerpc/linux64_closure.S \ - src/powerpc/ppc_closure.S src/powerpc/asm.h \ - src/powerpc/aix.S src/powerpc/darwin.S \ + src/m68k/ffitarget.h \ + src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \ + src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \ + src/powerpc/sysv.S src/powerpc/linux64.S \ + src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ + src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \ src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \ src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \ src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \ @@ -179,7 +181,7 @@ nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S endif if POWERPC -nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S +nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S endif if POWERPC_AIX nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S @@ -188,7 +190,7 @@ nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S endif if POWERPC_FREEBSD -nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S +nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S endif if AARCH64 nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c -- Alan Modra Australia Development Lab, IBM