summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-01-09 15:06:07 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-01-13 11:14:30 +0100
commit6b5ce621ff2a82d4fa77d7781d1dabd4b14a4c90 (patch)
tree2304b0813c598f2318a6183eaa89d705d75a30f0 /external
parente17ed7b1e11174a7b3ed1219ce1df8b26372417a (diff)
python3: bundle libffi for GNU/Linux builds
CPython commit f40d4ddff3c800b3c956a5e8820aabe3aa87cddd "Closes #27979: Remove bundled copy of libffi" causes a bit of a problem because it turns out that libffi isn't all that stable; there's libffi.so.5 on CentOS 6, libffi.so.6 on CentOS 7 and libffi.so.7 on lo_daily_update_gandalf tinderbox. So we have to bundle it in LO; it's only used on GNU/Linux currently. CPython commit 32119e10b792ad7ee4e5f951a2d89ddbaf111cc5 "bpo-35947: Update Windows to the current version of libffi (GH-11797)" also removes the libffi for MSVC, so in a future python upgrade we will have to build libffi for MSVC too. The libffi fork for MacOSX is still in CPython git master. (regression from b10be5d48433076f0b7238d818020f708553e114) Change-Id: Ibc20cf8cd3614cf9941b6970662bd930496776b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86493 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 79084665f0e351a3f83fdee88071919f05ec9cc3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86500 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'external')
-rw-r--r--external/Module_external.mk1
-rw-r--r--external/libffi/ExternalProject_libffi.mk33
-rw-r--r--external/libffi/Makefile7
-rw-r--r--external/libffi/Module_libffi.mk17
-rw-r--r--external/libffi/README3
-rw-r--r--external/libffi/UnpackedTarball_libffi.mk14
-rw-r--r--external/python3/ExternalProject_python3.mk13
7 files changed, 86 insertions, 2 deletions
diff --git a/external/Module_external.mk b/external/Module_external.mk
index 10ed2a6e54db..baf7215b2b70 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -57,6 +57,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
$(call gb_Helper_optional,LIBATOMIC_OPS,libatomic_ops) \
$(call gb_Helper_optional,LIBEOT,libeot) \
$(call gb_Helper_optional,LIBEXTTEXTCAT,libexttextcat) \
+ $(call gb_Helper_optional,LIBFFI,libffi) \
$(call gb_Helper_optional,LIBGPGERROR,libgpg-error) \
$(call gb_Helper_optional,LIBLANGTAG,liblangtag) \
$(call gb_Helper_optional,LIBNUMBERTEXT,libnumbertext) \
diff --git a/external/libffi/ExternalProject_libffi.mk b/external/libffi/ExternalProject_libffi.mk
new file mode 100644
index 000000000000..bdf8fe61eb76
--- /dev/null
+++ b/external/libffi/ExternalProject_libffi.mk
@@ -0,0 +1,33 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,libffi))
+
+$(eval $(call gb_ExternalProject_register_targets,libffi,\
+ build \
+))
+
+# set prefix so that it ends up in libffi.pc so that pkg-config in python3 works
+
+$(call gb_ExternalProject_get_state_target,libffi,build):
+ $(call gb_ExternalProject_run,build,\
+ ./configure \
+ --enable-option-checking=fatal \
+ $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
+ --enable-static \
+ --disable-shared \
+ --with-pic \
+ --enable-portable-binary \
+ CC="$(CC) $(if $(filter LINUX,$(OS)),-fvisibility=hidden)" \
+ --prefix=$(call gb_UnpackedTarball_get_dir,libffi)/$(HOST_PLATFORM) \
+ --disable-docs \
+ && $(MAKE) \
+ )
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libffi/Makefile b/external/libffi/Makefile
new file mode 100644
index 000000000000..e4968cf85fb6
--- /dev/null
+++ b/external/libffi/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libffi/Module_libffi.mk b/external/libffi/Module_libffi.mk
new file mode 100644
index 000000000000..739fd4197000
--- /dev/null
+++ b/external/libffi/Module_libffi.mk
@@ -0,0 +1,17 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Module_Module,libffi))
+
+$(eval $(call gb_Module_add_targets,libffi,\
+ UnpackedTarball_libffi \
+ ExternalProject_libffi \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libffi/README b/external/libffi/README
new file mode 100644
index 000000000000..cdf7fa937bc8
--- /dev/null
+++ b/external/libffi/README
@@ -0,0 +1,3 @@
+libffi is required to build CPython's ctypes module
+
+https://sourceware.org/libffi/
diff --git a/external/libffi/UnpackedTarball_libffi.mk b/external/libffi/UnpackedTarball_libffi.mk
new file mode 100644
index 000000000000..5d0582329ac5
--- /dev/null
+++ b/external/libffi/UnpackedTarball_libffi.mk
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,libffi))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,libffi,$(LIBFFI_TARBALL)))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/python3/ExternalProject_python3.mk b/external/python3/ExternalProject_python3.mk
index 5350f9e4c5d9..6c958431cd97 100644
--- a/external/python3/ExternalProject_python3.mk
+++ b/external/python3/ExternalProject_python3.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_ExternalProject_ExternalProject,python3))
$(eval $(call gb_ExternalProject_use_externals,python3,\
expat \
+ $(if $(filter LINUX,$(OS)),libffi) \
openssl \
zlib \
))
@@ -52,8 +53,12 @@ else
# OPENSSL_INCLUDES OPENSSL_LDFLAGS OPENSSL_LIBS cannot be set via commandline!
# use --with-openssl instead, which requires include/ and lib/ subdirs.
-# TODO: libffi has different SONAME on CentOS 6 vs. 7, so we better use
-# --without-system-ffi. However, that doesn't actually do anything on Linux :(
+# libffi is not all that stable, with 3 different SONAMEs currently, so we
+# have to bundle it; --without-system-ffi does not work any more on Linux.
+# Unfortuantely (as of 3.7) pkg-config is used to locate libffi so we do some
+# hacks to find the libffi.pc in workdir by overriding PKG_CONFIG_LIBDIR.
+# Also, pkg-config is only used to find the headers, the libdir needs to be
+# passed extra.
# create a symlink "LO_lib" because the .so are in a directory with platform
# specific name like build/lib.linux-x86_64-3.3
@@ -91,6 +96,9 @@ $(call gb_ExternalProject_get_state_target,python3,build) :
$(if $(SYSTEM_OPENSSL)$(DISABLE_OPENSSL),,\
--with-openssl=$(call gb_UnpackedTarball_get_dir,openssl) \
) \
+ $(if $(filter LINUX,$(OS)), \
+ PKG_CONFIG_LIBDIR="$(call gb_UnpackedTarball_get_dir,libffi)/$(HOST_PLATFORM)$${PKG_CONFIG_LIBDIR:+:$$PKG_CONFIG_LIBDIR}" \
+ ) \
CC="$(strip $(CC) \
$(if $(SYSTEM_EXPAT),,-I$(call gb_UnpackedTarball_get_dir,expat)/lib) \
$(if $(SYSBASE), -I$(SYSBASE)/usr/include) \
@@ -98,6 +106,7 @@ $(call gb_ExternalProject_get_state_target,python3,build) :
$(if $(python3_cflags),CFLAGS='$(python3_cflags)') \
$(if $(filter -fsanitize=%,$(CC)),LINKCC="$(CXX) -pthread") \
LDFLAGS="$(strip $(LDFLAGS) \
+ $(if $(filter LINUX,$(OS)),-L$(call gb_UnpackedTarball_get_dir,libffi)/$(HOST_PLATFORM)/.libs) \
$(if $(SYSTEM_EXPAT),,-L$(gb_StaticLibrary_WORKDIR)) \
$(if $(SYSTEM_ZLIB),,-L$(gb_StaticLibrary_WORKDIR)) \
$(if $(SYSBASE), -L$(SYSBASE)/usr/lib) \