[Libreoffice-commits] core.git: configure.ac external/libffi external/python3

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 17 08:15:26 UTC 2020


 configure.ac                                |    2 -
 external/libffi/ExternalPackage_libffi.mk   |   20 +++++++++++++++++++
 external/libffi/ExternalProject_libffi.mk   |   29 ++++++++++++++++++++++------
 external/libffi/Module_libffi.mk            |    1 
 external/python3/ExternalProject_python3.mk |    2 -
 5 files changed, 46 insertions(+), 8 deletions(-)

New commits:
commit 883068462fe5bcbb01a8e14736fc06d0c3695c62
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Tue Jul 14 23:20:06 2020 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Jul 17 10:14:36 2020 +0200

    libffi: build DLL on Windows
    
    The build setup is rather horrible, with some minimal gcc MSVC
    wrapper. But the DLL is a prerequisite for the Python 3.8 build,
    which dropped the internal libffi.
    
    It's also possible to build it statically, but then you have to
    patch the Python 3 _ctypes msbuild properties.
    
    This also defaults to explicit --build and --host settings, even
    without a cross build, because the predicted name would otherwise
    differ (*-unknown-* instead of *-pc-*).
    
    Additionally a "make install" also fails...
    
    Change-Id: Ifb7dac840e23efffb9a5e342560aef9e11e0db79
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98436
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/configure.ac b/configure.ac
index 09f6333216fe..9575faf112e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9052,7 +9052,7 @@ internal)
     fi
     AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
     BUILD_TYPE="$BUILD_TYPE PYTHON"
-    if test "$OS" = LINUX; then
+    if test "$OS" = LINUX -o "$OS" = WNT ; then
         BUILD_TYPE="$BUILD_TYPE LIBFFI"
     fi
     # Embedded Python dies without Home set
diff --git a/external/libffi/ExternalPackage_libffi.mk b/external/libffi/ExternalPackage_libffi.mk
new file mode 100644
index 000000000000..212e63aa36af
--- /dev/null
+++ b/external/libffi/ExternalPackage_libffi.mk
@@ -0,0 +1,20 @@
+# -*- 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_ExternalPackage_ExternalPackage,libffi,libffi))
+
+$(eval $(call gb_ExternalPackage_use_external_project,libffi,libffi))
+
+ifeq ($(COM),MSC)
+$(eval $(call gb_ExternalPackage_add_files,libffi,$(LIBO_LIB_FOLDER),\
+    $(HOST_PLATFORM)/.libs/libffi-7.dll \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libffi/ExternalProject_libffi.mk b/external/libffi/ExternalProject_libffi.mk
index 13a4b18db13d..49bd1af15d0c 100644
--- a/external/libffi/ExternalProject_libffi.mk
+++ b/external/libffi/ExternalProject_libffi.mk
@@ -14,18 +14,35 @@ $(eval $(call gb_ExternalProject_register_targets,libffi,\
 ))
 
 # set prefix so that it ends up in libffi.pc so that pkg-config in python3 works
+# For a static Windows build, change CPPFLAGS to include -D_LIB and --disable-static
+# Also remove the ExternalPackage in that case
+
+libffi_WIN_PLATFORM := $(strip \
+    $(if $(filter INTEL,$(CPUNAME)),32) \
+    $(if $(filter X86_64,$(CPUNAME)),64) \
+    $(if $(filter ARM64,$(CPUNAME)),arm64) \
+    )
 
 $(call gb_ExternalProject_get_state_target,libffi,build):
 	$(call gb_Trace_StartRange,libffi,EXTERNAL)
 	$(call gb_ExternalProject_run,build,\
+		export LIB="$(ILIB)" && \
 		./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)" \
+			--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) \
+			$(if $(filter LINUX,$(OS)), \
+			    --disable-shared \
+			    CC="$(CC) -fvisibility=hidden" \
+				--with-pic \
+				--enable-portable-binary) \
+			$(if $(filter WNT,$(OS)), \
+			    --disable-static \
+			    CC="$(call gb_UnpackedTarball_get_dir,libffi)/msvcc.sh -m$(libffi_WIN_PLATFORM)" \
+			    CXX="$(call gb_UnpackedTarball_get_dir,libffi)/msvcc.sh -m$(libffi_WIN_PLATFORM)" \
+				LD='link' \
+				CPP='cl -nologo -EP' \
+				CXXCPP='cl -nologo -EP' \
+				CPPFLAGS="-DFFI_BUILDING_DLL $(SOLARINC)") \
 			--prefix=$(call gb_UnpackedTarball_get_dir,libffi)/$(HOST_PLATFORM) \
 			--disable-docs \
 		&& $(MAKE) \
diff --git a/external/libffi/Module_libffi.mk b/external/libffi/Module_libffi.mk
index 739fd4197000..ace75480abe3 100644
--- a/external/libffi/Module_libffi.mk
+++ b/external/libffi/Module_libffi.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_Module_Module,libffi))
 $(eval $(call gb_Module_add_targets,libffi,\
 	UnpackedTarball_libffi \
 	ExternalProject_libffi \
+	ExternalPackage_libffi \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/python3/ExternalProject_python3.mk b/external/python3/ExternalProject_python3.mk
index e3096b14fed7..3843eab915a3 100644
--- a/external/python3/ExternalProject_python3.mk
+++ b/external/python3/ExternalProject_python3.mk
@@ -11,7 +11,7 @@ $(eval $(call gb_ExternalProject_ExternalProject,python3))
 
 $(eval $(call gb_ExternalProject_use_externals,python3,\
 	expat \
-	$(if $(filter LINUX,$(OS)),libffi) \
+	$(if $(filter WNT LINUX,$(OS)),libffi) \
 	openssl \
 	zlib \
 ))


More information about the Libreoffice-commits mailing list