Hello Jasper, ports@

I wanted to update java/jna (to work with jdk-11) but that needs an
updated libffi too.

The development of libffi seems to have moved to github, at least for
the release tarballs, and some patches were upstreamed.

Regarding the shlib version: looking at check_sym it seems to warrant
only a minor bump (5 symbols added) but upstream bumped the major 2
years ago with this commit:

https://github.com/libffi/libffi/commit/7855656148b96c7070ec362d2a73af840025a2b7

the change to FFI_TRAMPOLINE_SIZE probably requires a major bump; I went
with it to stay on the safe side.

The list of consumer is daunting and I can't test everything nor run a
bulk.  So far I tested on amd64:

 - java/jna: (post update, see other thread) builds fine + all tests passing
 - lang/gforth: builds fine + all tests passing
 - lang/guile2: builds fine + and ffi tests are passing
 - lang/python/3.9: builds fine and the failing tests don't seem to be
   related to libffi
 - lang/ruby/3.1: like python-3.9

plus some testing with guile3 (not in ports yet.)  I have the build and
tests log for these I can share if needed.

Comments and further testing (especially on !amd64) is appreciated :)


The changelog is:

    Add static trampoline support for Linux on x86_64 and ARM64.
    Add support for Alibaba's CSKY architecture.
    Add support for Kalray's KVX architecture.
    Add support for Intel Control-flow Enforcement Technology (CET).
    Add support for ARM Pointer Authentication (PA).
    Fix 32-bit PPC regression.
    Fix MIPS soft-float problem.
    Enable tmpdir override with the $LIBFFI_TMPDIR environment variable.
    Enable compatibility with MSVC runtime stack checking.
    Reject float and small integer argument in ffi_prep_cif_var().
      Callers must promote these types themselves.


Index: Makefile
===================================================================
RCS file: /home/cvs/ports/devel/libffi/Makefile,v
retrieving revision 1.45
diff -u -p -r1.45 Makefile
--- Makefile    11 Mar 2022 18:50:31 -0000      1.45
+++ Makefile    14 May 2022 09:09:29 -0000
@@ -1,8 +1,8 @@
 COMMENT=               Foreign Function Interface
 
-DISTNAME=              libffi-3.3
-REVISION=              1
-SHARED_LIBS +=  ffi                  1.2      # .6.4
+V=                     3.4.2
+DISTNAME=              libffi-$V
+SHARED_LIBS +=  ffi                  2.0      # 9.0
 CATEGORIES=            devel
 
 MAINTAINER=            Jasper Lievisse Adriaanse <jas...@openbsd.org>
@@ -17,8 +17,7 @@ PERMIT_PACKAGE=       Yes
 WANTLIB += c++abi
 .endif
 
-MASTER_SITES=          https://sourceware.org/pub/libffi/ \
-                       ftp://sourceware.org/pub/libffi/
+MASTER_SITES= https://github.com/libffi/libffi/releases/download/v$V/
 
 DEBUG_PACKAGES =       ${BUILD_PACKAGES}
 
Index: distinfo
===================================================================
RCS file: /home/cvs/ports/devel/libffi/distinfo,v
retrieving revision 1.6
diff -u -p -r1.6 distinfo
--- distinfo    10 Feb 2020 18:06:34 -0000      1.6
+++ distinfo    14 May 2022 09:05:38 -0000
@@ -1,2 +1,2 @@
-SHA256 (libffi-3.3.tar.gz) = cvunkicD3fp6Ao1ROsFahcjVTI1n9V+lpIAohdxlIFY=
-SIZE (libffi-3.3.tar.gz) = 1305466
+SHA256 (libffi-3.4.2.tar.gz) = VA+3IWGaaro73u99lA2Ong5tLBk1lbwkMkG3f/npNiA=
+SIZE (libffi-3.4.2.tar.gz) = 1351355
Index: patches/patch-configure
===================================================================
RCS file: /home/cvs/ports/devel/libffi/patches/patch-configure,v
retrieving revision 1.12
diff -u -p -r1.12 patch-configure
--- patches/patch-configure     11 Mar 2022 18:50:31 -0000      1.12
+++ patches/patch-configure     14 May 2022 09:06:48 -0000
@@ -3,7 +3,7 @@
 Index: configure
 --- configure.orig
 +++ configure
-@@ -18475,6 +18475,12 @@ $as_echo "#define SYMBOL_UNDERSCORE 1" >>confdefs.h
+@@ -18650,6 +18650,12 @@ $as_echo "#define SYMBOL_UNDERSCORE 1" >>confdefs.h
  
  fi
  
Index: patches/patch-configure_host
===================================================================
RCS file: /home/cvs/ports/devel/libffi/patches/patch-configure_host,v
retrieving revision 1.2
diff -u -p -r1.2 patch-configure_host
--- patches/patch-configure_host        11 Mar 2022 18:50:31 -0000      1.2
+++ patches/patch-configure_host        14 May 2022 09:06:48 -0000
@@ -1,12 +1,12 @@
 Index: configure.host
 --- configure.host.orig
 +++ configure.host
-@@ -203,7 +203,7 @@ case "${host}" in
+@@ -216,7 +216,7 @@ case "${host}" in
        TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
-       HAVE_LONG_DOUBLE_VARIANT=1
+       CFLAGS="$CFLAGS -D__NO_FPRS__"
        ;;
--  powerpc64-*-freebsd*)
-+  powerpc64-*-freebsd* | powerpc64-*-openbsd*)
+-  powerpc64-*-freebsd* | powerpc64le-*-freebsd*)
++  powerpc64-*-freebsd* | powerpc64le-*-freebsd* | powerpc64-*-openbsd*)
        TARGET=POWERPC; TARGETDIR=powerpc
        ;;
    powerpc*-*-rtems*)
Index: patches/patch-src_arm_ffi_c
===================================================================
RCS file: /home/cvs/ports/devel/libffi/patches/patch-src_arm_ffi_c,v
retrieving revision 1.10
diff -u -p -r1.10 patch-src_arm_ffi_c
--- patches/patch-src_arm_ffi_c 11 Mar 2022 18:50:31 -0000      1.10
+++ patches/patch-src_arm_ffi_c 14 May 2022 09:06:48 -0000
@@ -3,8 +3,8 @@ https://svnweb.freebsd.org/ports/head/de
 Index: src/arm/ffi.c
 --- src/arm/ffi.c.orig
 +++ src/arm/ffi.c
-@@ -55,6 +55,11 @@ extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN;
- #endif
+@@ -64,6 +64,11 @@ extern unsigned char ffi_arm_trampoline[12] FFI_HIDDEN
+ #include <machine/sysarch.h>
  #endif
  
 +#ifdef __arm__
@@ -15,7 +15,7 @@ Index: src/arm/ffi.c
  /* Forward declares. */
  static int vfp_type_p (const ffi_type *);
  static void layout_vfp_args (ffi_cif *);
-@@ -591,6 +596,16 @@ ffi_prep_closure_loc (ffi_closure * closure,
+@@ -621,6 +626,16 @@ ffi_prep_closure_loc (ffi_closure * closure,
    config[0] = closure;
    config[1] = closure_func;
  #else
@@ -30,5 +30,5 @@ Index: src/arm/ffi.c
 +      } while (0);
 +#endif
  
- #ifndef _M_ARM
-   memcpy(closure->tramp, ffi_arm_trampoline, 8);
+ #if defined(FFI_EXEC_STATIC_TRAMP)
+   if (ffi_tramp_is_present(closure))
Index: patches/patch-src_closures_c
===================================================================
RCS file: /home/cvs/ports/devel/libffi/patches/patch-src_closures_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-src_closures_c
--- patches/patch-src_closures_c        11 Mar 2022 18:50:31 -0000      1.3
+++ patches/patch-src_closures_c        14 May 2022 09:06:48 -0000
@@ -1,15 +1,15 @@
 Index: src/closures.c
 --- src/closures.c.orig
 +++ src/closures.c
-@@ -837,6 +837,7 @@ dlmmap (void *start, size_t length, int prot,
-         && flags == (MAP_PRIVATE | MAP_ANONYMOUS)
-         && fd == -1 && offset == 0);
+@@ -878,6 +878,7 @@ dlmmap (void *start, size_t length, int prot,
+       return ptr;
+     }
  
 +#if 0
    if (execfd == -1 && is_emutramp_enabled ())
      {
        ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
-@@ -855,6 +856,7 @@ dlmmap (void *start, size_t length, int prot,
+@@ -896,6 +897,7 @@ dlmmap (void *start, size_t length, int prot,
         with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with
         MREMAP_DUP and prot at this point.  */
      }
Index: patches/patch-src_mips_n32_S
===================================================================
RCS file: patches/patch-src_mips_n32_S
diff -N patches/patch-src_mips_n32_S
--- patches/patch-src_mips_n32_S        11 Mar 2022 18:50:31 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-Use EH_FRAME_FLAGS to get section flags that clang's integrated assembler
-expects. This fixes the following build error on mips64:
-
-../src/mips/n32.S:585:9: error: changed section flags for .eh_frame, expected: 
0x2
-        .section .eh_frame,"aw",@progbits
-        ^
-
-Index: src/mips/n32.S
---- src/mips/n32.S.orig
-+++ src/mips/n32.S
-@@ -582,7 +582,7 @@ cls_epilogue:      
-       .end    ffi_closure_N32
- 
- #ifdef __GNUC__
--        .section        .eh_frame,"aw",@progbits
-+        .section        .eh_frame,EH_FRAME_FLAGS,@progbits
- .Lframe1:
-         .4byte  .LECIE1-.LSCIE1               # length
- .LSCIE1:
Index: patches/patch-src_powerpc_ffi_powerpc_h
===================================================================
RCS file: patches/patch-src_powerpc_ffi_powerpc_h
diff -N patches/patch-src_powerpc_ffi_powerpc_h
--- patches/patch-src_powerpc_ffi_powerpc_h     11 Mar 2022 18:50:31 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-Fix for:
-../src/powerpc/ffi_powerpc.h:105: error: expected declaration
-specifiers or '...' before 'float128'
-From:
-https://github.com/libffi/libffi/pull/532/commits/2138adb2a5b6a0bc2fe3518e0645eacc89b6f392
-
-Index: src/powerpc/ffi_powerpc.h
---- src/powerpc/ffi_powerpc.h.orig
-+++ src/powerpc/ffi_powerpc.h
-@@ -62,7 +62,7 @@ typedef _Float128 float128;
- #elif defined(__FLOAT128__)
- typedef __float128 float128;
- #else
--typedef __int128 float128;
-+typedef char float128[16] __attribute__((aligned(16)));
- #endif
- 
- void FFI_HIDDEN ffi_closure_SYSV (void);
Index: patches/patch-src_powerpc_sysv_S
===================================================================
RCS file: patches/patch-src_powerpc_sysv_S
diff -N patches/patch-src_powerpc_sysv_S
--- patches/patch-src_powerpc_sysv_S    11 Mar 2022 18:50:31 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-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):
Index: patches/patch-testsuite_lib_libffi_exp
===================================================================
RCS file: /home/cvs/ports/devel/libffi/patches/patch-testsuite_lib_libffi_exp,v
retrieving revision 1.3
diff -u -p -r1.3 patch-testsuite_lib_libffi_exp
--- patches/patch-testsuite_lib_libffi_exp      11 Mar 2022 18:50:31 -0000      
1.3
+++ patches/patch-testsuite_lib_libffi_exp      14 May 2022 09:06:48 -0000
@@ -3,7 +3,7 @@ cc1: error: unrecognized command line op
 Index: testsuite/lib/libffi.exp
 --- testsuite/lib/libffi.exp.orig
 +++ testsuite/lib/libffi.exp
-@@ -488,7 +488,7 @@ proc run-many-tests { testcases extra_flags } {
+@@ -491,7 +491,7 @@ proc run-many-tests { testcases extra_flags } {
          }
        }
        "gnu" {

Reply via email to