devel/libffi: Fix build on i386 without objdump

FreeBSD 13 does not have any objdump in the default installation, which
causes issues with libffi on i386 with the recent update to llvm 11.
Add a patch originally from upstream, to use readelf instead of objdump.

The patch is for configure.ac originally.  I've applied it and rerun
autoreconf and committed the result, instead of adding a dependency on
autoreconf.

Fix devel/libffi321 in the same way.  While here, fix the fuzz on a few
other patches, which made it much easier to sort out the configure patch.

Thanks to dim@ for helping me figure out the issue.

MFH:		2020Q3
This commit is contained in:
Niclas Zeising 2020-08-20 11:34:28 +00:00
parent b1ea96541c
commit 1a3e10283d
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=545530
8 changed files with 70 additions and 25 deletions

View file

@ -3,11 +3,15 @@
PORTNAME= libffi
PORTVERSION= 3.3
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= SOURCEWARE/${PORTNAME}
PATCH_SITES= https://github.com/${PORTNAME}/${PORTNAME}/commit/
PATCHFILES= 01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd.patch:-p1
PATCHFILES+= 01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd.diff:-p1
# This patch is for configure.ac.
# A local patch against configure has been created in files/patch-configure.
#PATCHFILES+= 8c50837f0b58ba5b2bcb1b424a2a4bfa01559fb2.diff:-p1
MAINTAINER= zeising@FreeBSD.org
COMMENT= Foreign Function Interface

View file

@ -1,5 +1,5 @@
TIMESTAMP = 1595286570
TIMESTAMP = 1597921173
SHA256 (libffi-3.3.tar.gz) = 72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056
SIZE (libffi-3.3.tar.gz) = 1305466
SHA256 (01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd.patch) = 13299479bc5259456912afaf6d6d8fb97ed8e42938ff42902d4d7bcffe7d9660
SIZE (01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd.patch) = 1234
SHA256 (01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd.diff) = 627aac849e93debaa21cd85feb82b1a28cf481687a14717cf522eaec2a2b19aa
SIZE (01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd.diff) = 412

View file

@ -0,0 +1,23 @@
--- configure.orig 2020-08-20 10:54:03 UTC
+++ configure
@@ -18545,17 +18545,11 @@ if ${libffi_cv_ro_eh_frame+:} false; then :
$as_echo_n "(cached) " >&6
else
- libffi_cv_ro_eh_frame=no
+ libffi_cv_ro_eh_frame=yes
echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
- objdump -h conftest.o > conftest.dump 2>&1
- libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
- if test "x$libffi_eh_frame_line" != "x"; then
- libffi_test_line=`expr $libffi_eh_frame_line + 1`p
- sed -n $libffi_test_line conftest.dump > conftest.line
- if grep READONLY conftest.line > /dev/null; then
- libffi_cv_ro_eh_frame=yes
- fi
+ if readelf -WS conftest.o | grep -q -n 'eh_frame .* WA'; then
+ libffi_cv_ro_eh_frame=no
fi
fi
rm -f conftest.*

View file

@ -3,7 +3,7 @@
PORTNAME= libffi
PORTVERSION= 3.2.1
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= devel
MASTER_SITES= SOURCEWARE/${PORTNAME}
PKGNAMESUFFIX= 321

View file

@ -42,11 +42,13 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler supports pc related relocs" >&5
$as_echo_n "checking assembler supports pc related relocs... " >&6; }
if ${libffi_cv_as_x86_pcrel+:} false; then :
@@ -18386,77 +18391,8 @@ $as_echo "$libffi_cv_as_x86_pcrel" >&6; }
@@ -18386,78 +18391,9 @@ $as_echo "$libffi_cv_as_x86_pcrel" >&6; }
$as_echo "#define HAVE_AS_X86_PCREL 1" >>confdefs.h
fi
-
+ ;;
+esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .ascii pseudo-op support" >&5
-$as_echo_n "checking assembler .ascii pseudo-op support... " >&6; }
-if ${libffi_cv_as_ascii_pseudo_op+:} false; then :
@ -117,8 +119,28 @@
-
- fi
-fi
+ ;;
+esac
-
# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
# Check whether --enable-pax_emutramp was given.
if test "${enable_pax_emutramp+set}" = set; then :
@@ -18592,16 +18528,12 @@ if ${libffi_cv_ro_eh_frame+:} false; then :
$as_echo_n "(cached) " >&6
else
- libffi_cv_ro_eh_frame=no
+ libffi_cv_ro_eh_frame=yes
echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
- objdump -h conftest.o > conftest.dump 2>&1
- libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
- libffi_test_line=`expr $libffi_eh_frame_line + 1`p
- sed -n $libffi_test_line conftest.dump > conftest.line
- if grep READONLY conftest.line > /dev/null; then
- libffi_cv_ro_eh_frame=yes
- fi
+ if readelf -WS conftest.o | grep -q -n 'eh_frame .* WA'; then
+ libffi_cv_ro_eh_frame=no
+ fi
fi
rm -f conftest.*

View file

@ -3,8 +3,8 @@
# PR: ports/149167 ports/184517
# Patch by: cognet@ (to be upstreamed @ LLVM)
--- ./src/arm/ffi.c.orig 2013-03-16 22:19:39.000000000 +1100
+++ ./src/arm/ffi.c 2013-12-03 19:30:58.440924300 +1100
--- src/arm/ffi.c.orig 2014-11-08 12:47:24 UTC
+++ src/arm/ffi.c
@@ -33,6 +33,11 @@
#include <stdlib.h>
@ -17,10 +17,11 @@
/* Forward declares. */
static int vfp_type_p (ffi_type *);
static void layout_vfp_args (ffi_cif *);
@@ -582,6 +587,16 @@
@@ -750,6 +755,16 @@ ffi_closure_free (void *ptr)
}
#else
+
+#if defined(__FreeBSD__) && defined(__arm__)
+#define __clear_cache(start, end) do { \
+ struct arm_sync_icache_args ua; \
@ -30,7 +31,6 @@
+ sysarch(ARM_SYNC_ICACHE, &ua); \
+ } while (0);
+#endif
+
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \

View file

@ -1,7 +1,5 @@
diff --git ./src/mips/ffi.c.orig ./src/mips/ffi.c
index 03121e3..8b7881f 100644
--- ./src/mips/ffi.c.orig
+++ ./src/mips/ffi.c
--- src/mips/ffi.c.orig 2014-11-08 12:47:24 UTC
+++ src/mips/ffi.c
@@ -38,7 +38,9 @@
#endif
@ -13,7 +11,7 @@ index 03121e3..8b7881f 100644
# include <mips64/sysarch.h>
# else
# include <sys/cachectl.h>
@@ -729,11 +731,13 @@ ffi_prep_closure_loc (ffi_closure *closure,
@@ -736,11 +738,13 @@ ffi_prep_closure_loc (ffi_closure *closure,
closure->fun = fun;
closure->user_data = user_data;

View file

@ -1,7 +1,5 @@
diff --git ./src/mips/ffitarget.h.orig ./src/mips/ffitarget.h
index 717d659..5a0c2b1 100644
--- ./src/mips/ffitarget.h.orig
+++ ./src/mips/ffitarget.h
--- src/mips/ffitarget.h.orig 2014-11-08 12:47:24 UTC
+++ src/mips/ffitarget.h
@@ -41,7 +41,7 @@
#define _MIPS_SIM_ABI32 1
#define _MIPS_SIM_NABI32 2