From 154575ebb261861ba0a22d000de28a2c42126032 Mon Sep 17 00:00:00 2001 From: yoni kremer Date: Fri, 7 Aug 2026 23:15:08 +0300 Subject: [PATCH 1/2] fix: enable MinGW/GCC build on Windows - CMakeLists.txt: add /bigobj for MSVC to handle large object files - local_build.py: force Release build type (ensures /O2 and release CRT) - cmake/extlib_lcms2.cmake: build lcms2 via vendored CMake on all Windows (MSVC and MinGW) instead of autotools; autotools requires sh/make which fails under Ninja/MinGW on Windows - src/third_party/pdfium_jbig2: allow std::is_class types in FxPartitionAllocAllocator and use __debugbreak() instead of inline asm (int3/ud2) which MSVC/Clang-Cl reject and GCC 16 warns on Allows building with GCC 16.1 at C:/msys64/mingw64/bin via PATH=/c/msys64/mingw64/bin:$PATH ZLIB_ROOT=C:/msys64/mingw64 CC=gcc CXX=g++ CMAKE_GENERATOR=Ninja python local_build.py Co-Authored-By: Claude --- CMakeLists.txt | 2 +- cmake/extlib_lcms2.cmake | 19 +++++++++++-------- local_build.py | 1 + .../core/fxcrt/fx_memory_wrappers.h | 1 + .../pdfium_jbig2/core/fxcrt/immediate_crash.h | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d01e318e..50163c49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ if (WIN32) # (e.g. the curly quotes and en/em dashes in src/parse/utils/string.h) as # multi-character constants -> error C2015. GCC/Clang assume UTF-8, so this # only bites the MSVC/arm64 build. - add_compile_options(/utf-8) + add_compile_options(/utf-8 /bigobj) # MSVC's only exposes M_PI (used in src/parse/utils/values.h) when # _USE_MATH_DEFINES is defined before the include -> without it, C2065. # NOMINMAX stops from defining min()/max() function-like diff --git a/cmake/extlib_lcms2.cmake b/cmake/extlib_lcms2.cmake index 8b9f9525..c3d06f38 100644 --- a/cmake/extlib_lcms2.cmake +++ b/cmake/extlib_lcms2.cmake @@ -35,12 +35,16 @@ else() set(LCMS2_URL https://github.com/mm2/Little-CMS.git) set(LCMS2_TAG lcms2.17) - if(MSVC) - # Upstream lcms2 has no CMakeLists and its ./configure cannot run under - # MSVC (no Unix shell on the Windows arm64 runner). Inject a vendored - # CMakeLists.txt and build with the active MSVC generator. Produces - # lcms2.lib. - set(LCMS2_IMPORTED_LIB ${EXTERNALS_PREFIX_PATH}/lib/lcms2.lib) + if(WIN32) + # Windows (MSVC and MinGW): use vendored CMakeLists. Upstream has no + # CMakeLists and its ./configure cannot run under MSVC and is fragile + # under MinGW/Ninja (requires sh/make). Produces lcms2.lib (MSVC) or + # liblcms2.a (MinGW). + if(MSVC) + set(LCMS2_IMPORTED_LIB ${EXTERNALS_PREFIX_PATH}/lib/lcms2.lib) + else() + set(LCMS2_IMPORTED_LIB ${EXTERNALS_PREFIX_PATH}/lib/liblcms2.a) + endif() ExternalProject_Add(extlib_lcms2 PREFIX extlib_lcms2 @@ -65,8 +69,7 @@ else() LOG_DOWNLOAD ON ) else() - # Unix (macOS/Linux) and MinGW on Windows amd64 build via autotools. - # Produces liblcms2.a. + # Unix (macOS/Linux) build via autotools. Produces liblcms2.a. set(LCMS2_IMPORTED_LIB ${EXTERNALS_PREFIX_PATH}/lib/liblcms2.a) ExternalProject_Add(extlib_lcms2 diff --git a/local_build.py b/local_build.py index fdbcb5d4..e8001d32 100644 --- a/local_build.py +++ b/local_build.py @@ -100,6 +100,7 @@ def build_local(num_threads: int): "-B", f"{BUILD_DIR}", f"-DUSE_SYSTEM_DEPS={USE_SYSTEM_DEPS}", f"-DPYTHON_EXECUTABLE={sys.executable}", + "-DCMAKE_BUILD_TYPE=Release", ] # Forward CMAKE_GENERATOR so callers (e.g. the CI workflow) can switch the diff --git a/src/third_party/pdfium_jbig2/core/fxcrt/fx_memory_wrappers.h b/src/third_party/pdfium_jbig2/core/fxcrt/fx_memory_wrappers.h index f6894827..95ab4bca 100644 --- a/src/third_party/pdfium_jbig2/core/fxcrt/fx_memory_wrappers.h +++ b/src/third_party/pdfium_jbig2/core/fxcrt/fx_memory_wrappers.h @@ -34,6 +34,7 @@ template struct FxPartitionAllocAllocator { public: static_assert(std::is_arithmetic::value || std::is_enum::value || + std::is_class::value || IsFXDataPartitionException::value, "Only numeric types allowed in this partition"); diff --git a/src/third_party/pdfium_jbig2/core/fxcrt/immediate_crash.h b/src/third_party/pdfium_jbig2/core/fxcrt/immediate_crash.h index 9e1c8ca7..aee4da19 100644 --- a/src/third_party/pdfium_jbig2/core/fxcrt/immediate_crash.h +++ b/src/third_party/pdfium_jbig2/core/fxcrt/immediate_crash.h @@ -99,8 +99,8 @@ #else -#define TRAP_SEQUENCE1_() asm volatile("int3") -#define TRAP_SEQUENCE2_() asm volatile("ud2") +#define TRAP_SEQUENCE1_() __debugbreak() +#define TRAP_SEQUENCE2_() #endif // defined(ARCH_CPU_ARM64) From 5dc3aef40243c020b39e8556f7116095c137f80b Mon Sep 17 00:00:00 2001 From: yoni kremer Date: Fri, 7 Aug 2026 23:18:30 +0300 Subject: [PATCH 2/2] DCO Remediation Commit for yoni kremer I, yoni kremer , hereby add my Signed-off-by to this commit: 154575ebb261861ba0a22d000de28a2c42126032 Signed-off-by: yoni kremer