+cc maintainer

On Sun, Jan 21 2018, Brian Callahan <bcal...@devio.us> wrote:
> On 01/21/18 08:13, Peter Hessler wrote:
>> On 2018 Jan 21 (Sun) at 02:06:52 -0500 (-0500), Brian Callahan wrote:
>> :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.
>> :
>>
>> Did you mean to include a patch to libffi.pc to address these issues?
>>
>>
>
> Ugh. No more 2am diffs more me.
>
> We just want this to be for arm, of course, to avoid breaking all gcc
> archs. Attached diff deals.

I think it would be better to link libffi against -lc++abi, inter-libs deps
would be enough and would ensure that consumers don't need to use
pkg-config.  static builds would still need the pkg-config goo, but we
don't have static archs any more.  Do we have such ports?

The diff below also adds c++abi to WANTLIB.

Test summary:
  # of expected passes            1845
  # of unexpected failures        15

Now testing some consumer ports.


Index: Makefile
===================================================================
RCS file: /d/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 19:41:05 -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
 
@@ -15,6 +15,10 @@ HOMEPAGE=            http://sourceware.org/libffi/
 PERMIT_PACKAGE_CDROM=  Yes
 
 WANTLIB += pthread
+# needed for unwind symbols
+.if ${MACHINE_ARCH} == "arm"
+WANTLIB += c++abi
+.endif
 
 MASTER_SITES=          ftp://sourceware.org/pub/libffi/
 
Index: patches/patch-configure
===================================================================
RCS file: /d/cvs/ports/devel/libffi/patches/patch-configure,v
retrieving revision 1.7
diff -u -p -r1.7 patch-configure
--- patches/patch-configure     28 Jan 2016 08:40:47 -0000      1.7
+++ patches/patch-configure     21 Jan 2018 19:34:49 -0000
@@ -1,14 +1,19 @@
 $OpenBSD: patch-configure,v 1.7 2016/01/28 08:40:47 jasper Exp $
 
-- Always link with -pthread for libffi
+- Always link with -pthread for libffi (XXX not needed any more?)
+- Link with libc++abi on arm (to access unwind symbols)
 
---- configure.orig     Tue Jan 26 18:55:54 2016
-+++ configure  Tue Jan 26 18:56:20 2016
-@@ -18522,6 +18522,12 @@ $as_echo "#define SYMBOL_UNDERSCORE 1" >>confdefs.h
+Index: configure
+--- configure.orig
++++ configure
+@@ -18522,6 +18522,15 @@ $as_echo "#define SYMBOL_UNDERSCORE 1" >>confdefs.h
  
  fi
  
 +case "$target" in
++    arm-*-openbsd*)
++      LDFLAGS="-lpthread -lc++abi $LDFLAGS"
++    ;;
 +    *-*-openbsd*)
 +      LDFLAGS="-lpthread $LDFLAGS"
 +    ;;
Index: patches/patch-src_arm_ffi_c
===================================================================
RCS file: /d/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 19:34:49 -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 19:34:10 -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


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to