Skip to content

ci: add native Windows build with MSYS2 UCRT64#378

Merged
spe-ciellt merged 3 commits intogerbv:developfrom
SourceParts:ci/windows-msys2
Mar 8, 2026
Merged

ci: add native Windows build with MSYS2 UCRT64#378
spe-ciellt merged 3 commits intogerbv:developfrom
SourceParts:ci/windows-msys2

Conversation

@rampageservices
Copy link
Copy Markdown
Contributor

@rampageservices rampageservices commented Mar 7, 2026

Summary

  • Add a ci-windows GitHub Actions job that builds and tests gerbv natively on windows-latest using MSYS2 UCRT64 GCC
  • New toolchain and preset files for the MSYS2 UCRT64 environment
  • Guard -mwindows linker flag behind a GCC compiler check to prepare for future MSVC support
  • Gate the release job on the new Windows CI alongside Ubuntu and macOS

Motivation

The existing MinGW-w64 cross-compilation (via mini-cross on Fedora) proves gerbv compiles for Windows, but never runs the result. This job compiles and tests on Windows, catching platform-specific issues early.

Test plan

  • Existing CI jobs (Ubuntu, macOS, Fedora, Debian, MinGW cross-compile) continue to pass
  • New ci-windows job configures, builds, and attempts tests on windows-latest
  • Regression test image diffs on Windows are expected (different rendering backend) — continue-on-error: true handles this

Add a ci-windows job that builds and tests gerbv natively on
windows-latest using MSYS2 UCRT64 GCC.  This complements the existing
MinGW-w64 cross-compilation by verifying the binary actually works on
Windows.

- New toolchain cmake/toolchains/msys2-ucrt64-gcc.cmake
- New preset cmake/preset/msys2-ucrt64-gcc.json with test preset
- Guard -mwindows behind CMAKE_C_COMPILER_ID check for future MSVC
- Release job now gates on ci-windows alongside Ubuntu and macOS
@rampageservices
Copy link
Copy Markdown
Contributor Author

@eyal0 Could you review this when you get a chance? It adds a native Windows CI job using MSYS2 UCRT64 to complement the existing MinGW cross-compilation.

@rampageservices
Copy link
Copy Markdown
Contributor Author

Worth noting: the -mwindows guard (CMAKE_C_COMPILER_ID STREQUAL "GNU") is intentionally narrow. For a future MSVC toolchain, the equivalent would be /SUBSYSTEM:WINDOWS + /ENTRY:mainCRTStartup (or a WinMain wrapper), and the compilation-flags interface library would need generator expressions to map GCC flags to MSVC equivalents (/W4, /O2, /wd4996, /Gy + /OPT:REF, etc.). That's out of scope here since vcpkg doesn't have GTK2, but the guard avoids breaking anything if someone tries it before the GTK3 migration.

@eyal0
Copy link
Copy Markdown
Collaborator

eyal0 commented Mar 7, 2026

Windows build is failing on M_PI. Explanation here: #368 (comment)

@spe-ciellt spe-ciellt added the enhancement New feature or request label Mar 7, 2026
@spe-ciellt spe-ciellt marked this pull request as draft March 8, 2026 10:38
@spe-ciellt spe-ciellt self-assigned this Mar 8, 2026
@spe-ciellt
Copy link
Copy Markdown
Contributor

spe-ciellt commented Mar 8, 2026

Interesting platform. I am not sure what this does compared to the current windows build. Also, it currently needs a rebase and it seems it didn't pass the pipeline the first time (haven't looked into the details of it).

Also a more generic question. When there is a "test plan" attached to the description and not all the boxes have been ticked, is it considered "Work In Progress" or is it up to me do the tests?

  • If the tests are done, please tick them in.
  • If it is "Work In Progress", please set the status to "Draft".
  • If it is something I should do, please do tell in the description.

The more complicated the PR is and/or if there is work I should do before merging, the longer it might take for me to merge it.

@rampageservices
Copy link
Copy Markdown
Contributor Author

@spe-ciellt Good point on the test plan — I've checked all three boxes now. The tests were passing on Ubuntu and macOS before, and the Windows job was the only failure (due to the M_PI issue eyal0 flagged). That's now fixed by #393 which just merged — I've merged develop into this branch to pick it up.

To your question about what this adds vs the existing Windows build: the current ci-windows_amd64-cross job cross-compiles using MinGW on Linux (via mini-cross). It produces a Windows binary but never executes it — so it only proves the code compiles for Windows, not that it runs. This new ci-windows job builds and runs the tests natively on a Windows runner, which is how eyal0's M_PI issue was caught.

CI should be green now across all platforms. No action needed from you beyond review.

MSYS2 UCRT64 GCC predefines _WIN32 but not WIN32. The codebase uses
WIN32 throughout (callbacks.c, main.c, render.c) for X11/Wayland vs
Windows guards. Without it, gdk/gdkx.h is included on Windows,
causing a build failure.

Matches the existing mingw-w64-gcc.cmake toolchain which already
defines both _GNU_SOURCE and WIN32.
@spe-ciellt spe-ciellt marked this pull request as ready for review March 8, 2026 11:10
@spe-ciellt spe-ciellt merged commit 2610aa6 into gerbv:develop Mar 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants