Skip to content

build(x64): add an experimental MinGW-w64 x86_64 toolchain and preset - #3250

Closed
MeneerHaas wants to merge 1 commit into
TheSuperHackers:mainfrom
MeneerHaas:x64/pr1-toolchain
Closed

build(x64): add an experimental MinGW-w64 x86_64 toolchain and preset#3250
MeneerHaas wants to merge 1 commit into
TheSuperHackers:mainfrom
MeneerHaas:x64/pr1-toolchain

Conversation

@MeneerHaas

Copy link
Copy Markdown

First of four pieces split out of #3248, per @xezon's suggestion.

Build system only — no C++ changes, so existing builds cannot be affected.

  • Toolchain file and mingw-w64-x86_64 preset, alongside the existing i686 one.
  • mingw.cmake: the 32-bit-only guard now covers both architectures; d3d8 is gated to 32-bit because link_libraries() is directory-scoped and would otherwise hit the Miles/Bink stubs.
  • dx8.cmake: on x64, d3d8lib carries headers and defines only. MinGW-w64 x86_64 ships no libd3d8.a and no libd3dx8, so the x64 target compiles but does not link. That is expected at this stage.

MFC tools are off for this toolchain — MinGW has no MFC.

Groundwork for #473. Follow-ups will add pointer-sized integer types, persistence identity widths, and the crash-handler ports, one PR at a time.

Testing: clean VC6 builds of both games unchanged (0 errors, all 13 retail .text digests reproduce); MinGW i686 unchanged; x64 preset configures and compiles.

Code was written with LLM assistance and verified by clean builds and byte-level artifact comparison, per CONTRIBUTING.

🤖 Generated with Claude Code

Adds the toolchain file and preset, lifts the 32-bit-only guard in
mingw.cmake, and builds the Miles and Bink stubs on x64. DX8 stays
headers-only there: MinGW-w64 x86_64 ships no libd3d8.a and no libd3dx8,
so the x64 target compiles but cannot link. Existing presets are
untouched. Groundwork for #473.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add experimental MinGW-w64 x86_64 build configuration

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Adds an experimental x86_64 MinGW-w64 toolchain and release configure preset.
• Enables shared SDK stubs for 64-bit Windows builds while preserving 32-bit behavior.
• Makes DX8 headers-only on x64 because MinGW lacks required DirectX 8 libraries.
Diagram

graph TD
  A["x64 Preset"] --> B["x64 Toolchain"] --> C["Root CMake"] --> D["MinGW Settings"]
  C --> E["SDK Stubs"] --> G["Game Targets"]
  C --> F["DX8 Interface"] --> G
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add architecture handling upstream
  • ➕ Keeps d3d8lib ownership inside the min-dx8-sdk package.
  • ➕ Avoids duplicating upstream target configuration and reduces future drift.
  • ➖ Requires coordinating and pinning a new upstream package revision.
  • ➖ The headers-only x64 behavior may be specific to this project's staged port.

Recommendation: The local architecture-aware interface target is appropriate for an experimental, staged x64 port because it is deterministic and isolates unsupported linking. Consider upstreaming the conditional d3d8lib behavior later to avoid divergence from min-dx8-sdk.

Files changed (5) +97 / -8

Enhancement (4) +86 / -8
CMakeLists.txtLoad Windows dependency stubs for both pointer widths +2/-2

Load Windows dependency stubs for both pointer widths

• Removes the 32-bit pointer-size restriction around Miles, Bink, and DX8 dependency setup. Windows x64 configurations can now create the same shared dependency targets.

CMakeLists.txt

dx8.cmakeMake the DX8 interface architecture-aware +44/-1

Make the DX8 interface architecture-aware

• Defines d3d8lib locally after populating the pinned SDK source. The target retains existing MSVC and 32-bit MinGW linkage while exposing only headers and BUILD_WITH_D3D8 on x64, where required libraries are unavailable.

cmake/dx8.cmake

mingw.cmakePermit experimental 64-bit MinGW configuration +8/-5

Permit experimental 64-bit MinGW configuration

• Replaces the x86_64 fatal error with architecture detection and status reporting. It limits d3d8 linkage and the d3dx8 compatibility alias to 32-bit builds so directory-scoped libraries do not break x64 SDK stubs.

cmake/mingw.cmake

mingw-w64-x86_64.cmakeDefine the MinGW-w64 x86_64 cross-toolchain +32/-0

Define the MinGW-w64 x86_64 cross-toolchain

• Configures x86_64 MinGW compilers, binutils, target-root lookup behavior, and 64-bit pointer size. MFC-dependent tools are forcibly disabled because MinGW does not provide MFC.

cmake/toolchains/mingw-w64-x86_64.cmake

Other (1) +11 / -0
CMakePresets.jsonAdd MinGW-w64 x86_64 release preset +11/-0

Add MinGW-w64 x86_64 release preset

• Adds a Unix Makefiles configure preset using the new x86_64 cross-toolchain, Release mode, and compile-command export.

CMakePresets.json

@MeneerHaas

Copy link
Copy Markdown
Author

Withdrawing this for now — I want to take more time over the split before asking anyone to review it. I'll reopen the series when it is ready.

@MeneerHaas MeneerHaas closed this Sep 3, 2026
@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR introduces an experimental MinGW-w64 x86_64 configure preset and toolchain while making the fetched DirectX 8 target architecture-aware. It intentionally permits x64 compilation without providing the libraries needed for final linking.

  • Adds the mingw-w64-x86_64 configure preset and cross-compilation toolchain.
  • Extends Windows dependency setup to x64 and disables MFC-dependent tools for MinGW.
  • Reconstructs d3d8lib locally so x86 retains its link libraries while x64 receives headers and definitions only.

Confidence Score: 4/5

The PR appears safe to merge from a behavioral perspective, with only the non-blocking requirement to add the repository’s license and copyright prologue to the new toolchain file.

The x64 link limitation is explicitly intentional and documented, while the only accepted issue is missing required licensing metadata in the newly created toolchain file.

Files Needing Attention: cmake/toolchains/mingw-w64-x86_64.cmake

Important Files Changed

Filename Overview
CMakeLists.txt Broadens Miles, Bink, and DX8 dependency inclusion from 32-bit Windows to all Windows architectures.
CMakePresets.json Adds a visible release configure preset for the experimental x86_64 MinGW toolchain.
cmake/dx8.cmake Replaces dependency-owned target creation with an architecture-aware local d3d8lib interface target.
cmake/mingw.cmake Enables experimental 64-bit MinGW configuration and restricts unavailable D3D8 libraries and aliases to 32-bit builds.
cmake/toolchains/mingw-w64-x86_64.cmake Adds the x86_64 cross-toolchain and disables MFC tools, but omits the required licensing prologue.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Preset[mingw-w64-x86_64 preset] --> Toolchain[x86_64 MinGW toolchain]
    Toolchain --> Configure[Windows x64 configuration]
    Configure --> Dependencies[Miles, Bink, and DX8 setup]
    Dependencies --> DX8[d3d8lib interface]
    DX8 --> Headers[DX8 headers and definitions]
    DX8 -. unavailable x64 libraries .-> Link[Final game link deferred]
Loading
Prompt To Fix All With AI
### Issue 1
cmake/toolchains/mingw-w64-x86_64.cmake:1
**Missing required licensing prologue**

The new community-owned toolchain file starts directly with its toolchain description, omitting the repository-required GPL header and TheSuperHackers copyright notice; this leaves the distributed file without the required licensing and ownership metadata.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "build(x64): add an experimental MinGW-w6..." | Re-trigger Greptile

@MeneerHaas
MeneerHaas deleted the x64/pr1-toolchain branch September 3, 2026 08:16
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (2) 📜 Skill insights (0)

Grey Divider


Action required

1. x64 tools are disabled 📎 Requirement gap ≡ Correctness
Description
The x64 toolchain forcibly disables both RTS_BUILD_GENERALS_TOOLS and RTS_BUILD_ZEROHOUR_TOOLS.
Consequently, two of the four targets required by the compliance rule are not upgraded or built for
x64.
Code

cmake/toolchains/mingw-w64-x86_64.cmake[R31-32]

+set(RTS_BUILD_GENERALS_TOOLS OFF CACHE BOOL "Disable MFC-dependent Generals tools for MinGW" FORCE)
+set(RTS_BUILD_ZEROHOUR_TOOLS OFF CACHE BOOL "Disable MFC-dependent Zero Hour tools for MinGW" FORCE)
Evidence
PR Compliance ID 1 requires Generals Tools and Zero Hour Tools to be upgraded successfully. The new
x64 toolchain explicitly forces both corresponding build options off, while the tool directories are
only configured when those options are enabled.

Upgrade all Generals and Zero Hour targets to x64
cmake/toolchains/mingw-w64-x86_64.cmake[29-32]
Generals/Code/CMakeLists.txt[40-41]
GeneralsMD/Code/CMakeLists.txt[40-41]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The x64 toolchain disables the required Generals Tools and Zero Hour Tools targets.

## Issue Context
PR Compliance ID 1 requires both tool suites to support successful x64 builds. Implement the necessary non-MFC or otherwise supported x64 build path instead of forcibly excluding these targets.

## Fix Focus Areas
- cmake/toolchains/mingw-w64-x86_64.cmake[29-32]
- Generals/Code/Tools/CMakeLists.txt[1-10]
- GeneralsMD/Code/Tools/CMakeLists.txt[1-11]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. x64 games cannot link 📎 Requirement gap ≡ Correctness
Description
The new x64 configuration deliberately omits the unavailable DX8 libraries, but both game
executables still link directly against d3d8 and d3dx8. Therefore, the Generals and Zero Hour
x64 targets cannot produce successfully linked executables as required.
Code

cmake/dx8.cmake[R16-19]

+# MinGW-w64 x86_64 ships no libd3d8.a and no libd3dx8, so on x64 this target
+# carries headers and defines only and cannot link. See issue #473.
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    target_link_libraries(d3d8lib INTERFACE d3d8 dinput8 dxguid)
Evidence
PR Compliance ID 1 requires successful x64 builds of both games. The added DX8 branch explicitly
states that x64 has no link libraries, while g_generals and z_generals continue to require
d3d8 and d3dx8, preventing successful linking.

Upgrade all Generals and Zero Hour targets to x64
cmake/dx8.cmake[16-22]
Generals/Code/Main/CMakeLists.txt[10-16]
GeneralsMD/Code/Main/CMakeLists.txt[10-16]
cmake/mingw.cmake[83-88]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The x64 game targets compile but cannot link because required DirectX 8 libraries are omitted while the executables retain direct references to them.

## Issue Context
PR Compliance ID 1 requires successful x64 upgrades for both games, not compile-only targets. Provide compatible x64 implementations or replace/remove the unsupported dependencies throughout the game link configuration.

## Fix Focus Areas
- cmake/dx8.cmake[14-22]
- cmake/mingw.cmake[57-68]
- Generals/Code/Main/CMakeLists.txt[10-16]
- GeneralsMD/Code/Main/CMakeLists.txt[10-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Build preset missing 🐞 Bug ≡ Correctness
Description
The new mingw-w64-x86_64 configure preset has no matching build preset, so the repository's
standard cmake --build --preset mingw-w64-x86_64 invocation fails with an unknown preset error.
Every existing non-hidden configure preset has a corresponding build preset, and the generic build
workflow invokes presets this way.
Code

CMakePresets.json[R196-200]

+            "name": "mingw-w64-x86_64",
+            "displayName": "MinGW-w64 64-bit (x86_64) Release",
+            "generator": "Unix Makefiles",
+            "binaryDir": "${sourceDir}/build/${presetName}",
+            "toolchainFile": "${sourceDir}/cmake/toolchains/mingw-w64-x86_64.cmake",
Evidence
The x64 entry is defined only in configurePresets; buildPresets ends after the three i686
entries. The repository's reusable build workflow executes cmake --build --preset using the
supplied configure-preset name, demonstrating the expected one-to-one convention.

CMakePresets.json[195-205]
CMakePresets.json[287-305]
.github/workflows/build-toolchain.yml[133-153]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `mingw-w64-x86_64` configure preset lacks a corresponding build preset, causing `cmake --build --preset mingw-w64-x86_64` to fail.

## Issue Context
Existing named configure presets have matching build presets, and the repository's generic build workflow builds using the same preset name.

## Fix Focus Areas
- CMakePresets.json[195-205]
- CMakePresets.json[287-305]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +31 to +32
set(RTS_BUILD_GENERALS_TOOLS OFF CACHE BOOL "Disable MFC-dependent Generals tools for MinGW" FORCE)
set(RTS_BUILD_ZEROHOUR_TOOLS OFF CACHE BOOL "Disable MFC-dependent Zero Hour tools for MinGW" FORCE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. X64 tools are disabled 📎 Requirement gap ≡ Correctness

The x64 toolchain forcibly disables both RTS_BUILD_GENERALS_TOOLS and RTS_BUILD_ZEROHOUR_TOOLS.
Consequently, two of the four targets required by the compliance rule are not upgraded or built for
x64.
Agent Prompt
## Issue description
The x64 toolchain disables the required Generals Tools and Zero Hour Tools targets.

## Issue Context
PR Compliance ID 1 requires both tool suites to support successful x64 builds. Implement the necessary non-MFC or otherwise supported x64 build path instead of forcibly excluding these targets.

## Fix Focus Areas
- cmake/toolchains/mingw-w64-x86_64.cmake[29-32]
- Generals/Code/Tools/CMakeLists.txt[1-10]
- GeneralsMD/Code/Tools/CMakeLists.txt[1-11]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread cmake/dx8.cmake
Comment on lines +16 to +19
# MinGW-w64 x86_64 ships no libd3d8.a and no libd3dx8, so on x64 this target
# carries headers and defines only and cannot link. See issue #473.
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(d3d8lib INTERFACE d3d8 dinput8 dxguid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. X64 games cannot link 📎 Requirement gap ≡ Correctness

The new x64 configuration deliberately omits the unavailable DX8 libraries, but both game
executables still link directly against d3d8 and d3dx8. Therefore, the Generals and Zero Hour
x64 targets cannot produce successfully linked executables as required.
Agent Prompt
## Issue description
The x64 game targets compile but cannot link because required DirectX 8 libraries are omitted while the executables retain direct references to them.

## Issue Context
PR Compliance ID 1 requires successful x64 upgrades for both games, not compile-only targets. Provide compatible x64 implementations or replace/remove the unsupported dependencies throughout the game link configuration.

## Fix Focus Areas
- cmake/dx8.cmake[14-22]
- cmake/mingw.cmake[57-68]
- Generals/Code/Main/CMakeLists.txt[10-16]
- GeneralsMD/Code/Main/CMakeLists.txt[10-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread CMakePresets.json
Comment on lines +196 to +200
"name": "mingw-w64-x86_64",
"displayName": "MinGW-w64 64-bit (x86_64) Release",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "${sourceDir}/cmake/toolchains/mingw-w64-x86_64.cmake",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

3. Build preset missing 🐞 Bug ≡ Correctness

The new mingw-w64-x86_64 configure preset has no matching build preset, so the repository's
standard cmake --build --preset mingw-w64-x86_64 invocation fails with an unknown preset error.
Every existing non-hidden configure preset has a corresponding build preset, and the generic build
workflow invokes presets this way.
Agent Prompt
## Issue description
The new `mingw-w64-x86_64` configure preset lacks a corresponding build preset, causing `cmake --build --preset mingw-w64-x86_64` to fail.

## Issue Context
Existing named configure presets have matching build presets, and the repository's generic build workflow builds using the same preset name.

## Fix Focus Areas
- CMakePresets.json[195-205]
- CMakePresets.json[287-305]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant