summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-01-09 15:06:07 +0100
committerGabor Kelemen <gabor.kelemen.extern@allotropia.de>2023-07-26 14:22:48 +0200
commit09b311f3727de30b7609e413ff01d7c8a85dc7a0 (patch)
tree1549eae86e9cd7af4208b7084722d00894eea44c
parent22d73a56e1e55a27e7029d19cb47a84064736c69 (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>
-rw-r--r--Makefile.fetch1
-rw-r--r--RepositoryExternal.mk6
-rwxr-xr-xbin/check-elf-dynamic-objects3
-rw-r--r--configure.ac3
-rw-r--r--download.lst2
-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
-rw-r--r--readlicense_oo/license/license.xml23
13 files changed, 121 insertions, 5 deletions
diff --git a/Makefile.fetch b/Makefile.fetch
index 522a4e22bc72..d046a1029448 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -154,6 +154,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S
$(call fetch_Optional,LIBASSUAN,LIBASSUAN_TARBALL) \
$(call fetch_Optional,LIBEOT,LIBEOT_TARBALL) \
$(call fetch_Optional,LIBEXTTEXTCAT,LIBEXTTEXTCAT_TARBALL) \
+ $(call fetch_Optional,LIBFFI,LIBFFI_TARBALL) \
$(call fetch_Optional,LIBGPGERROR,LIBGPGERROR_TARBALL) \
$(call fetch_Optional,LIBLANGTAG,LANGTAGREG_TARBALL) \
$(call fetch_Optional,LIBLANGTAG,LIBLANGTAG_TARBALL) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 82da26bfe624..e6fec4edcb1b 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -3213,6 +3213,12 @@ endif
endef
+# this is only used by python currently
+define gb_ExternalProject__use_libffi
+$(call gb_ExternalProject_use_external_project,$(1),libffi)
+
+endef
+
endif # SYSTEM_PYTHON
# ORCUS
diff --git a/bin/check-elf-dynamic-objects b/bin/check-elf-dynamic-objects
index ac73ce0b626c..24175f66d40c 100755
--- a/bin/check-elf-dynamic-objects
+++ b/bin/check-elf-dynamic-objects
@@ -113,9 +113,6 @@ local file="$1"
# skip the majority of files, no ELF binaries here
skip=1
;;
- */_ctypes.cpython-*.so)
- whitelist="${whitelist} libffi.so.6" # TODO dubious?
- ;;
*/_uuid.cpython-*.so)
whitelist="${whitelist} libuuid.so.1"
;;
diff --git a/configure.ac b/configure.ac
index 347d1ecd3bd4..0d0d06cb9a16 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8756,6 +8756,9 @@ internal)
fi
AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
BUILD_TYPE="$BUILD_TYPE PYTHON"
+ if test "$OS" = LINUX; then
+ BUILD_TYPE="$BUILD_TYPE LIBFFI"
+ fi
# Embedded Python dies without Home set
if test "$HOME" = ""; then
export HOME=""
diff --git a/download.lst b/download.lst
index f032941715bb..e13acde7611b 100644
--- a/download.lst
+++ b/download.lst
@@ -146,6 +146,8 @@ export LIBEOT_SHA256SUM := cf5091fa8e7dcdbe667335eb90a2cfdd0a3fe8f8c7c8d1ece44d9
export LIBEOT_TARBALL := libeot-0.01.tar.bz2
export LIBEXTTEXTCAT_SHA256SUM := 13fdbc9d4c489a4d0519e51933a1aa21fe3fb9eb7da191b87f7a63e82797dac8
export LIBEXTTEXTCAT_TARBALL := libexttextcat-3.4.5.tar.xz
+export LIBFFI_SHA256SUM := 72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056
+export LIBFFI_TARBALL := libffi-3.3.tar.gz
export LIBGPGERROR_SHA256SUM := 4f93aac6fecb7da2b92871bb9ee33032be6a87b174f54abf8ddf0911a22d29d2
export LIBGPGERROR_TARBALL := libgpg-error-1.27.tar.bz2
export LIBLANGTAG_SHA256SUM := d6242790324f1432fb0a6fae71b6851f520b2c5a87675497cf8ea14c2924d52e
diff --git a/external/Module_external.mk b/external/Module_external.mk
index e9d53ee5ab7c..b03083640336 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) \
diff --git a/readlicense_oo/license/license.xml b/readlicense_oo/license/license.xml
index d211b18b1692..1c2a3d4b6290 100644
--- a/readlicense_oo/license/license.xml
+++ b/readlicense_oo/license/license.xml
@@ -1686,6 +1686,29 @@
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</p>
</div>
+ <div class ="LIBFFI">
+ <h2>libffi</h2>
+ <p>The following software may be included in this product: libffi</p>
+ <p>The libffi project code is covered by the MIT license:</p>
+ <p>libffi - Copyright (c) 1996-2019 Anthony Green, Red Hat, Inc and others.</p>
+ <p>See source files for details.</p>
+ <p>Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:</p>
+ <p>The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.</p>
+ <p>THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
+ </div>
<div class="PYTHON">
<h2>Python</h2>
<p>The following software may be included in this product: Python. Use of any of this software is governed by