Skip to content

ci(build): Add MinGW-w64 i686 cross-compilation to CI workflow#2163

Open
JohnsterID wants to merge 2 commits intoTheSuperHackers:mainfrom
JohnsterID:add-mingw-i686-build
Open

ci(build): Add MinGW-w64 i686 cross-compilation to CI workflow#2163
JohnsterID wants to merge 2 commits intoTheSuperHackers:mainfrom
JohnsterID:add-mingw-i686-build

Conversation

@JohnsterID
Copy link

@JohnsterID JohnsterID commented Jan 21, 2026

Add automated MinGW-w64 (i686) build jobs for both Generals and GeneralsMD to the CI pipeline, enabling Linux-hosted cross-compilation with artifact collection matching the MSVC PDB workflow.

Changes:

  • .github/workflows/ci.yml: Add two new matrix build jobs
    • build-mingw-generals: Builds Generals with mingw-w64-i686 toolchain
    • build-mingw-generalsmd: Builds GeneralsMD with mingw-w64-i686 toolchain
    • Matrix: mingw-w64-i686 (Release), mingw-w64-i686-debug (Debug)
    • Profile preset excluded (uses MSVC inline ASM with no GCC equivalent)

Toolchain setup (ubuntu-latest):

  • MinGW-w64 cross-compiler (i686-w64-mingw32-gcc)
  • Wine stable + widl for COM interface compilation
  • CMake with Unix Makefiles generator
  • Cached toolchain and dependencies

Artifact collection:

  • Stripped executable (.exe) + separate debug symbols (.exe.debug) for Release
  • Single executable with embedded symbols for Debug
  • Matches MSVC .exe + .pdb workflow
  • Static linked (no DLL dependencies)
  • 30-day retention period

Jobs respect detect-changes filter (Generals/, GeneralsMD/, Core/, .github/workflows/, etc.) for conditional execution, identical to existing VC6 and win32 build triggers.

Result: 4 new artifact combinations

  • Generals-mingw-w64-i686 (76 MB: 12 MB exe + 229 MB debug)
  • Generals-mingw-w64-i686-debug (56.6 MB: 200 MB exe)
  • GeneralsMD-mingw-w64-i686 (82.2 MB: 13 MB exe + 248 MB debug)
  • GeneralsMD-mingw-w64-i686-debug (61.4 MB: 215 MB exe)

Runtime issues

Closes #486

@greptile-apps
Copy link

greptile-apps bot commented Jan 21, 2026

Greptile Summary

This PR adds two new CI jobs (build-mingw-generals and build-mingw-generalsmd) that cross-compile the game executables on ubuntu-latest using the MinGW-w64 i686 toolchain, producing stripped release and debug artifacts that mirror the existing MSVC PDB workflow. The jobs integrate cleanly with the existing detect-changes filter and artifact retention policy.

Key observations:

  • The cache key pattern in both jobs (cmake-deps-mingw-${{ matrix.preset }}-...) is identical, causing a race-to-save collision when the two jobs run in parallel with the same preset; adding a per-job discriminator to the key prevents silent cache conflicts.
  • The 20-line "Install Wine and widl" shell block is duplicated verbatim between the two jobs; extracting this into a composite action or reusable workflow step would make future maintenance safer.

Confidence Score: 3/5

  • Safe to merge with minor rework on cache key discriminators and Wine setup consolidation.
  • The new jobs follow the same structure as existing CI jobs and integrate correctly with the change-detection filter. The cache key collision is a real but low-severity issue — it won't break builds today since both jobs fetch the same upstream dependencies, but it is logically incorrect and could silently cause problems if dependency sets ever diverge. The duplicated Wine installation block is a maintainability concern. Neither issue prevents the builds from working correctly.
  • .github/workflows/ci.yml — cache key collision on lines 225–230 and 313–318 needs a per-job discriminator; Wine installation block (lines 203–223) is duplicated at lines 291–311.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[push / PR / workflow_dispatch] --> B[detect-changes]
    B -->|generals or shared changed| C[build-mingw-generals]
    B -->|generalsmd or shared changed| D[build-mingw-generalsmd]

    C --> C1[Checkout Code]
    C1 --> C2[Install MinGW-w64 Toolchain]
    C2 --> C3[Install Wine and widl]
    C3 --> C4[Cache CMake Dependencies]
    C4 --> C5[cmake configure - Generals preset]
    C5 --> C6[cmake build - target g_generals]
    C6 --> C7[Collect Artifacts - exe / dll / exe.debug]
    C7 --> C8[Upload Artifact - Generals-preset - 30 days]

    D --> D1[Checkout Code]
    D1 --> D2[Install MinGW-w64 Toolchain]
    D2 --> D3[Install Wine and widl]
    D3 --> D4[Cache CMake Dependencies]
    D4 --> D5[cmake configure - GeneralsMD preset]
    D5 --> D6[cmake build - target z_generals]
    D6 --> D7[Collect Artifacts - exe / dll / exe.debug]
    D7 --> D8[Upload Artifact - GeneralsMD-preset - 30 days]

    C4 -.->|cache key collision for same preset| D4
Loading

Last reviewed commit: 639c907

JohnsterID added a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 21, 2026
…perHackers#2163)

Add automated MinGW-w64 (i686) build jobs for both Generals and GeneralsMD
to the CI pipeline, enabling Linux-hosted cross-compilation with artifact
collection matching the MSVC PDB workflow.

Changes:
- .github/workflows/ci.yml: Add two new matrix build jobs
  - build-mingw-generals: Builds Generals with mingw-w64-i686 toolchain
  - build-mingw-generalsmd: Builds GeneralsMD with mingw-w64-i686 toolchain
  - Matrix: mingw-w64-i686 (Release), mingw-w64-i686-debug (Debug)
  - Profile preset excluded (uses MSVC inline ASM with no GCC equivalent)

Toolchain setup (ubuntu-latest):
- MinGW-w64 cross-compiler (i686-w64-mingw32-gcc)
- Wine stable + widl for COM interface compilation
- CMake with Unix Makefiles generator
- Cached toolchain and dependencies

Artifact collection:
- Stripped executable (.exe) + separate debug symbols (.exe.debug) for Release
- Single executable with embedded symbols for Debug
- Matches MSVC .exe + .pdb workflow
- Static linked (no DLL dependencies)
- 30-day retention period

Jobs respect detect-changes filter (Generals/**, GeneralsMD/**, Core/**,
.github/workflows/**, etc.) for conditional execution, identical to existing
VC6 and win32 build triggers.

Result: 4 new artifact combinations
- Generals-mingw-w64-i686 (76 MB: 12 MB exe + 229 MB debug)
- Generals-mingw-w64-i686-debug (56.6 MB: 200 MB exe)
- GeneralsMD-mingw-w64-i686 (82.2 MB: 13 MB exe + 248 MB debug)
- GeneralsMD-mingw-w64-i686-debug (61.4 MB: 215 MB exe)
@JohnsterID JohnsterID force-pushed the add-mingw-i686-build branch from c701bca to 7ba67b2 Compare January 21, 2026 21:06
@xezon
Copy link

xezon commented Jan 22, 2026

How do these sizes compare with the other builds that we do?

@jurassicLizard
Copy link

How do these sizes compare with the other builds that we do?

mingw binaries are almost always larger as these builds have a lot of statically linked libraries most notably libgcc and libstdc++ which could be dynamically linked dlls and shipped seperately to reduce size if it is a concern

@JohnsterID
Copy link
Author

Yep, this is a trade-off: ease of use and portability/convenience versus size. These builds prioritize self-contained artifacts over minimizing footprint.

@xezon xezon requested a review from OmniBlade January 22, 2026 22:22
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Build Anything related to building, compiling Platform Work towards platform support, such as Linux, MacOS labels Jan 22, 2026
stephanmeesters pushed a commit to stephanmeesters/GeneralsGameCode that referenced this pull request Jan 27, 2026
…perHackers#2163)

Add automated MinGW-w64 (i686) build jobs for both Generals and GeneralsMD
to the CI pipeline, enabling Linux-hosted cross-compilation with artifact
collection matching the MSVC PDB workflow.

Changes:
- .github/workflows/ci.yml: Add two new matrix build jobs
  - build-mingw-generals: Builds Generals with mingw-w64-i686 toolchain
  - build-mingw-generalsmd: Builds GeneralsMD with mingw-w64-i686 toolchain
  - Matrix: mingw-w64-i686 (Release), mingw-w64-i686-debug (Debug)
  - Profile preset excluded (uses MSVC inline ASM with no GCC equivalent)

Toolchain setup (ubuntu-latest):
- MinGW-w64 cross-compiler (i686-w64-mingw32-gcc)
- Wine stable + widl for COM interface compilation
- CMake with Unix Makefiles generator
- Cached toolchain and dependencies

Artifact collection:
- Stripped executable (.exe) + separate debug symbols (.exe.debug) for Release
- Single executable with embedded symbols for Debug
- Matches MSVC .exe + .pdb workflow
- Static linked (no DLL dependencies)
- 30-day retention period

Jobs respect detect-changes filter (Generals/**, GeneralsMD/**, Core/**,
.github/workflows/**, etc.) for conditional execution, identical to existing
VC6 and win32 build triggers.

Result: 4 new artifact combinations
- Generals-mingw-w64-i686 (76 MB: 12 MB exe + 229 MB debug)
- Generals-mingw-w64-i686-debug (56.6 MB: 200 MB exe)
- GeneralsMD-mingw-w64-i686 (82.2 MB: 13 MB exe + 248 MB debug)
- GeneralsMD-mingw-w64-i686-debug (61.4 MB: 215 MB exe)
stephanmeesters pushed a commit to stephanmeesters/GeneralsGameCode that referenced this pull request Jan 27, 2026
…perHackers#2163)

Add automated MinGW-w64 (i686) build jobs for both Generals and GeneralsMD
to the CI pipeline, enabling Linux-hosted cross-compilation with artifact
collection matching the MSVC PDB workflow.

Changes:
- .github/workflows/ci.yml: Add two new matrix build jobs
  - build-mingw-generals: Builds Generals with mingw-w64-i686 toolchain
  - build-mingw-generalsmd: Builds GeneralsMD with mingw-w64-i686 toolchain
  - Matrix: mingw-w64-i686 (Release), mingw-w64-i686-debug (Debug)
  - Profile preset excluded (uses MSVC inline ASM with no GCC equivalent)

Toolchain setup (ubuntu-latest):
- MinGW-w64 cross-compiler (i686-w64-mingw32-gcc)
- Wine stable + widl for COM interface compilation
- CMake with Unix Makefiles generator
- Cached toolchain and dependencies

Artifact collection:
- Stripped executable (.exe) + separate debug symbols (.exe.debug) for Release
- Single executable with embedded symbols for Debug
- Matches MSVC .exe + .pdb workflow
- Static linked (no DLL dependencies)
- 30-day retention period

Jobs respect detect-changes filter (Generals/**, GeneralsMD/**, Core/**,
.github/workflows/**, etc.) for conditional execution, identical to existing
VC6 and win32 build triggers.

Result: 4 new artifact combinations
- Generals-mingw-w64-i686 (76 MB: 12 MB exe + 229 MB debug)
- Generals-mingw-w64-i686-debug (56.6 MB: 200 MB exe)
- GeneralsMD-mingw-w64-i686 (82.2 MB: 13 MB exe + 248 MB debug)
- GeneralsMD-mingw-w64-i686-debug (61.4 MB: 215 MB exe)
@xezon
Copy link

xezon commented Feb 22, 2026

@JohnsterID can you Rebase this to see if it still compiles?

…perHackers#2163)

Add automated MinGW-w64 (i686) build jobs for both Generals and GeneralsMD
to the CI pipeline, enabling Linux-hosted cross-compilation with artifact
collection matching the MSVC PDB workflow.

Changes:
- .github/workflows/ci.yml: Add two new matrix build jobs
  - build-mingw-generals: Builds Generals with mingw-w64-i686 toolchain
  - build-mingw-generalsmd: Builds GeneralsMD with mingw-w64-i686 toolchain
  - Matrix: mingw-w64-i686 (Release), mingw-w64-i686-debug (Debug)
  - Profile preset excluded (uses MSVC inline ASM with no GCC equivalent)

Toolchain setup (ubuntu-latest):
- MinGW-w64 cross-compiler (i686-w64-mingw32-gcc)
- Wine stable + widl for COM interface compilation
- CMake with Unix Makefiles generator
- Cached toolchain and dependencies

Artifact collection:
- Stripped executable (.exe) + separate debug symbols (.exe.debug) for Release
- Single executable with embedded symbols for Debug
- Matches MSVC .exe + .pdb workflow
- Static linked (no DLL dependencies)
- 30-day retention period

Jobs respect detect-changes filter (Generals/**, GeneralsMD/**, Core/**,
.github/workflows/**, etc.) for conditional execution, identical to existing
VC6 and win32 build triggers.

Result: 4 new artifact combinations
- Generals-mingw-w64-i686 (76 MB: 12 MB exe + 229 MB debug)
- Generals-mingw-w64-i686-debug (56.6 MB: 200 MB exe)
- GeneralsMD-mingw-w64-i686 (82.2 MB: 13 MB exe + 248 MB debug)
- GeneralsMD-mingw-w64-i686-debug (61.4 MB: 215 MB exe)
@JohnsterID JohnsterID force-pushed the add-mingw-i686-build branch from 7ba67b2 to ff7557a Compare March 7, 2026 08:28
The Cache MinGW-w64 Dependencies step attempted to cache system paths
(/usr/lib/gcc/i686-w64-mingw32, /usr/i686-w64-mingw32) which is
problematic due to permission issues with actions/cache when handling
root-owned paths. Additionally, the Install MinGW-w64 Toolchain step
ran unconditionally without checking cache-hit status, making the
cache completely redundant.

Remove the cache step entirely and rely on apt-get install which is
fast enough (~4s at 76MB/s) and reliable.
Comment on lines +225 to +230
- name: Cache CMake Dependencies
id: cache-cmake-deps
uses: actions/cache@v4
with:
path: build/${{ matrix.preset }}/_deps
key: cmake-deps-mingw-${{ matrix.preset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache key collision between concurrent jobs: both build-mingw-generals and build-mingw-generalsmd produce identical cache keys for matching preset values (e.g., both output cmake-deps-mingw-mingw-w64-i686-<hash>). When these jobs run in parallel, whichever finishes first wins the single cache slot; the other job's save is silently dropped.

While the CMake dependencies are likely identical today, the pattern is fragile. If Generals and GeneralsMD ever require different sub-dependencies, one job will silently restore the wrong cached tree. Add a job-specific discriminator to the cache key to eliminate ambiguity — for example, use cmake-deps-mingw-generals-${{ matrix.preset }}-... in build-mingw-generals and cmake-deps-mingw-generalsmd-${{ matrix.preset }}-... in build-mingw-generalsmd.

The same collision exists in build-mingw-generalsmd at line 313–318.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/ci.yml
Line: 225-230

Comment:
Cache key collision between concurrent jobs: both `build-mingw-generals` and `build-mingw-generalsmd` produce identical cache keys for matching preset values (e.g., both output `cmake-deps-mingw-mingw-w64-i686-<hash>`). When these jobs run in parallel, whichever finishes first wins the single cache slot; the other job's save is silently dropped.

While the CMake dependencies are likely identical today, the pattern is fragile. If Generals and GeneralsMD ever require different sub-dependencies, one job will silently restore the wrong cached tree. Add a job-specific discriminator to the cache key to eliminate ambiguity — for example, use `cmake-deps-mingw-generals-${{ matrix.preset }}-...` in `build-mingw-generals` and `cmake-deps-mingw-generalsmd-${{ matrix.preset }}-...` in `build-mingw-generalsmd`.

The same collision exists in `build-mingw-generalsmd` at line 313–318.

How can I resolve this? If you propose a fix, please make it concise.

@xezon
Copy link

xezon commented Mar 7, 2026

Ok every target is building. Are we happy to merge this now or is there still something to do?

@tintinhamans tintinhamans changed the title build(ci): Add MinGW-w64 i686 cross-compilation to CI workflow ci(build): Add MinGW-w64 i686 cross-compilation to CI workflow Mar 8, 2026
@tintinhamans
Copy link

Changed title to ci(build) as this change is about CI primarily, not build like e.g. a CMake change would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build Anything related to building, compiling Minor Severity: Minor < Major < Critical < Blocker Platform Work towards platform support, such as Linux, MacOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make project buildable using MinGW toolchain

5 participants