Hi ports --

devel/libffi failed to build for me on my Orange Pi Zero (armv7) using the latest snapshot. It's a clang thing, FreeBSD dealt with it like such: https://github.com/libffi/libffi/issues/162
So let's do the same thing.

The change in patches/patch_src_arm_ffi_c is also necessary. Without it, trying to build
py-setuptools Abort Traps immediately. With the patch, everything seems OK.

However, a ton of tests fail:
# of expected passes            10
# of unexpected failures        685
# of unresolved testcases       675
But I don't know the previous state of things. So I don't know if this is a change or as
expected.

Finally, it looks like libffi needs libc++abi on arm for at least some functions, as experienced with lang/snobol4, its configure script didn't pick up libffi and instead
complained about this:
/usr/local/lib/libffi.so.1.2: undefined reference to `__aeabi_unwind_cpp_pr0' /usr/local/lib/libffi.so.1.2: undefined reference to `__aeabi_unwind_cpp_pr1'
Those functions are in libc++abi.

Also taking suggestions for #ifdef __arm__ defines in the event they would also catch
arm64.

Comments/OK?

~Brian

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/libffi/Makefile,v
retrieving revision 1.35
diff -u -p -r1.35 Makefile
--- Makefile	26 May 2016 20:48:50 -0000	1.35
+++ Makefile	21 Jan 2018 05:11:17 -0000
@@ -3,7 +3,7 @@
 COMMENT=		Foreign Function Interface
 
 DISTNAME=		libffi-3.2.1
-REVISION=		2
+REVISION=		3
 SHARED_LIBS +=  ffi                  1.2      # .6.4
 CATEGORIES=		devel
 
Index: patches/patch-src_arm_ffi_c
===================================================================
RCS file: /cvs/ports/devel/libffi/patches/patch-src_arm_ffi_c,v
retrieving revision 1.7
diff -u -p -r1.7 patch-src_arm_ffi_c
--- patches/patch-src_arm_ffi_c	15 Jul 2015 17:06:48 -0000	1.7
+++ patches/patch-src_arm_ffi_c	21 Jan 2018 05:11:17 -0000
@@ -1,15 +1,36 @@
 $OpenBSD: patch-src_arm_ffi_c,v 1.7 2015/07/15 17:06:48 jasper Exp $
 
-Fix warning: implicit declaration of function '__clear_cache'
+https://svnweb.freebsd.org/ports/head/devel/libffi/files/patch-src__arm__ffi.c?revision=337118&view=markup
 
---- src/arm/ffi.c.orig	Fri Apr 25 19:45:13 2014
-+++ src/arm/ffi.c	Mon Sep 15 22:00:37 2014
-@@ -37,6 +37,8 @@
+Index: src/arm/ffi.c
+--- src/arm/ffi.c.orig
++++ src/arm/ffi.c
+@@ -33,6 +33,11 @@
+ 
+ #include <stdlib.h>
+ 
++#ifdef __arm__
++#include <machine/sysarch.h>
++#include <stdint.h>
++#endif
++
+ /* Forward declares. */
  static int vfp_type_p (ffi_type *);
  static void layout_vfp_args (ffi_cif *);
+@@ -750,6 +755,16 @@ ffi_closure_free (void *ptr)
+ }
  
-+extern void __clear_cache(char *beg, char *end);
+ #else
 +
- int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space);
- int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space);
++#ifdef __arm__
++#define __clear_cache(start, end) do {					\
++		struct arm_sync_icache_args ua;				\
++									\
++		ua.addr = (uintptr_t)(start);				\
++		ua.len = (char *)(end) - (char *)start;			\
++		sysarch(ARM_SYNC_ICACHE, &ua);				\
++	} while (0);
++#endif
  
+ #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX)				\
+ ({ unsigned char *__tramp = (unsigned char*)(TRAMP);			\
Index: patches/patch-src_arm_sysv_S
===================================================================
RCS file: patches/patch-src_arm_sysv_S
diff -N patches/patch-src_arm_sysv_S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_arm_sysv_S	21 Jan 2018 05:11:17 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+https://github.com/libffi/libffi/issues/162
+
+Index: src/arm/sysv.S
+--- src/arm/sysv.S.orig
++++ src/arm/sysv.S
+@@ -396,7 +396,7 @@ LSYM(Lbase_args):
+ 	beq	LSYM(Lepilogue_vfp)
+ 
+ 	cmp	r3, #FFI_TYPE_SINT64
+-	stmeqia	r2, {r0, r1}
++	stmiaeq	r2, {r0, r1}
+ 	beq	LSYM(Lepilogue_vfp)
+ 
+ 	cmp	r3, #FFI_TYPE_FLOAT

Reply via email to