summaryrefslogtreecommitdiff
path: root/dev-libs/libffi-compat
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2021-07-28 10:27:13 +0100
committerV3n3RiX <venerix@redcorelinux.org>2021-07-28 10:27:13 +0100
commitf4fc10428424904caf2035cffc442195cb088b2c (patch)
tree72f320d5963e55586cfdeed2b14c72b8191b6327 /dev-libs/libffi-compat
parentfbd9734cedfe790955100b8e4ab3613457d77b1a (diff)
gentoo resync : 28.07.2021
Diffstat (limited to 'dev-libs/libffi-compat')
-rw-r--r--dev-libs/libffi-compat/Manifest9
-rw-r--r--dev-libs/libffi-compat/files/libffi-3.3-compiler-vendor-quote.patch33
-rw-r--r--dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy-2.patch28
-rw-r--r--dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy.patch42
-rw-r--r--dev-libs/libffi-compat/files/libffi-3.3-power7.patch39
-rw-r--r--dev-libs/libffi-compat/files/libffi-3.3-ppc-int128.patch63
-rw-r--r--dev-libs/libffi-compat/files/libffi-3.3-ppc-vector-offset.patch53
-rw-r--r--dev-libs/libffi-compat/files/libffi-3.3_rc0-ppc-macos-go.patch79
-rw-r--r--dev-libs/libffi-compat/libffi-compat-3.3-r2.ebuild71
9 files changed, 417 insertions, 0 deletions
diff --git a/dev-libs/libffi-compat/Manifest b/dev-libs/libffi-compat/Manifest
index acc4a549c98d..fdfbfde8e7db 100644
--- a/dev-libs/libffi-compat/Manifest
+++ b/dev-libs/libffi-compat/Manifest
@@ -6,6 +6,15 @@ AUX libffi-3.2.1-include-path-autogen.patch 2901 BLAKE2B 836e61b6f64b9d649e96979
AUX libffi-3.2.1-include-path.patch 1156 BLAKE2B b5842f5dc6462edac0a5f58265246599d0283bb148f954fb79d8037e37ae332a664f57a201589b89022d63932d8a4e56c4b0c6a7a9a2240ae6602e847fff3a55 SHA512 f387590510ee5e3aedc03744fcf1faae35c105a81d4c2f646e495d489bc6467cd88d4a0a63b40a29fe620ad71db1a05c1fe483af63974222f366135f73f36cb3
AUX libffi-3.2.1-musl-emutramp.patch 1182 BLAKE2B 44db381b87d3f3f85b60379398b1a1d97437e14a8ab75d1035ee1cf498a6cb79b6d68a3a38d87e9e16ddd74d66a585064831a5e9370227289f2ddd297d90542d SHA512 cfd5106226fa45beaecf3b7eb039d77f5113e393b9e958625b8d015550daaea527365938a97f2ce5286777662df4848d6112961cb76653d8335950a734da43c5
AUX libffi-3.2.1-o-tmpfile-eacces.patch 660 BLAKE2B 651067a56e0bd0980a696ad12c8fa76d68d914fa370fb93c3f5f5759dd4837895a077510606fa451beafb75e7da19f42a9f88e3d56d6c283f684da695ad69960 SHA512 0887063ce1d812c31a34d662f852cf2944e008f2f60bd07941572f9032861e749968b090686e0d788f7cc3c5c8f1ed2388418ff000c42fd2d592f9837e782f65
+AUX libffi-3.3-compiler-vendor-quote.patch 896 BLAKE2B 6c2895f821f11f3e41bf078c8ae5d4b97c50ec0db007380f6d33159adc7e2101a6db21b6513db2cd596834c5d71dd36be63c5d108ed79de6b91b4d281b019d71 SHA512 e7ab9255af8528e6b9b7ce3fd4a016d6b67b24e27aa00131d2240aadc4dc599ea33492944641608146e123a6cd363df411f614436cb999eadc2e840e7de93f77
+AUX libffi-3.3-power7-memcpy-2.patch 1086 BLAKE2B 954504aca37f2dd16913c3fb3d61e8fb5e8db017d897405905366f4701bf2357871dd41e86e59050733f04321e0155b03683577f132504aec5c476cc78323be6 SHA512 5a0d8590c2e53e20e4384dad704060a2c781b91487a0e14d2f1521f69b722ccc60e25b84c38f9ded65b01bef49250e07c6935be577d100aea18496abfbe374f5
+AUX libffi-3.3-power7-memcpy.patch 1681 BLAKE2B 6e3df741b07718f13c347ae54fe82bbf0f433790d14dff4114ffa77f2c3700460801af3fc5a649589ab2d1d0122db0729cd1aaa5321ea3f7822b1cd4d7f64b05 SHA512 13eb09d8080cadedb959c8d62d37f80bf3c32fbe488fdb59955ff6c8649f1086baaedb015e47ee52de65836f57bc172dbce2d2b3bc1aee6aca07eb9da451cf70
+AUX libffi-3.3-power7.patch 1172 BLAKE2B 42408c0774553fde9c086ea3c2b0d0152d15a9dce63860e8884c683ce92553c3db38d6fdddcdee644f7819f56a28a12e639ee05a0956cf0fa3fed521157754f7 SHA512 17062f152ce2aa8d46e4e01c3c0b8e52c67d30c3405b9b2f40656dfe731c774fd67ff3ad397f426d9e56ca4fe4ec4908f5c8f6082d52975cf19171ca4e39c534
+AUX libffi-3.3-ppc-int128.patch 2309 BLAKE2B 5b0c89e8f9f63329d2cb796d23b3a22c48b7761956e18fd383636efdc75e2558cb5d6615dd1ec965034d93061314711ee2ad533f49522a365049d5451bcebf19 SHA512 3b47dde00428ebc536f0f73fc7295d4c554f65a35502e855e808893eb3940d68f903a96cd6f24f0eb5f83a405d10bb83feef19538e490ceeeba99a22a0b96bcd
+AUX libffi-3.3-ppc-vector-offset.patch 1425 BLAKE2B 334ed26ea082c603cfbf43d37e9cf64ac34a7054857743a9fbf5d05c7226402dfec4fd955cc3dc5652f57712bbaadcd0551ff727cfd8f8305edf38daa9814be2 SHA512 742ef73d95e39eefcbcfb423c4729966a31bf88ff00d20eab6c4db1db04e97f53784bf29111c57c577d1f6264735ee4ed797b4537a74d0ae1753de2990cd3ce9
+AUX libffi-3.3_rc0-ppc-macos-go.patch 2100 BLAKE2B 7ae1309b08be9293acee042d141bb632b0763af9e14200ef7206db763b01e289a68ce544709c8abc5a86adca5f1c0c895c6bf24f667429b118bf660ffa95bb39 SHA512 4684b87f1d36a0098ebde7996e4417718b3535eb66ec7c619be74fa30e4446849c246b491cad3aea1ac44bdf9e9fbf6e952000cb85299faf5b1d8598136b184b
DIST libffi-3.2.1.tar.gz 940837 BLAKE2B d202ccaa185acfd2476ed2a9b011891507cd8efbbda60f67c583268d1563853442ed829acecbf81c9b6b9a930345780bb7a4bd80e71e50ef544c7f4eab8cb01f SHA512 980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483
+DIST libffi-3.3.tar.gz 1305466 BLAKE2B cddc40729a30a9bd34d675809f51f8d1b4ccaffa54bc6dd6f7e965f4e260edd34754719f9f6247c8957aeb7cf154d56ce1fe16a54c3f1ad39afbebdf41d23caa SHA512 61513801a156f11420f541d325de697131846487122d6bdcf5491b18b4da788589f5c0bb07e88e396495d3be5830d74e9135595e2b8ddbfe95c448d8597fbd6f
EBUILD libffi-compat-3.2.1-r3.ebuild 1578 BLAKE2B 1c703cf741a6486569641aa4236b4fad5af5c22b29da819dd5bb81d51273f3789ba7fd110d3dd1d329e8784b09f0cf5b19607fe42acc2520e5ba2ea98019e708 SHA512 b7f515de893e823e87a161a030951e69e8d15daaff7693083ff6ea9d00211fcdbe4443b263e61b69e683603fb43e453a9379996bb450f58a7b51a1afb63571ad
+EBUILD libffi-compat-3.3-r2.ebuild 2283 BLAKE2B 320f8e454a49c764cff191b57fd4f09c68ec78eaae8fa4ef575daadf39fe7f2e2c886ac73d23bf1cf287cc99aa7e1f1509b517ffbabcb07266e8c33380cd05cd SHA512 4dcc6a336f7d42feec074bb20b0c9f0ea1e0a2979d9ebf6aeb35d7fe56c9454c2bee693e08bea637251f7e7a87e2ad8dbf149819f759fe879eb87d5671ec34b4
MISC metadata.xml 1956 BLAKE2B 950088c8250c7ef8bdf87ab5ff06a04a2bd96cb39fad1c7a04f4bfef89ea06d75e38b389d3c4425a79c0663da4276b15803d6955cccdcd49c94238530ac75cb0 SHA512 bd173f87493e8100483813d27556ddb86214fcd8870412b0100562c66b02e01fff37dc68e9ada1aa2e5b68bf79b30dd02b1306ff408ed9dace5bfe765880a333
diff --git a/dev-libs/libffi-compat/files/libffi-3.3-compiler-vendor-quote.patch b/dev-libs/libffi-compat/files/libffi-3.3-compiler-vendor-quote.patch
new file mode 100644
index 000000000000..db5b69ce2db9
--- /dev/null
+++ b/dev-libs/libffi-compat/files/libffi-3.3-compiler-vendor-quote.patch
@@ -0,0 +1,33 @@
+https://bugs.gentoo.org/753299
+--- a/testsuite/lib/libffi.exp
++++ b/testsuite/lib/libffi.exp
+@@ -287,9 +287,6 @@ proc libffi-init { args } {
+ verbose "libffi $blddirffi"
+
+ # Which compiler are we building with?
+- set tmp [grep "$blddirffi/config.log" "^ax_cv_c_compiler_vendor.*$"]
+- regexp -- {^[^=]*=(.*)$} $tmp nil compiler_vendor
+-
+ if { [string match $compiler_vendor "gnu"] } {
+ set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+ if {$gccdir != ""} {
+--- a/configure.ac
++++ b/configure.ac
+@@ -59,6 +59,7 @@ fi
+ cat > local.exp <<EOF
+ set CC_FOR_TARGET "$CC"
+ set CXX_FOR_TARGET "$CXX"
++set compiler_vendor "$ax_cv_c_compiler_vendor"
+ EOF
+
+ AM_MAINTAINER_MODE
+--- a/configure
++++ b/configure
+@@ -17402,6 +17402,7 @@ fi
+ cat > local.exp <<EOF
+ set CC_FOR_TARGET "$CC"
+ set CXX_FOR_TARGET "$CXX"
++set compiler_vendor "$ax_cv_c_compiler_vendor"
+ EOF
+
+
diff --git a/dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy-2.patch b/dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy-2.patch
new file mode 100644
index 000000000000..d9d47acb618f
--- /dev/null
+++ b/dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy-2.patch
@@ -0,0 +1,28 @@
+From 6663047f56c2932a6b10a790f4ac6666dd181326 Mon Sep 17 00:00:00 2001
+From: Anthony Green <green@moxielogic.com>
+Date: Fri, 29 Nov 2019 07:00:35 -0500
+Subject: [PATCH] Address platforms with no __int128.
+
+---
+ src/powerpc/ffi_linux64.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/powerpc/ffi_linux64.c b/src/powerpc/ffi_linux64.c
+index de0d033..7364770 100644
+--- a/src/powerpc/ffi_linux64.c
++++ b/src/powerpc/ffi_linux64.c
+@@ -547,9 +547,9 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
+ if (next_arg.ul == gpr_end.ul)
+ next_arg.ul = rest.ul;
+ if (vecarg_count < NUM_VEC_ARG_REGISTERS64 && i < nfixedargs)
+- *vec_base.f128++ = **p_argv.f128;
++ memcpy (vec_base.f128++, *p_argv.f128, sizeof (float128));
+ else
+- *next_arg.f128 = **p_argv.f128;
++ memcpy (next_arg.f128, *p_argv.f128, sizeof (float128));
+ if (++next_arg.f128 == gpr_end.f128)
+ next_arg.f128 = rest.f128;
+ vecarg_count++;
+--
+2.26.0
+
diff --git a/dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy.patch b/dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy.patch
new file mode 100644
index 000000000000..91f9a6f60fae
--- /dev/null
+++ b/dev-libs/libffi-compat/files/libffi-3.3-power7-memcpy.patch
@@ -0,0 +1,42 @@
+From e50b9ef8b910fa642ef158f6642e60d54d7ad740 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 7 Dec 2019 02:34:14 -0800
+Subject: [PATCH] powerpc64: Use memcpy to help platforms with no __int128.
+ (#534)
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/powerpc/ffi_linux64.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/powerpc/ffi_linux64.c b/src/powerpc/ffi_linux64.c
+index 7364770..4d50878 100644
+--- a/src/powerpc/ffi_linux64.c
++++ b/src/powerpc/ffi_linux64.c
+@@ -680,9 +680,9 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
+ {
+ if (vecarg_count < NUM_VEC_ARG_REGISTERS64
+ && i < nfixedargs)
+- *vec_base.f128++ = *arg.f128++;
++ memcpy (vec_base.f128++, arg.f128, sizeof (float128));
+ else
+- *next_arg.f128 = *arg.f128++;
++ memcpy (next_arg.f128, arg.f128++, sizeof (float128));
+ if (++next_arg.f128 == gpr_end.f128)
+ next_arg.f128 = rest.f128;
+ vecarg_count++;
+@@ -986,9 +986,9 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
+ do
+ {
+ if (pvec < end_pvec && i < nfixedargs)
+- *to.f128 = *pvec++;
++ memcpy (to.f128, pvec++, sizeof (float128));
+ else
+- *to.f128 = *from.f128;
++ memcpy (to.f128, from.f128, sizeof (float128));
+ to.f128++;
+ from.f128++;
+ }
+--
+2.26.0
+
diff --git a/dev-libs/libffi-compat/files/libffi-3.3-power7.patch b/dev-libs/libffi-compat/files/libffi-3.3-power7.patch
new file mode 100644
index 000000000000..83f518f4c2e3
--- /dev/null
+++ b/dev-libs/libffi-compat/files/libffi-3.3-power7.patch
@@ -0,0 +1,39 @@
+https://bugs.gentoo.org/701128
+
+From 2138adb2a5b6a0bc2fe3518e0645eacc89b6f392 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu, 28 Nov 2019 00:02:42 +0000
+Subject: [PATCH] powerpc: fix build failure on power7 and older
+
+Build failure looks as:
+```
+libtool: compile: powerpc-unknown-linux-gnu-gcc \
+ -O2 -mcpu=powerpc -mtune=powerpc -pipe ... -c src/powerpc/ffi.c ...
+In file included from src/powerpc/ffi.c:33:
+src/powerpc/ffi_powerpc.h:65:9: error: '__int128' is not supported on this target
+ 65 | typedef __int128 float128;
+ | ^~~~~~~~
+```
+
+The fix avoids using __int128 in favour of aligned char[16].
+
+Closes: https://github.com/libffi/libffi/issues/531
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ src/powerpc/ffi_powerpc.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/src/powerpc/ffi_powerpc.h
++++ b/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);
+--
+2.24.0
+
diff --git a/dev-libs/libffi-compat/files/libffi-3.3-ppc-int128.patch b/dev-libs/libffi-compat/files/libffi-3.3-ppc-int128.patch
new file mode 100644
index 000000000000..ed53ae99902f
--- /dev/null
+++ b/dev-libs/libffi-compat/files/libffi-3.3-ppc-int128.patch
@@ -0,0 +1,63 @@
+From 4f9e20ac51ce13d46fed3c869e1deb6d9bb89444 Mon Sep 17 00:00:00 2001
+From: Andrew Geissler <geissonator@users.noreply.github.com>
+Date: Fri, 1 May 2020 06:58:30 -0500
+Subject: [PATCH] ffi_powerpc.h: fix build failure with powerpc7 (#561)
+
+This is a patch pulled down from the following:
+https://github.com/buildroot/buildroot/blob/78926f610b1411b03464152472fd430012deb9ac/package/libffi/0004-ffi_powerpc.h-fix-build-failure-with-powerpc7.patch
+
+This issue is being hit on OpenBMC code when pulling the latest
+libffi tag and building on a P8 ppc64le machine. I verified this
+patch fixes the issue we are seeing.
+
+Below is the original commit message:
+
+Sicne commit 73dd43afc8a447ba98ea02e9aad4c6898dc77fb0, build on powerpc7
+fails on:
+
+In file included from ../src/powerpc/ffi.c:33:0:
+../src/powerpc/ffi_powerpc.h:61:9: error: '_Float128' is not supported on this target
+ typedef _Float128 float128;
+ ^~~~~~~~~
+
+Fix this build failure by checking for __HAVE_FLOAT128 before using
+_Float128, as _Float128 is enabled only on specific conditions, see
+output/host/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/floatn.h:
+
+ /* Defined to 1 if the current compiler invocation provides a
+ floating-point type with the IEEE 754 binary128 format, and this glibc
+ includes corresponding *f128 interfaces for it. */
+ #if defined _ARCH_PWR8 && defined __LITTLE_ENDIAN__ && (_CALL_ELF == 2) \
+ && defined __FLOAT128__ && !defined __NO_LONG_DOUBLE_MATH
+ # define __HAVE_FLOAT128 1
+ #else
+ # define __HAVE_FLOAT128 0
+ #endif
+
+Fixes:
+ - http://autobuild.buildroot.org/results/5c9dd8fb3b6a128882b6250f197c80232d8a3b53
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
+
+Co-authored-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ src/powerpc/ffi_powerpc.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/powerpc/ffi_powerpc.h b/src/powerpc/ffi_powerpc.h
+index 8e2f2f0..960a5c4 100644
+--- a/src/powerpc/ffi_powerpc.h
++++ b/src/powerpc/ffi_powerpc.h
+@@ -57,7 +57,7 @@ typedef union
+ double d;
+ } ffi_dblfl;
+
+-#if defined(__FLOAT128_TYPE__)
++#if defined(__FLOAT128_TYPE__) && defined(__HAVE_FLOAT128)
+ typedef _Float128 float128;
+ #elif defined(__FLOAT128__)
+ typedef __float128 float128;
+--
+2.27.0
+
diff --git a/dev-libs/libffi-compat/files/libffi-3.3-ppc-vector-offset.patch b/dev-libs/libffi-compat/files/libffi-3.3-ppc-vector-offset.patch
new file mode 100644
index 000000000000..4bcd27e4f152
--- /dev/null
+++ b/dev-libs/libffi-compat/files/libffi-3.3-ppc-vector-offset.patch
@@ -0,0 +1,53 @@
+From 4d6d2866ae43e55325e8ee96561221804602cd7a Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@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
+---
+ src/powerpc/sysv.S | 12 +++++-------
+ 1 file changed, 5 insertions(+), 7 deletions(-)
+
+diff --git a/src/powerpc/sysv.S b/src/powerpc/sysv.S
+index 1474ce7..df97734 100644
+--- a/src/powerpc/sysv.S
++++ b/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):
+--
+2.27.0
+
diff --git a/dev-libs/libffi-compat/files/libffi-3.3_rc0-ppc-macos-go.patch b/dev-libs/libffi-compat/files/libffi-3.3_rc0-ppc-macos-go.patch
new file mode 100644
index 000000000000..88f9b4557657
--- /dev/null
+++ b/dev-libs/libffi-compat/files/libffi-3.3_rc0-ppc-macos-go.patch
@@ -0,0 +1,79 @@
+ffi_darwin: use FFI_GO_CLOSURES guard to avoid unsolvable dependencies
+
+The go calls depend on compilation and link-time signatures and symbols
+which are missing because they aren't build due to FFO_GO_CLOSURES not
+being set.
+
+Signed-off-by: Fabian Groffen <grobian@gentoo.org>
+
+--- a/src/powerpc/ffi_darwin.c 2018-04-02 14:21:51.000000000 +0200
++++ b/src/powerpc/ffi_darwin.c 2018-12-10 13:57:26.000000000 +0100
+@@ -909,8 +909,10 @@
+ extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
+ void (*fn)(void), void (*fn2)(void));
+
++#if FFI_GO_CLOSURES
+ extern void ffi_call_go_AIX(extended_cif *, long, unsigned, unsigned *,
+ void (*fn)(void), void (*fn2)(void), void *closure);
++#endif
+
+ extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
+ void (*fn)(void), void (*fn2)(void), ffi_type*);
+@@ -950,6 +952,7 @@
+ }
+ }
+
++#if FFI_GO_CLOSURES
+ void
+ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
+ void *closure)
+@@ -981,6 +984,7 @@
+ break;
+ }
+ }
++#endif
+
+ static void flush_icache(char *);
+ static void flush_range(char *, int);
+@@ -1110,6 +1114,7 @@
+ return FFI_OK;
+ }
+
++#if FFI_GO_CLOSURES
+ ffi_status
+ ffi_prep_go_closure (ffi_go_closure* closure,
+ ffi_cif* cif,
+@@ -1133,6 +1138,7 @@
+ }
+ return FFI_OK;
+ }
++#endif
+
+ static void
+ flush_icache(char *addr)
+@@ -1168,9 +1174,11 @@
+ ffi_closure_helper_DARWIN (ffi_closure *, void *,
+ unsigned long *, ffi_dblfl *);
+
++#if FFI_GO_CLOSURES
+ ffi_type *
+ ffi_go_closure_helper_DARWIN (ffi_go_closure*, void *,
+ unsigned long *, ffi_dblfl *);
++#endif
+
+ /* Basically the trampoline invokes ffi_closure_ASM, and on
+ entry, r11 holds the address of the closure.
+@@ -1430,6 +1438,7 @@
+ closure->user_data, rvalue, pgr, pfr);
+ }
+
++#if FFI_GO_CLOSURES
+ ffi_type *
+ ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue,
+ unsigned long *pgr, ffi_dblfl *pfr)
+@@ -1437,4 +1446,5 @@
+ return ffi_closure_helper_common (closure->cif, closure->fun,
+ closure, rvalue, pgr, pfr);
+ }
++#endif
+
diff --git a/dev-libs/libffi-compat/libffi-compat-3.3-r2.ebuild b/dev-libs/libffi-compat/libffi-compat-3.3-r2.ebuild
new file mode 100644
index 000000000000..2cfc48a26b21
--- /dev/null
+++ b/dev-libs/libffi-compat/libffi-compat-3.3-r2.ebuild
@@ -0,0 +1,71 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit libtool multilib-minimal
+
+DESCRIPTION="a portable, high level programming interface to various calling conventions"
+HOMEPAGE="https://sourceware.org/libffi/"
+SRC_URI="https://github.com/libffi/libffi/releases/download/v${PV}/libffi-${PV}.tar.gz"
+
+LICENSE="MIT"
+SLOT="7" # SONAME=libffi.so.7
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="debug pax-kernel test"
+
+RESTRICT="!test? ( test )"
+
+RDEPEND="!dev-libs/libffi:0/7" # conflicts on libffi.so.7
+DEPEND=""
+BDEPEND="test? ( dev-util/dejagnu )"
+
+DOCS="ChangeLog* README.md"
+
+PATCHES=(
+ "${FILESDIR}"/libffi-3.2.1-o-tmpfile-eacces.patch #529044
+ "${FILESDIR}"/libffi-3.3_rc0-ppc-macos-go.patch
+ "${FILESDIR}"/libffi-3.3-power7.patch
+ "${FILESDIR}"/libffi-3.3-power7-memcpy.patch
+ "${FILESDIR}"/libffi-3.3-power7-memcpy-2.patch
+ "${FILESDIR}"/libffi-3.3-ppc-int128.patch
+ "${FILESDIR}"/libffi-3.3-ppc-vector-offset.patch
+ "${FILESDIR}"/libffi-3.3-compiler-vendor-quote.patch
+)
+
+S=${WORKDIR}/libffi-${PV}
+
+ECONF_SOURCE=${S}
+
+src_prepare() {
+ default
+ if [[ ${CHOST} == arm64-*-darwin* ]] ; then
+ # ensure we use aarch64 asm, not x86 on arm64
+ sed -i -e 's/aarch64\*-\*-\*/arm64*-*-*|&/' \
+ configure configure.host || die
+ fi
+}
+
+multilib_src_configure() {
+ use userland_BSD && export HOST="${CHOST}"
+ # --includedir= path maintains a few properties:
+ # 1. have stable name across libffi versions: some packages like
+ # dev-lang/ghc or kde-frameworks/networkmanager-qt embed
+ # ${includedir} at build-time. Don't require those to be
+ # rebuilt unless SONAME changes. bug #695788
+ #
+ # We use /usr/.../${PN} (instead of former /usr/.../${P}).
+ #
+ # 2. have ${ABI}-specific location as ffi.h is target-dependent.
+ #
+ # We use /usr/$(get_libdir)/... to have ABI identifier.
+ econf \
+ --includedir="${EPREFIX}"/usr/$(get_libdir)/${PN}/include \
+ --disable-multi-os-directory \
+ --disable-static \
+ $(use_enable pax-kernel pax_emutramp) \
+ $(use_enable debug)
+}
+
+multilib_src_install() {
+ dolib.so .libs/libffi.so.${SLOT}*
+}