diff --git a/make/target-libs.mk b/make/target-libs.mk index 059a465d..479d28a1 100644 --- a/make/target-libs.mk +++ b/make/target-libs.mk @@ -1184,23 +1184,22 @@ fribidi: $(DL_DIR)/$(FRIBIDI_SOURCE) | $(TARGET_DIR) # ----------------------------------------------------------------------------- -LIBFFI_VER = 3.2.1 +LIBFFI_VER = 3.3 LIBFFI_DIR = libffi-$(LIBFFI_VER) LIBFFI_SOURCE = libffi-$(LIBFFI_VER).tar.gz -LIBFFI_SITE = ftp://sourceware.org/pub/libffi +LIBFFI_SITE = $(call github,libffi,libffi,v$(LIBFFI_VERSION)) $(DL_DIR)/$(LIBFFI_SOURCE): $(DOWNLOAD) $(LIBFFI_SITE)/$(LIBFFI_SOURCE) -LIBFFI_PATCH = libffi-install_headers.patch - LIBFFI_CONF = $(if $(filter $(BOXSERIES), hd1),--enable-static --disable-shared) libffi: $(DL_DIR)/$(LIBFFI_SOURCE) | $(TARGET_DIR) $(REMOVE)/$(LIBFFI_DIR) $(UNTAR)/$(LIBFFI_SOURCE) $(CHDIR)/$(LIBFFI_DIR); \ - $(call apply_patches, $(LIBFFI_PATCH)); \ + $(APPLY_PATCHES); \ + autoreconf -fi; \ $(CONFIGURE) \ --prefix=$(prefix) \ --datarootdir=$(REMOVE_datarootdir) \ diff --git a/patches/libffi-install_headers.patch b/patches/libffi-install_headers.patch deleted file mode 100644 index d2bf7237..00000000 --- a/patches/libffi-install_headers.patch +++ /dev/null @@ -1,34 +0,0 @@ -Submitted By: Armin K. -Date: 2012-03-29 -Initial Package Version: 3.0.10 -Upstream Status: Not Submitted -Origin: Self -Description: Makes package install headers into /usr/include instead - of /usr/lib/libffi-3.0.10/include - ---- libffi.orig/include/Makefile.in 2011-08-23 16:28:35.000000000 +0200 -+++ libffi/include/Makefile.in 2012-03-29 19:57:53.919343783 +0200 -@@ -314,7 +314,7 @@ - AUTOMAKE_OPTIONS = foreign - DISTCLEANFILES = ffitarget.h - EXTRA_DIST = ffi.h.in ffi_common.h --includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include -+includesdir = $(includedir) - nodist_includes_HEADERS = ffi.h ffitarget.h - all: all-am - ---- libffi.orig/libffi.pc.in 2011-08-22 20:38:12.000000000 +0200 -+++ libffi/libffi.pc.in 2012-03-29 19:57:18.263549738 +0200 -@@ -2,10 +2,10 @@ - exec_prefix=@exec_prefix@ - libdir=@libdir@ - toolexeclibdir=@toolexeclibdir@ --includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include -+includedir=@includedir@ - - Name: @PACKAGE_NAME@ - Description: Library supporting Foreign Function Interfaces - Version: @PACKAGE_VERSION@ - Libs: -L${toolexeclibdir} -lffi --Cflags: -I${includedir} -+Cflags diff --git a/patches/libffi/0001-Fix-installation-location-of-libffi.patch b/patches/libffi/0001-Fix-installation-location-of-libffi.patch new file mode 100644 index 00000000..6ac91237 --- /dev/null +++ b/patches/libffi/0001-Fix-installation-location-of-libffi.patch @@ -0,0 +1,55 @@ +From 580f46a7bc6e9fea3a2227b5268cc3aed1d60e3b Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Thu, 7 Feb 2013 22:26:56 +0100 +Subject: [PATCH] Fix installation location of libffi +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The libffi is currently declared as toolexeclib_LTLIBRARIES. In many +cases, toolexeclib libraries will be installed in /usr/lib, so it +doesn't make any difference. + +However, with multilib toolchains, they get installed in a +subdirectory of /usr/lib/. For example, with a Sourcery CodeBench +PowerPC toolchain, if the e500mc multilib variant is used, the libffi +library gets installed in /usr/lib/te500mc/. This is due to the +following code in the configure script: + + multi_os_directory=`$CC -print-multi-os-directory` + case $multi_os_directory in + .) ;; # Avoid trailing /. + *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; + esac + +Once the library is installed in /usr/lib/te500mc/, nothing works +because this installation location is inconsistent with the +installation location declared in libffi.pc. + +So, instead of using this bizarre toolexeclib_LTLIBRARIES, simply use +the more standard lib_LTLIBRARIES, which ensures that the libffi +library is always installed in /usr/lib. + +Signed-off-by: Thomas Petazzoni +[unfuzz for 3.2.1] +Signed-off-by: Jörg Krause +--- + Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index 0e40451..309474c 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -104,7 +104,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) + + MAKEOVERRIDES= + +-toolexeclib_LTLIBRARIES = libffi.la ++lib_LTLIBRARIES = libffi.la + noinst_LTLIBRARIES = libffi_convenience.la + + libffi_la_SOURCES = src/prep_cif.c src/types.c \ +-- +2.5.3 + diff --git a/patches/libffi/0002-Fix-use-of-compact-eh-frames-on-MIPS.patch b/patches/libffi/0002-Fix-use-of-compact-eh-frames-on-MIPS.patch new file mode 100644 index 00000000..c19e395f --- /dev/null +++ b/patches/libffi/0002-Fix-use-of-compact-eh-frames-on-MIPS.patch @@ -0,0 +1,45 @@ +From 31b6b6bc14197cd4183bdbd311fddeb36b5ae100 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=B6rg=20Krause?= +Date: Sat, 19 Sep 2015 22:53:29 +0200 +Subject: [PATCH] Fix use of compact eh frames on MIPS +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Newer MIPS toolchains use a different (compact) eh_frame format. +libffi don't like them, so we have to switch to the older format. + +This patch add -mno-compact-eh to CFLAGS when compiling for +Mips and compiler support it. + +Signed-off-by: Jérôme Pouiller +[unfuzz for 3.2.1] +Signed-off-by: Jörg Krause +--- + configure.ac | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/configure.ac b/configure.ac +index a7bf5ee..36cd0d4 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -469,6 +469,16 @@ esac + AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1) + AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE) + ++if test x$TARGET = xMIPS; then ++ save_CFLAGS="$CFLAGS" ++ CFLAGS=-mno-compact-eh ++ AC_MSG_CHECKING([whether the C compiler needs -mno-compact-eh]) ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], ++ [AC_MSG_RESULT([yes])]; [save_CFLAGS="$save_CFLAGS -mno-compact-eh"], ++ [AC_MSG_RESULT([no])]) ++ CFLAGS="$save_CFLAGS" ++fi ++ + if test x$TARGET = xX86_64; then + AC_CACHE_CHECK([toolchain supports unwind section type], + libffi_cv_as_x86_64_unwind_section_type, [ +-- +2.5.3 + diff --git a/patches/libffi/0003-libffi-enable-hardfloat-in-the-MIPS-assembly-code.patch b/patches/libffi/0003-libffi-enable-hardfloat-in-the-MIPS-assembly-code.patch new file mode 100644 index 00000000..168972a8 --- /dev/null +++ b/patches/libffi/0003-libffi-enable-hardfloat-in-the-MIPS-assembly-code.patch @@ -0,0 +1,44 @@ +From 48bc37fabbc685b1e3293055bd33ca66c619305e Mon Sep 17 00:00:00 2001 +From: Vicente Olivert Riera +Date: Wed, 13 Jan 2016 14:49:59 +0000 +Subject: [PATCH] libffi: enable hardfloat in the MIPS assembly code + +This way it will be possible to build it for soft-float. This is only a +temporary fix. The package needs to be fixed properly. + +Signed-off-by: Vicente Olivert Riera +[Update for 3.3-rc0] +Signed-off-by: Fabrice Fontaine +--- + src/mips/n32.S | 1 + + src/mips/o32.S | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/src/mips/n32.S b/src/mips/n32.S +index c6985d3..dc842d5 100644 +--- a/src/mips/n32.S ++++ b/src/mips/n32.S +@@ -44,6 +44,7 @@ + #endif + #if !defined(__mips_isa_rev) || (__mips_isa_rev<6) + .set mips4 + #endif ++ .set hardfloat + .text + .align 2 + .globl ffi_call_N32 +diff --git a/src/mips/o32.S b/src/mips/o32.S +index eb27981..b653daf 100644 +--- a/src/mips/o32.S ++++ b/src/mips/o32.S +@@ -42,6 +42,7 @@ + #define RA_OFF (SIZEOF_FRAME - 1 * FFI_SIZEOF_ARG) + + .abicalls ++ .set hardfloat + .text + .align 2 + .globl ffi_call_O32 +-- +2.4.10 + diff --git a/patches/libffi/0004-ffi_powerpc.h-fix-build-failure-with-powerpc7.patch b/patches/libffi/0004-ffi_powerpc.h-fix-build-failure-with-powerpc7.patch new file mode 100644 index 00000000..7ee1f102 --- /dev/null +++ b/patches/libffi/0004-ffi_powerpc.h-fix-build-failure-with-powerpc7.patch @@ -0,0 +1,51 @@ +From f9d8f11d60cdc656a801e0d8116101beb22e117b Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine +Date: Sun, 24 Nov 2019 09:52:01 +0100 +Subject: [PATCH] ffi_powerpc.h: fix build failure with powerpc7 + +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 +--- + 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 5ee2a70..a5a786b 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.24.0 + diff --git a/patches/libffi/0005-powerpc-fix-build-failure-on-power7-and-older.patch b/patches/libffi/0005-powerpc-fix-build-failure-on-power7-and-older.patch new file mode 100644 index 00000000..d0b91dda --- /dev/null +++ b/patches/libffi/0005-powerpc-fix-build-failure-on-power7-and-older.patch @@ -0,0 +1,39 @@ +From 01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd Mon Sep 17 00:00:00 2001 +From: Sergei Trofimovich +Date: Thu, 28 Nov 2019 12:42:41 +0000 +Subject: [PATCH] powerpc: fix build failure on power7 and older (#532) + +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 +[Retrieved from: +https://github.com/libffi/libffi/commit/01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd] +Signed-off-by: Fabrice Fontaine +--- + 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 5ee2a709..8e2f2f0e 100644 +--- 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); diff --git a/patches/libffi/0006-Address-platforms-with-no-__int128.patch b/patches/libffi/0006-Address-platforms-with-no-__int128.patch new file mode 100644 index 00000000..012c6f0d --- /dev/null +++ b/patches/libffi/0006-Address-platforms-with-no-__int128.patch @@ -0,0 +1,28 @@ +From 6663047f56c2932a6b10a790f4ac6666dd181326 Mon Sep 17 00:00:00 2001 +From: Anthony Green +Date: Fri, 29 Nov 2019 07:00:35 -0500 +Subject: [PATCH] Address platforms with no __int128. + +[Retrieved from: +https://github.com/libffi/libffi/commit/6663047f56c2932a6b10a790f4ac6666dd181326] +Signed-off-by: Fabrice Fontaine +--- + 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 de0d0337..73647701 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++; diff --git a/patches/libffi/0007-powerpc64-Use-memcpy-to-help-platforms-with-no-__int128.patch b/patches/libffi/0007-powerpc64-Use-memcpy-to-help-platforms-with-no-__int128.patch new file mode 100644 index 00000000..53036707 --- /dev/null +++ b/patches/libffi/0007-powerpc64-Use-memcpy-to-help-platforms-with-no-__int128.patch @@ -0,0 +1,42 @@ +From e50b9ef8b910fa642ef158f6642e60d54d7ad740 Mon Sep 17 00:00:00 2001 +From: Khem Raj +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 +[Retrieved from: +https://github.com/libffi/libffi/commit/e50b9ef8b910fa642ef158f6642e60d54d7ad740] +Signed-off-by: Fabrice Fontaine +--- + 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 73647701..4d50878e 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++; + }