Fix Linux mingw cross-compile and add a Linux/Wine CI workflow#5812
Open
koppor wants to merge 2 commits into
Open
Fix Linux mingw cross-compile and add a Linux/Wine CI workflow#5812koppor wants to merge 2 commits into
koppor wants to merge 2 commits into
Conversation
The mingw-w64 cross-build (cmd/build-linux-wine.ts) had drifted since it was added: the mupdf-libs aggregate removal, the src/base rework and a number of new/renamed src files broke compile and link. Fix the drift, plus latent portability bugs the MSVC build can't see: - case-sensitive #include mismatches (theme.h, SumatraPdf.h) - INT_MAX used in Vec.h without <limits.h> (add to Base.h) - 'Size Size() const' rejected by gcc without an elaborated type - HWND-to-LONG casts rejected by clang; use HandleToLong - SetThreadDescription missing from mingw-w64 headers before v12 - unrar's internal Archive class collides with src/base/Archive.cpp's Archive under GNU ld (MSVC picks one via COMDAT); rename it to UnrarArchive in unrar TUs only - shared lib defs: restore files premake has but the TS defs lost (libheif heif_components/metadata/omaf, mupdf cull-device.c, options.c, md.c + cmark includes) and add extract's memento.h dir Prefer the posix-threads mingw flavor: Debian's default is win32 threads, whose libstdc++ lacks the std::mutex that libheif needs. Add .github/workflows/linux.yml: cross-compile in a debian:trixie container (mingw-w64 >= 12 required), run the exe's built-in unit tests under Wine (xvfb), gate a render smoke test on its output, and upload the exe as an artifact - so this build path cannot rot silently again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mBFgiNUBqbB5x2dg996Ft prompt: get SumatraPDF fully working on Linux with a minimal patch and working CI; first PR: the Wine cross-build fixes plus a CI job that builds and tests under Wine
Collaborator
Author
|
I think, for me, this would be a good start when switching my main OS to Linux 😅. |
Move the Linux workflow from a debian:trixie container to the plain ubuntu-24.04 runner and cache the apt packages with awalsh128/cache-apt-pkgs-action (execute_install_scripts for wine's update-alternatives postinst). ubuntu-24.04 ships mingw-w64 v11, which needs three accommodations: - src/base/WinDynCalls.h: define the Windows 11 DWM corner/border enums for pre-v12 headers (the dwm:: wrappers pass them as DWORD) - ext/darkmodelib/src/StdAfx.h: same, plus the Mica backdrop types and newer DWMWA attribute ids the library uses - cmd/build-with-mingw.ts: mingw-w64 v11 has UIA headers but no libuiautomationcore.a import library; synthesize one with dlltool from a .def listing the functions we call Verified in an ubuntu:24.04 container with that exact package set: full build, "Passed all 24 tests" under Wine 9, render smoke passes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mBFgiNUBqbB5x2dg996Ft prompt: run the Linux workflow on ubuntu 24.04 and use awalsh128/cache-apt-pkgs-action for apt installation
Collaborator
Author
|
I am not sure about mingw 11 vs. 12, but the "hack" proposed by Claude sounds reasonable to support Ubuntu-24.04, too |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running on WSL w/ Wine
🤖 This description was generated by Claude Code.
What
cmd/build-linux-wine.ts(cross-compile the full SumatraPDF.exe with mingw-w64 on Linux and run it under Wine) had drifted out of sync since it was added: themupdf-libsaggregate removal, thesrc/baserework, and a number of new or renamedsrc/files broke both compile and link. Because no CI exercises this path, nothing caught it. This PR makes the Linux cross-build green again and adds a CI workflow so it stays green.Latent portability bugs fixed in source (invisible to MSVC):
#includemismatches (theme.hin EditAnnotations.cpp,SumatraPdf.hin Notifications.cpp) — fatal on any case-sensitive filesystemINT_MAXused inVec.hwithout<limits.h>(added toBase.h; MSVC gets it transitively)Size Size() const;inGeom.h— gcc rejects the unelaborated form ("changes meaning of Size")(LONG)hwnd/(int)hwndcasts insrc/uia/— hard errors under clang; now the canonicalHandleToLong()SetThreadDescriptionisn't declared by mingw-w64 headers before v12 — declared inWinDynCalls.hunder#ifdef __MINGW32__(an identical redeclaration is harmless on newer headers, and the block is invisible to MSVC)Archiveclass collides withsrc/base/Archive.cpp'sArchivesince the base rework — GNU ld errors on the duplicate strong symbols (MSVC silently picks one via COMDAT, a latent hazard there too). unrar TUs now compile with-DArchive=UnrarArchive; consumers only use the C API indll.hpp, which doesn't mention the class.Shared lib-def drift (
cmd/build-lib-defs.ts— also benefits the mac/linux native builds):extract: addext/extract/srcto includes (memento.hlives there)libheif: restore theheif_components/heif_metadata/heif_omafAPI files (premake lists them; the TS defs had dropped them → link errors from ExifDump)mupdf: addcull-device.c,options.c,md.cplus the cmark-gfm include dirs andCMARK_GFM_STATIC_DEFINE(previously patched locally inbuild-linux.tsonly)cmd/build-with-mingw.tsre-synced with premake: the removedmupdfLibsimport replaced with the individual restored libs;djvudec,a-gumbo,zopflilibs added; ~30 added/renamed src files (AIChat*, PdfDarkMode*, PdfCad*, the RefHover and CommandPalette splits, FindBar/FindWindow, Markdown*, WebpReader, SumatraLog, AppUnitTests, …); missing include dirs (libjxl, libheif, libwebp, cmark, djvudec);-Wno-narrowingfor mingw'sQITABENTmacro under clang; the generated TTS/Test stubs re-synced with the currentTextToSpeech.h/WStrsignatures; a missingbasenameimport.Toolchain:
resolveMingwToolsnow prefersx86_64-w64-mingw32-g++-posix— Debian's unsuffixed mingw is the win32-threads flavor whose libstdc++ has nostd::mutex(libheif needs it). On Ubuntu the unsuffixed name is already the posix flavor, so nothing changes there.CI —
.github/workflows/linux.yml: cross-compiles in adebian:trixiecontainer (mingw-w64 ≥ 12 is the practical floor: ubuntu-24.04 runners ship v11, whose headers predateSetThreadDescription,DWMWCP_*, …), runs the built exe's built-in unit tests under Wine (xvfb) as the gate, runs a render smoke test (-benchon a repo PDF, gated on its "Finished" output since-benchdoesn't return 0 on success), and uploads the exe as an artifact.How tested
On Linux, inside a
debian:trixiecontainer (the same environment the CI job uses):The workflow itself was validated locally with
nektos/actrunning the real job in the same container before pushing.The source changes are written to be no-ops for MSVC (include/decl fixes,
HandleToLong, a mingw-only#ifdefblock; the unrar rename lives in the TS lib defs only — premake is untouched), but I could not compile on Windows from this machine — the Windows CI run on this PR is the verification for that.🤖 Generated with Claude Code