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

New commits:
commit 5c20dd294119daa1cd87d9b8da8984ee76dc7dab
Author:     Jan-Marek Glogowski <[email protected]>
AuthorDate: Sun Feb 7 15:15:58 2021 +0100
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Wed Aug 2 15:29:54 2023 +0200

    tdf#140236 WIN install libffi with Python
    
    Regression from commit b4dfba947768834ffecc09056992019878711c8b
    ("python3: update to 3.8.4"). Previous Python versions included
    the source for libffi on all platforms, but now just for MacOS.
    So now LO must build that DLL on Windows, which was done in
    commit 883068462fe5bcbb01a8e14736fc06d0c3695c62 ("libffi: build
    DLL on Windows").
    
    Since OpenSSL is installed in the program directory and the LO
    Python directory, this currently works "accidentially". Not sure
    the Python OpenSSL DLLs should be handled via some extra gbuild
    package to separate both, but that can be done in an additional
    change.
    
    Change-Id: I4a42e39cc2f4434a9944aad32836f66ec2819931
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110537
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <[email protected]>

diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index f43f8acf2f1e..4d7b30a24b0f 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -3175,6 +3175,7 @@ else # !SYSTEM_PYTHON
 
 $(eval $(call gb_Helper_register_packages_for_install,python,\
        python3 \
+    $(if $(filter WNT,$(OS)),libffi) \
 ))
 
 define gb_LinkTarget__use_python_headers
commit 62db67b07d1f8fc32cabf1b3b0b4e7e34a6eb4d6
Author:     Jan-Marek Glogowski <[email protected]>
AuthorDate: Tue Jul 14 23:20:06 2020 +0200
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Wed Aug 2 14:40:58 2023 +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 <[email protected]>

diff --git a/configure.ac b/configure.ac
index 85ea8ecfc58c..1b71847401b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8756,7 +8756,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/ExternalProject_libffi.mk 
b/external/libffi/ExternalProject_libffi.mk
index bdf8fe61eb76..0ff625ea3e20 100644
--- a/external/libffi/ExternalProject_libffi.mk
+++ b/external/libffi/ExternalProject_libffi.mk
@@ -14,17 +14,34 @@ $(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_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 a6338ccf3578..c124a46f0798 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 \
 ))

Reply via email to