commit:     6364a6a2e066d377e04f3b1f1cbf17ac215d63ec
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  7 21:58:55 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue Jul  7 21:59:47 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6364a6a2

dev-libs/libffi: backport upstream ppc32 fixes

USE=test-bhaible exposed a few invalid type handlers.
Enable it by default for tests.

Package-Manager: Portage-2.3.103, Repoman-2.3.23
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 dev-libs/libffi/files/libffi-3.3-ppc-int128.patch  | 63 ++++++++++++++++
 .../files/libffi-3.3-ppc-vector-offset.patch       | 53 +++++++++++++
 dev-libs/libffi/libffi-3.3-r2.ebuild               | 88 ++++++++++++++++++++++
 3 files changed, 204 insertions(+)

diff --git a/dev-libs/libffi/files/libffi-3.3-ppc-int128.patch 
b/dev-libs/libffi/files/libffi-3.3-ppc-int128.patch
new file mode 100644
index 00000000000..ed53ae99902
--- /dev/null
+++ b/dev-libs/libffi/files/libffi-3.3-ppc-int128.patch
@@ -0,0 +1,63 @@
+From 4f9e20ac51ce13d46fed3c869e1deb6d9bb89444 Mon Sep 17 00:00:00 2001
+From: Andrew Geissler <geissona...@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.fabr...@gmail.com>
+Signed-off-by: Andrew Geissler <geissona...@yahoo.com>
+
+Co-authored-by: Fabrice Fontaine <fontaine.fabr...@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/files/libffi-3.3-ppc-vector-offset.patch 
b/dev-libs/libffi/files/libffi-3.3-ppc-vector-offset.patch
new file mode 100644
index 00000000000..4bcd27e4f15
--- /dev/null
+++ b/dev-libs/libffi/files/libffi-3.3-ppc-vector-offset.patch
@@ -0,0 +1,53 @@
+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
+---
+ 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/libffi-3.3-r2.ebuild 
b/dev-libs/libffi/libffi-3.3-r2.ebuild
new file mode 100644
index 00000000000..22591c89471
--- /dev/null
+++ b/dev-libs/libffi/libffi-3.3-r2.ebuild
@@ -0,0 +1,88 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit multilib multilib-minimal toolchain-funcs
+
+MY_PV=${PV/_rc/-rc}
+MY_P=${PN}-${MY_PV}
+
+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${MY_PV}/${MY_P}.tar.gz";
+
+LICENSE="MIT"
+SLOT="0/7" # SONAME=libffi.so.7
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos 
~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris 
~x86-solaris"
+IUSE="debug pax_kernel static-libs test +test-bhaible"
+
+RESTRICT="!test? ( test )"
+
+RDEPEND=""
+DEPEND=""
+BDEPEND="test? ( dev-util/dejagnu )"
+
+DOCS="ChangeLog* README.md"
+
+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
+       "${FILESDIR}"/${PN}-3.3-ppc-int128.patch
+       "${FILESDIR}"/${PN}-3.3-ppc-vector-offset.patch
+)
+
+S=${WORKDIR}/${MY_P}
+
+ECONF_SOURCE=${S}
+
+pkg_setup() {
+       # Check for orphaned libffi, see https://bugs.gentoo.org/354903 for 
example
+       if [[ ${ROOT} == "/" && ${EPREFIX} == "" ]] && ! has_version 
${CATEGORY}/${PN}; then
+               local base="${T}"/conftest
+               echo 'int main() { }' > "${base}".c
+               $(tc-getCC) -o "${base}" "${base}".c -lffi >&/dev/null
+               if [ $? -eq 0 ]; then
+                       eerror "The linker reported linking against -lffi to be 
working while it shouldn't have."
+                       eerror "This is wrong and you should find and delete 
the old copy of libffi before continuing."
+                       die "The system is in inconsistent state with unknown 
libffi installed."
+               fi
+       fi
+}
+
+src_prepare() {
+       default
+
+       if ! use test-bhaible; then
+               # These tests are very heavyweight (hours of runtime)
+               rm -v testsuite/libffi.bhaible/bhaible.exp || 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 \
+               $(use_enable static-libs static) \
+               $(use_enable pax_kernel pax_emutramp) \
+               $(use_enable debug)
+}
+
+multilib_src_install_all() {
+       find "${ED}" -name "*.la" -delete || die
+       einstalldocs
+}

Reply via email to