On Thu, 29 Jul 2021 14:57:28 +0000 Charlene Wendling <juliana...@posteo.jp> wrote:
> Hi, > > George emitted the hypothesis that libffi may be partly broken on > macppc. He was right :) > > After searching around, i found out that upstream has already a fix for > that [0]. Tests results have improved a lot: > > Before the below diff: > > # of expected passes 440 > # of unexpected failures 104 > > After the below diff: > > # of expected passes 530 > # of unexpected failures 14 Thank you for finding this diff! ok gkoehler@ The patched code is inside #ifndef POWERPC64, so there is no change on powerpc64. There are 10 "unexpected failures" on powerpc64. Now I hope that our libffi consumers might get lucky and dodge the few remaining failures on powerpc*. macppc and powerpc64: 2 failures in libffi.call/float2.c -- They fail because our <float.h>'s LBDL_EPSILON is a double, not a long double, so printf("%Lf", LDBL_EPSILON) warns. macppc only: 10 failures in libffi.bhaible/test-call.c 2 failures in libffi.call/many.c -- These pass more than 8 floating-point arguments. Args after registers f1 .. f8 must go on the stack. powerpc64 only: 2 failures in libffi.call/va_1.c 2 failures in libffi.call/va_struct1.c 2 failures in libffi.call/va_struct2.c 2 failures in libffi.call/va_struct3.c -- These do va_arg(3) with a struct. --George > I have been able to build gforth on macppc and make it run with that > patched libffi. Finally. I'll send a diff for gforth after that one, > some extra bits are required. > > I think no further consumer testing is really needed, given the > spectacular change in tests results, we should assume the libffi we're > shipping on macppc currently is in a pretty bad shape anyway. > > Comments/feedback are welcome, > > Charlène. > > > [0] https://github.com/libffi/libffi/commit/4d6d2866 > > > Index: Makefile > =================================================================== > RCS file: /cvs/ports/devel/libffi/Makefile,v > retrieving revision 1.43 > diff -u -p -u -p -r1.43 Makefile > --- Makefile 11 Jun 2021 15:37:14 -0000 1.43 > +++ Makefile 29 Jul 2021 13:54:53 -0000 > @@ -3,7 +3,7 @@ > COMMENT= Foreign Function Interface > > DISTNAME= libffi-3.3 > -REVISION= 0 > +REVISION= 1 > SHARED_LIBS += ffi 1.2 # .6.4 > CATEGORIES= devel > > Index: patches/patch-src_powerpc_sysv_S > =================================================================== > RCS file: patches/patch-src_powerpc_sysv_S > diff -N patches/patch-src_powerpc_sysv_S > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ patches/patch-src_powerpc_sysv_S 29 Jul 2021 13:54:53 -0000 > @@ -0,0 +1,48 @@ > +$OpenBSD$ > + > +From 4d6d2866ae43e55325e8ee96561221804602cd7a Mon Sep 17 00:00:00 2001 > +From: Samuel Holland <sam...@sholland.org> > +Date: Fri, 21 Feb 2020 21:06:15 -0600 > +Subject: [PATCH] Update powerpc sysv assembly for ffi_powerpc.h changes > (#541) > + > +Some of the flag bits were moved when adding powerpc64 vector support. > + > +Fixes #536 > + > +Index: src/powerpc/sysv.S > +--- src/powerpc/sysv.S.orig > ++++ src/powerpc/sysv.S > +@@ -104,17 +104,16 @@ ENTRY(ffi_call_SYSV) > + bctrl > + > + /* Now, deal with the return value. */ > +- mtcrf 0x01,%r31 /* cr7 */ > ++ mtcrf 0x03,%r31 /* cr6-cr7 */ > + bt- 31,L(small_struct_return_value) > + bt- 30,L(done_return_value) > + #ifndef __NO_FPRS__ > + bt- 29,L(fp_return_value) > + #endif > + stw %r3,0(%r30) > +- bf+ 28,L(done_return_value) > ++ bf+ 27,L(done_return_value) > + stw %r4,4(%r30) > +- mtcrf 0x02,%r31 /* cr6 */ > +- bf 27,L(done_return_value) > ++ bf 26,L(done_return_value) > + stw %r5,8(%r30) > + stw %r6,12(%r30) > + /* Fall through... */ > +@@ -145,10 +144,9 @@ L(done_return_value): > + #ifndef __NO_FPRS__ > + L(fp_return_value): > + .cfi_restore_state > +- bf 28,L(float_return_value) > ++ bf 27,L(float_return_value) > + stfd %f1,0(%r30) > +- mtcrf 0x02,%r31 /* cr6 */ > +- bf 27,L(done_return_value) > ++ bf 26,L(done_return_value) > + stfd %f2,8(%r30) > + b L(done_return_value) > + L(float_return_value): -- George Koehler <kern...@gmail.com>