dev-libs/libffi: fix ppc64 build, bug 713596
authorSergei Trofimovich <slyfox@gentoo.org>
Sun, 29 Mar 2020 14:06:02 +0000 (15:06 +0100)
committerSergei Trofimovich <slyfox@gentoo.org>
Sun, 29 Mar 2020 14:06:10 +0000 (15:06 +0100)
Backport fixes for older power targets without explicit __int128 support.

Reported-by: Agostino Sarubbo
Closes: https://bugs.gentoo.org/713596
Package-Manager: Portage-2.3.96, Repoman-2.3.22
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
dev-libs/libffi/files/libffi-3.3-power7-memcpy-2.patch [new file with mode: 0644]
dev-libs/libffi/files/libffi-3.3-power7-memcpy.patch [new file with mode: 0644]
dev-libs/libffi/libffi-3.3-r1.ebuild

diff --git a/dev-libs/libffi/files/libffi-3.3-power7-memcpy-2.patch b/dev-libs/libffi/files/libffi-3.3-power7-memcpy-2.patch
new file mode 100644 (file)
index 0000000..d9d47ac
--- /dev/null
@@ -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/files/libffi-3.3-power7-memcpy.patch b/dev-libs/libffi/files/libffi-3.3-power7-memcpy.patch
new file mode 100644 (file)
index 0000000..91f9a6f
--- /dev/null
@@ -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
+
index cbc8682f8c1bb2b4508d9fa8df7802ad133d796d..79f1d5d690eadb4073909272f3d72b01b870553e 100644 (file)
@@ -28,6 +28,8 @@ PATCHES=(
        "${FILESDIR}"/${PN}-3.2.1-o-tmpfile-eacces.patch #529044
        "${FILESDIR}"/${PN}-3.3_rc0-ppc-macos-go.patch
        "${FILESDIR}"/${PN}-3.3-power7.patch
+       "${FILESDIR}"/${PN}-3.3-power7-memcpy.patch
+       "${FILESDIR}"/${PN}-3.3-power7-memcpy-2.patch
 )
 
 S=${WORKDIR}/${MY_P}