add new port devel/libffi321

Add a new port, devel/libffi321, which is a stripped down version of libffi
3.2.1.  This version only brings in the shared library from libffi 3.2.1
(the libffi 3.3.0 update bumped the version number of the shlib) for binary
consumers that can't easily be recompiled and updated against the new
version of libffi.
This version is not meant to be linked against, and you should not depend on
it to bring libffi in, unless you explicitly need the binary compat.
Libraries are installed in ${LOCALBASE}/lib/compat.

PR:		247028 (for tracking)
Requested by:	arrowd
Tested by:	arrowd
This commit is contained in:
Niclas Zeising 2020-07-06 19:03:52 +00:00
parent 66fcec0e75
commit 46cf2d293b
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=541359
12 changed files with 1750 additions and 0 deletions

View File

@ -1165,6 +1165,7 @@
SUBDIR += libfastjson
SUBDIR += libffcall
SUBDIR += libffi
SUBDIR += libffi321
SUBDIR += libfirm
SUBDIR += libfixposix
SUBDIR += libflatarray

24
devel/libffi321/Makefile Normal file
View File

@ -0,0 +1,24 @@
# Created by: Horance Chou <horance@freedom.ie.cycu.edu.tw>
# $FreeBSD$
PORTNAME= libffi
PORTVERSION= 3.2.1
CATEGORIES= devel
MASTER_SITES= SOURCEWARE/${PORTNAME}
PKGNAMESUFFIX= 321
MAINTAINER= zeising@FreeBSD.org
COMMENT= Foreign Function Interface (stripped down compat version)
LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= libtool
USE_LDCONFIG= yes
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --libdir=${PREFIX}/lib/compat \
--disable-static
INSTALL_TARGET= install-strip
.include <bsd.port.mk>

2
devel/libffi321/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (libffi-3.2.1.tar.gz) = d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37
SIZE (libffi-3.2.1.tar.gz) = 940837

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,112 @@
# Clang doesn't like the -Wno-psabi argument that we want to pass to GCC.
# Since clang is detected as GCC via __GNUC__, use ax_cv_c_compiler_vendor.
# https://github.com/atgreen/libffi/commit/b5ade2fb5d9ba06519484677a5474e5dad48c2e3
diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp
index 5051d31..0e92bb0 100644
--- testsuite/lib/libffi.exp
+++ testsuite/lib/libffi.exp
@@ -100,46 +100,39 @@ proc libffi-init { args } {
global libffi_link_flags
global tool_root_dir
global ld_library_path
-
- global using_gcc
+ global compiler_vendor
set blddirffi [pwd]/..
verbose "libffi $blddirffi"
- # Are we building with GCC?
- set tmp [grep ../config.status "GCC='yes'"]
- if { [string match $tmp "GCC='yes'"] } {
-
- set using_gcc "yes"
+ # Which compiler are we building with?
+ set tmp [grep ../config.log "^ax_cv_c_compiler_vendor.*$"]
+ regexp -- {^[^=]*=(.*)$} $tmp nil compiler_vendor
- set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
- if {$gccdir != ""} {
- set gccdir [file dirname $gccdir]
- }
- verbose "gccdir $gccdir"
-
- set ld_library_path "."
- append ld_library_path ":${gccdir}"
-
- set compiler "${gccdir}/xgcc"
- if { [is_remote host] == 0 && [which $compiler] != 0 } {
- foreach i "[exec $compiler --print-multi-lib]" {
- set mldir ""
- regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
- set mldir [string trimright $mldir "\;@"]
- if { "$mldir" == "." } {
- continue
- }
- if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
- append ld_library_path ":${gccdir}/${mldir}"
+ if { [string match $compiler_vendor "gnu"] } {
+ set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+ if {$gccdir != ""} {
+ set gccdir [file dirname $gccdir]
+ }
+ verbose "gccdir $gccdir"
+
+ set ld_library_path "."
+ append ld_library_path ":${gccdir}"
+
+ set compiler "${gccdir}/xgcc"
+ if { [is_remote host] == 0 && [which $compiler] != 0 } {
+ foreach i "[exec $compiler --print-multi-lib]" {
+ set mldir ""
+ regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+ set mldir [string trimright $mldir "\;@"]
+ if { "$mldir" == "." } {
+ continue
+ }
+ if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+ append ld_library_path ":${gccdir}/${mldir}"
+ }
}
- }
- }
-
- } else {
-
- set using_gcc "no"
-
+ }
}
# add the library path for libffi.
@@ -278,18 +271,25 @@ proc libffi-dg-runtest { testcases default-extra-flags } {
}
proc run-many-tests { testcases extra_flags } {
- global using_gcc
- if { [string match $using_gcc "yes"] } {
+ global compiler_vendor
+ switch $compiler_vendor {
+ "clang" {
+ set common "-W -Wall"
+ set optimizations { "-O0" "-O1" "-O2" "-O3" "-Os" }
+ }
+ "gnu" {
set common "-W -Wall -Wno-psabi"
set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" }
- } else {
+ }
+ default {
# Assume we are using the vendor compiler.
set common ""
set optimizations { "" }
+ }
}
set targetabis { "" }
- if [string match $using_gcc "yes"] {
+ if [string match $compiler_vendor "gnu"] {
if [istarget "i?86-*-*"] {
set targetabis {
""

View File

@ -0,0 +1,124 @@
--- configure.orig 2014-11-12 11:59:57 UTC
+++ configure
@@ -17221,7 +17221,7 @@ case "$host" in
mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
TARGET=MIPS; TARGETDIR=mips
;;
- mips*-*linux* | mips*-*-openbsd*)
+ mips*-*linux* | mips*-*-openbsd* | mips*-*-freebsd*)
# Support 128-bit long double for NewABI.
HAVE_LONG_DOUBLE='defined(__mips64)'
TARGET=MIPS; TARGETDIR=mips
@@ -17255,6 +17255,10 @@ case "$host" in
TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
HAVE_LONG_DOUBLE_VARIANT=1
;;
+ powerpcspe-*-freebsd*)
+ TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+ CFLAGS="$CFLAGS -D__NO_FPRS__"
+ ;;
powerpc64-*-freebsd*)
TARGET=POWERPC; TARGETDIR=powerpc
;;
@@ -18289,7 +18293,8 @@ $as_echo "#define HAVE_AS_CFI_PSEUDO_OP 1" >>confdefs.
fi
-if test x$TARGET = xSPARC; then
+case "$TARGET" in
+ SPARC)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler and linker support unaligned pc related relocs" >&5
$as_echo_n "checking assembler and linker support unaligned pc related relocs... " >&6; }
if ${libffi_cv_as_sparc_ua_pcrel+:} false; then :
@@ -18363,9 +18368,9 @@ $as_echo "$libffi_cv_as_register_pseudo_op" >&6; }
$as_echo "#define HAVE_AS_REGISTER_PSEUDO_OP 1" >>confdefs.h
fi
-fi
+ ;;
-if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
+ X86*)
{ $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; }
$as_echo "#define HAVE_AS_X86_PCREL 1" >>confdefs.h
fi
-
- { $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 :
- $as_echo_n "(cached) " >&6
-else
-
- libffi_cv_as_ascii_pseudo_op=unknown
- # Check if we have .ascii
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-asm (".ascii \\"string\\"");
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- libffi_cv_as_ascii_pseudo_op=yes
-else
- libffi_cv_as_ascii_pseudo_op=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_ascii_pseudo_op" >&5
-$as_echo "$libffi_cv_as_ascii_pseudo_op" >&6; }
- if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
-
-$as_echo "#define HAVE_AS_ASCII_PSEUDO_OP 1" >>confdefs.h
-
- fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .string pseudo-op support" >&5
-$as_echo_n "checking assembler .string pseudo-op support... " >&6; }
-if ${libffi_cv_as_string_pseudo_op+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- libffi_cv_as_string_pseudo_op=unknown
- # Check if we have .string
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-asm (".string \\"string\\"");
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- libffi_cv_as_string_pseudo_op=yes
-else
- libffi_cv_as_string_pseudo_op=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_string_pseudo_op" >&5
-$as_echo "$libffi_cv_as_string_pseudo_op" >&6; }
- if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
-
-$as_echo "#define HAVE_AS_STRING_PSEUDO_OP 1" >>confdefs.h
-
- fi
-fi
+ ;;
+esac
# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
# Check whether --enable-pax_emutramp was given.

View File

@ -0,0 +1,36 @@
# Description: Fix abort() on ARM related to __clear_cache(). This is an issue
# for anything !apple that is using the libcompiler_rt provided by clang on ARM
# 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
@@ -33,6 +33,11 @@
#include <stdlib.h>
+#if defined(__FreeBSD__) && defined(__arm__)
+#include <sys/types.h>
+#include <machine/sysarch.h>
+#endif
+
/* Forward declares. */
static int vfp_type_p (ffi_type *);
static void layout_vfp_args (ffi_cif *);
@@ -582,6 +587,16 @@
#else
+#if defined(__FreeBSD__) && defined(__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); \
unsigned int __fun = (unsigned int)(FUN); \

View File

@ -0,0 +1,29 @@
diff --git ./src/mips/ffi.c.orig ./src/mips/ffi.c
index 03121e3..8b7881f 100644
--- ./src/mips/ffi.c.orig
+++ ./src/mips/ffi.c
@@ -38,7 +38,9 @@
#endif
#ifndef USE__BUILTIN___CLEAR_CACHE
-# if defined(__OpenBSD__)
+# if defined(__FreeBSD__)
+# include <machine/sysarch.h>
+# elif defined(__OpenBSD__)
# include <mips64/sysarch.h>
# else
# include <sys/cachectl.h>
@@ -729,11 +731,13 @@ ffi_prep_closure_loc (ffi_closure *closure,
closure->fun = fun;
closure->user_data = user_data;
+#if !defined(__FreeBSD__)
#ifdef USE__BUILTIN___CLEAR_CACHE
__builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE);
#else
cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE);
#endif
+#endif /* ! __FreeBSD__ */
return FFI_OK;
}

View File

@ -0,0 +1,13 @@
diff --git ./src/mips/ffitarget.h.orig ./src/mips/ffitarget.h
index 717d659..5a0c2b1 100644
--- ./src/mips/ffitarget.h.orig
+++ ./src/mips/ffitarget.h
@@ -41,7 +41,7 @@
#define _MIPS_SIM_ABI32 1
#define _MIPS_SIM_NABI32 2
#define _MIPS_SIM_ABI64 3
-#elif !defined(__OpenBSD__)
+#elif !defined(__OpenBSD__) && !defined(__FreeBSD__)
# include <sgidefs.h>
#endif

View File

@ -0,0 +1,55 @@
# Description: 3.2.1 fails to build with clang 3.5.0 on arm
# Issue ID: https://github.com/atgreen/libffi/issues/162
# Submitted by: sbruno
--- src/arm/sysv.S.orig 2015-01-01 10:47:51 UTC
+++ src/arm/sysv.S
@@ -360,7 +360,7 @@ ARM_FUNC_START(ffi_call_VFP)
cmp r0, #3
sub ip, fp, #64
flddle d0, [ip]
- fldmiadgt ip, {d0-d7}
+ vldmiagt ip, {d0-d7}
LSYM(Lbase_args):
@ move first 4 parameters in registers
@@ -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
@@ -409,7 +409,7 @@ LSYM(Lbase_args):
cmp r3, #FFI_TYPE_STRUCT_VFP_FLOAT
cmpne r3, #FFI_TYPE_STRUCT_VFP_DOUBLE
- fstmiadeq r2, {d0-d3}
+ vstmiaeq r2, {d0-d3}
LSYM(Lepilogue_vfp):
RETLDM "r0-r3,fp"
@@ -420,7 +420,7 @@ LSYM(Lepilogue_vfp):
ARM_FUNC_START(ffi_closure_VFP)
- fstmfdd sp!, {d0-d7}
+ vstmdb sp!, {d0-d7}
@ r0-r3, then d0-d7
UNWIND .pad #80
add ip, sp, #80
@@ -470,10 +470,10 @@ ARM_FUNC_START(ffi_closure_VFP)
ldmia sp, {r0, r1}
b .Lclosure_epilogue_vfp
.Lretfloat_struct_vfp:
- fldmiad sp, {d0-d1}
+ vldmia sp, {d0-d1}
b .Lclosure_epilogue_vfp
.Lretdouble_struct_vfp:
- fldmiad sp, {d0-d3}
+ vldmia sp, {d0-d3}
b .Lclosure_epilogue_vfp
.ffi_closure_VFP_end:

10
devel/libffi321/pkg-descr Normal file
View File

@ -0,0 +1,10 @@
The libffi library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run
time.
This version has the old shared library version from libffi 3.2.1.
It is stripped down and only brings in the shared library. It is
not meant to build against.
WWW: http://sources.redhat.com/libffi/

View File

@ -0,0 +1,3 @@
lib/compat/libffi.so
lib/compat/libffi.so.6
lib/compat/libffi.so.6.0.4