You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the detailed report — both observations are spot on. #951 added a switch in ffi_closure_helper_common() that returns PPC_LD_* jump-table indexes, but never defined those constants in ffi_darwin.c (they live in ffi_powerpc.h, which this file deliberately does not include — it has its own, differing FLAG_* enum and ffi_dblfl), and left the function signatures returning ffi_type *.
The patch below:
Defines the PPC_LD_* constants locally in ffi_darwin.c, mirroring ffi_powerpc.h with the same POWERPC64 conditional. The values match the jump tables in aix_closure.S for both the 64-bit path (PPC_LD_U32=10, PPC_LD_S32=11) and the 32-bit path (where U32/S32 collapse to PPC_LD_R3 and I64 to PPC_LD_R3R4).
Changes the return type of ffi_closure_helper_common(), ffi_closure_helper_DARWIN(), and ffi_go_closure_helper_DARWIN() (and the two forward prototypes) from ffi_type * to int, since the value is an integer index consumed by the assembly (r3 × 16 → jump table), consistent with ffi_closure_helper_SYSV/ffi_closure_helper_LINUX64.
I don't have AIX/Darwin PowerPC hardware to build-test this, so it would be great if you could confirm it builds and runs on your end.
diff --git a/src/powerpc/ffi_darwin.c b/src/powerpc/ffi_darwin.c
index 126367e1..d62737f4 100644
--- a/src/powerpc/ffi_darwin.c+++ b/src/powerpc/ffi_darwin.c@@ -39,6 +39,33 @@ struct ffi_aix_trampoline_struct {
void * static_chain; /* Pointer to closure */
};
+/* Closure jump table indexes returned by ffi_closure_helper_common and+ consumed by the jump tables in aix_closure.S. These mirror the+ definitions in ffi_powerpc.h, which this file cannot include because+ it defines its own (differing) FLAG_* and ffi_dblfl. */+#define PPC_LD_NONE 0+#define PPC_LD_R3 1+#define PPC_LD_R3R4 2+#define PPC_LD_F32 3+#define PPC_LD_F64 4+#define PPC_LD_F128 5+#define PPC_LD_U8 6+#define PPC_LD_S8 7+#define PPC_LD_U16 8+#define PPC_LD_S16 9++#ifndef POWERPC64+# define PPC_LD_U32 PPC_LD_R3+# define PPC_LD_S32 PPC_LD_R3+# define PPC_LD_PTR PPC_LD_R3+# define PPC_LD_I64 PPC_LD_R3R4+#else+# define PPC_LD_U32 10+# define PPC_LD_S32 11+# define PPC_LD_PTR PPC_LD_R3+# define PPC_LD_I64 PPC_LD_R3+#endif+
extern void ffi_closure_ASM (void);
#if defined (FFI_GO_CLOSURES)
@@ -1192,12 +1219,12 @@ typedef union
double d;
} ffi_dblfl;
-ffi_type *+int
ffi_closure_helper_DARWIN (ffi_closure *, void *,
unsigned long *, ffi_dblfl *);
#if defined (FFI_GO_CLOSURES)
-ffi_type *+int
ffi_go_closure_helper_DARWIN (ffi_go_closure*, void *,
unsigned long *, ffi_dblfl *);
#endif
@@ -1209,7 +1236,7 @@ ffi_go_closure_helper_DARWIN (ffi_go_closure*, void *,
up space for a return value, ffi_closure_ASM invokes the
following helper function to do most of the work. */
-static ffi_type *+static int
ffi_closure_helper_common (ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*),
void *user_data, void *rvalue,
@@ -1485,7 +1512,7 @@ ffi_closure_helper_common (ffi_cif* cif,
}
}
-ffi_type *+int
ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
unsigned long *pgr, ffi_dblfl *pfr)
{
@@ -1494,7 +1521,7 @@ ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
}
#if defined (FFI_GO_CLOSURES)
-ffi_type *+int
ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue,
unsigned long *pgr, ffi_dblfl *pfr)
{
Activity
atgreen commentedon Jun 21, 2026
Thanks for the detailed report — both observations are spot on. #951 added a
switchinffi_closure_helper_common()that returnsPPC_LD_*jump-table indexes, but never defined those constants inffi_darwin.c(they live inffi_powerpc.h, which this file deliberately does not include — it has its own, differingFLAG_*enum andffi_dblfl), and left the function signatures returningffi_type *.The patch below:
PPC_LD_*constants locally inffi_darwin.c, mirroringffi_powerpc.hwith the samePOWERPC64conditional. The values match the jump tables inaix_closure.Sfor both the 64-bit path (PPC_LD_U32=10,PPC_LD_S32=11) and the 32-bit path (whereU32/S32collapse toPPC_LD_R3andI64toPPC_LD_R3R4).ffi_closure_helper_common(),ffi_closure_helper_DARWIN(), andffi_go_closure_helper_DARWIN()(and the two forward prototypes) fromffi_type *toint, since the value is an integer index consumed by the assembly (r3× 16 → jump table), consistent withffi_closure_helper_SYSV/ffi_closure_helper_LINUX64.I don't have AIX/Darwin PowerPC hardware to build-test this, so it would be great if you could confirm it builds and runs on your end.
Renegade334 commentedon Jun 21, 2026
Many thanks. With this patch, we get successful builds on aix-ppc64 with clang-20.
powerpc: fix aix/darwin closure build errors
barracuda156 commentedon Jun 22, 2026
@atgreen I will try this on Darwin.
Upd. Builds fine.
barracuda156 commentedon Jul 26, 2026
Unfortunately, the library does not work correctly now: #1002