configure.ac                                           |    7 +++++--
 external/pdfium/UnpackedTarball_pdfium.mk              |    4 ++++
 external/pdfium/pdfium-vs2019-arm64_no-__umulh.patch.1 |   17 +++++++++++++++++
 3 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit 8c2605aea05c6c5b9883400e1c1b7944f4edbc47
Author:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
AuthorDate: Fri Mar 14 01:26:32 2025 +0100
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Fri Mar 14 21:48:55 2025 +0100

    use clang with --target switch on windows (pdfium/skia)
    
    fixes the native compilation of arm64 of pdfium after
    6007fbef5c2e4a0b80a4c0031ff36117aa41e63f (update to pdfium 7012
    that switched to using clang) and allows to enable skia
    
    Change-Id: I1cee8c7b84c1988f7a5800da913c299d14444e4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182889
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/configure.ac b/configure.ac
index a9e63fd288e9..46efc6456061 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1001,7 +1001,7 @@ cygwin*|wsl*)
     LINKFLAGSNOUNDEFS=
 
     if test "$host_cpu" = "aarch64"; then
-        build_skia=no
+        build_skia=yes
         enable_gpgmepp=no
         enable_coinmp=no
         enable_firebird_sdbc=no
@@ -4118,6 +4118,7 @@ cygwin*|wsl*)
         WIN_HOST_ARCH="x64"
         WIN_MULTI_ARCH="x86"
         WIN_HOST_BITS=64
+        WIN_CLANG_TARGET="x86_64-pc-windows-msvc"
         ;;
     i*86)
         CPUNAME=INTEL
@@ -4126,6 +4127,7 @@ cygwin*|wsl*)
         WIN_HOST_ARCH="x86"
         WIN_HOST_BITS=32
         WIN_OTHER_ARCH="x64"
+        WIN_CLANG_TARGET="i686-pc-windows-msvc"
         ;;
     aarch64)
         CPUNAME=AARCH64
@@ -4135,6 +4137,7 @@ cygwin*|wsl*)
         SCPDEFS="$SCPDEFS -DWINDOWS_AARCH64"
         WIN_HOST_ARCH="arm64"
         WIN_HOST_BITS=64
+        WIN_CLANG_TARGET="arm64-pc-windows-msvc"
         ;;
     *)
         AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
@@ -12828,7 +12831,7 @@ if test \( "$ENABLE_SKIA" = TRUE -o "$ENABLE_PDFIUM" = 
TRUE \) -a "$COM_IS_CLANG
             fi
             if test -n "$LO_CLANG_CC"; then
                 dnl explicitly set -m32/-m64
-                LO_CLANG_CC="$LO_CLANG_CC -m$WIN_HOST_BITS"
+                LO_CLANG_CC="$LO_CLANG_CC --target=$WIN_CLANG_TARGET 
-m$WIN_HOST_BITS"
                 LO_CLANG_CXX="$LO_CLANG_CC"
                 AC_MSG_RESULT([$LO_CLANG_CC])
             else
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index 4a47b35bd6f3..305246bce888 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -16,6 +16,10 @@ pdfium_patches += constexpr-template.patch
 
 pdfium_patches += system-abseil.diff
 
+ifeq ($(OS),WNT)
+pdfium_patches += pdfium-vs2019-arm64_no-__umulh.patch.1
+endif
+
 $(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium))
 
 $(eval $(call gb_UnpackedTarball_set_tarball,pdfium,$(PDFIUM_TARBALL)))
diff --git a/external/pdfium/pdfium-vs2019-arm64_no-__umulh.patch.1 
b/external/pdfium/pdfium-vs2019-arm64_no-__umulh.patch.1
new file mode 100644
index 000000000000..227cc8c921ac
--- /dev/null
+++ b/external/pdfium/pdfium-vs2019-arm64_no-__umulh.patch.1
@@ -0,0 +1,17 @@
+clang as of Visual Studio 2019 doesn't support the __umulh intrinsic yet
+VS2022 (at last version 17.10) does, so instead of a !defined(__clang__)
+use a compiler version check to force the fallback for older versions.
+See https://learn.microsoft.com/en-us/cpp/overview/compiler-versions for
+a mapping of VisualStudio version to compiler version macro
+diff -ur 
pdfium.org/third_party/fast_float/src/include/fast_float/float_common.h 
pdfium/third_party/fast_float/src/include/fast_float/float_common.h
+--- pdfium.org/third_party/fast_float/src/include/fast_float/float_common.h    
2025-03-14 14:19:56
++++ pdfium/third_party/fast_float/src/include/fast_float/float_common.h        
2025-03-14 14:42:05
+@@ -338,7 +338,7 @@
+     return answer;
+   }
+   value128 answer;
+-#if defined(_M_ARM64) && !defined(__MINGW32__)
++#if defined(_M_ARM64) && !defined(__MINGW32__) && defined(_MSC_VER) && 
_MSC_VER >= 1930
+   // ARM64 has native support for 64-bit multiplications, no need to emulate
+   // But MinGW on ARM64 doesn't have native support for 64-bit multiplications
+   answer.high = __umulh(a, b);

Reply via email to