[PR #3377] [MERGED] Native mods build on Windows: MinGW-w64 with the toolchain, and a stage path horizon-mixins takes #4943

Closed
opened 2026-11-03 05:09:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3377
Author: @d3grando
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @levzzz5154

Base: main ← Head: native-mods-windows


📝 Commits (1)

  • 88724d0 Native mods build on Windows: MinGW-w64 with the toolchain, and a stage path horizon-mixins takes

📊 Changes

3 files changed (+221 additions, -12 deletions)

View changed files

📝 docs/native-mods.md (+16 -3)
📝 launcher/src/native_mods.rs (+29 -1)
📝 launcher/src/rust_toolchain.rs (+176 -8)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Native mods didn't build on Windows (docs/native-mods.md listed it as unproven). Tried with launcher 0.2.21,
Veinminer 0.3.0 from the registry and game v0.2.94, on Windows 11 (Ryzen 7 9800X3D, no MinGW or MSYS2 installed), the
build stopped three times:

  1. horizon-mixins doesn't build (23 s in): error calling dlltool 'dlltool.exe': program not found, compiling
    windows-sys 0.61.2. It imports through raw-dylib, and on windows-gnu rustc makes those import libraries with
    dlltool. rust-mingw has one (lib/rustlib/x86_64-pc-windows-gnu/bin/self-contained/), but it isn't on the
    build's PATH; with it there, dlltool fails with CreateProcess, because it runs the GNU assembler
    (dlltool -v: run: …\self-contained\as --64 …) and rust-mingw ships none. A crate with nothing but
    windows-sys = "=0.61.2" fails the same way with the launcher's toolchain.
  2. apply fails: E_IO: Incorrect function. (os error 1), file \\?\C:. native_mods.rs canonicalizes its
    folder (for macOS's /tmp), which on Windows gives \\?\C:\…, and horizon-mixins' output_path stats each
    component, \\?\C: (the volume) included. Fixed in the tool too: horizon-rust/horizon-mixins#3.
  3. The game doesn't build, 130 crates in: ring 0.17.14 (rustls) compiles C with cc: failed to find tool "gcc.exe". rust-mingw's gcc.exe is a linker only (its GCC-WARNING.txt says so), and hidapi and wasmtime
    compile C too.

So the toolchain needs a C compiler and binutils on Windows. This brings MinGW-w64 with it:

  • rust_toolchain.rs: MINGW, WinLibs' GCC 16.2.0 on MinGW-w64 14.0.0 (MSVCRT, the C runtime rust-mingw links
    against; POSIX threads; SEH), one zip pinned by SHA-256, unpacked into the toolchain's mingw64/ without its
    documentation (875 of 925 MB), in the same .partial → rename install as Rust's components. Toolchain::command
    puts mingw64/bin on PATH right after Rust's bin. A Windows toolchain without it counts as not installed, so
    the next build installs it (with Rust's components again: 22 s here).
  • native_mods.rs: plain, the stage path without a drive path's verbatim prefix.
  • docs/native-mods.md: what the toolchain brings on Windows, the Windows measurements, and Windows off the
    "unproven" list.
  • Tests: the MinGW pin, which zip entries land where (share/ and anything outside mingw64/ stay out), a zip
    unpacked for real, the PATH order, and plain (a drive path loses \\?\, a share and a Unix path don't change).

What I tried before settling on this, all on the same machine:

Result
Put rust-mingw's self-contained on PATH dlltool found, fails without as.exe
Rust x86_64-pc-windows-gnullvm + rust-lld (no MinGW) windows-sys builds without dlltool and a small binary runs, but horizon-mixins doesn't link: no import libraries for crates linking advapi32/cfgmgr32 the old way (winapi), and rust-mingw's are MSVCRT, not UCRT
Binutils only (as, dlltool + 5 DLLs, 6.8 MB) horizon-mixins builds; the game stops at ring (no C compiler)
MinGW-w64 (this) the game builds and Veinminer works
MSVC host with Visual Studio Build Tools builds (that's how I build Horizon here), but players would need Visual Studio

WinLibs is a third-party binary in the toolchain, so it's your call; if you'd rather pin another MinGW-w64 build
(MSYS2's packages, w64devkit), only MINGW changes. It's 264 MB to download, once, and only for players who build
native mods.

Vanilla reference

Horizon-only (the launcher's toolchain for native mods); no harness.

Self-check

pr_ready (tools/pr_ready.py --quick on DESKTOP-J80C959, against origin/main at 1d6d4cf0a, 1 min 0 s)

Check Result
Scope ✅ 3 files, +221 −12
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 399 run, FAILED (failures=1, skipped=12) (38 s)
rustfmt ➖ no Rust change
clippy ➖ no Rust change
tests ➖ no crate touched
doc tests ➖ no crate touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅
launcher clippy ❌ failed (3 s)
launcher tests ❌ 220 passed, 2 failed (15 s)
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

All three ❌ are Windows-only and fail the same on origin/main here: launcher clippy stops at
unused import: std::os::windows::process::CommandExt in sources.rs:497 (Windows-only code, so Linux CI doesn't
see it); the 2 launcher tests are backend::tests::mojang_downloads_only_for_an_owner and
servers::tests::deleting_a_stopped_server_moves_its_world_and_backups_to_trash; the Python one is
test_port_publish.test_body_has_names_and_signatures_only. Clippy has nothing on the two files this changes
(cargo +stable clippy --all-targets --locked), and every rust_toolchain and native_mods test passes, the 5 new
ones included.

End to end

With this launcher (a debug build: a release build of gpui needs the Windows SDK's fxc.exe, which this machine
lacks), from no toolchain and an empty native/target/, no MinGW anywhere on the system, and the pinned horizon-mixins
unchanged:

horizon-launcher native-build <veinminer-0.3.0> --version v0.2.94 --trust-native-code
…
native-83f15fa-4bbdb580b9ca built and selected for its instance (483 s).

Release compile 6 min 57 s, 8 min 3 s in all. In that build, /veinminer answers "Veinminer: on", and one break in
a 3×3×3 coal ore vein leaves 0 ore and drops 35 coal.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3377 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `native-mods-windows` --- ### 📝 Commits (1) - [`88724d0`](https://github.com/horizon-rust/horizon/commit/88724d07532acf8887c5e8ceef22a4496ca87ea1) Native mods build on Windows: MinGW-w64 with the toolchain, and a stage path horizon-mixins takes ### 📊 Changes **3 files changed** (+221 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/native-mods.md` (+16 -3) 📝 `launcher/src/native_mods.rs` (+29 -1) 📝 `launcher/src/rust_toolchain.rs` (+176 -8) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Native mods didn't build on Windows (`docs/native-mods.md` listed it as unproven). Tried with launcher 0.2.21, Veinminer 0.3.0 from the registry and game v0.2.94, on Windows 11 (Ryzen 7 9800X3D, no MinGW or MSYS2 installed), the build stopped three times: 1. **horizon-mixins doesn't build** (23 s in): `error calling dlltool 'dlltool.exe': program not found`, compiling `windows-sys` 0.61.2. It imports through `raw-dylib`, and on `windows-gnu` rustc makes those import libraries with `dlltool`. rust-mingw has one (`lib/rustlib/x86_64-pc-windows-gnu/bin/self-contained/`), but it isn't on the build's `PATH`; with it there, dlltool fails with `CreateProcess`, because it runs the GNU assembler (`dlltool -v`: `run: …\self-contained\as --64 …`) and rust-mingw ships none. A crate with nothing but `windows-sys = "=0.61.2"` fails the same way with the launcher's toolchain. 2. **`apply` fails**: `E_IO: Incorrect function. (os error 1)`, file `\\?\C:`. `native_mods.rs` canonicalizes its folder (for macOS's `/tmp`), which on Windows gives `\\?\C:\…`, and horizon-mixins' `output_path` stats each component, `\\?\C:` (the volume) included. Fixed in the tool too: horizon-rust/horizon-mixins#3. 3. **The game doesn't build**, 130 crates in: `ring` 0.17.14 (rustls) compiles C with `cc`: `failed to find tool "gcc.exe"`. rust-mingw's `gcc.exe` is a linker only (its `GCC-WARNING.txt` says so), and `hidapi` and wasmtime compile C too. So the toolchain needs a C compiler and binutils on Windows. This brings MinGW-w64 with it: - `rust_toolchain.rs`: `MINGW`, WinLibs' GCC 16.2.0 on MinGW-w64 14.0.0 (MSVCRT, the C runtime rust-mingw links against; POSIX threads; SEH), one zip pinned by SHA-256, unpacked into the toolchain's `mingw64/` without its documentation (875 of 925 MB), in the same `.partial` → rename install as Rust's components. `Toolchain::command` puts `mingw64/bin` on `PATH` right after Rust's `bin`. A Windows toolchain without it counts as not installed, so the next build installs it (with Rust's components again: 22 s here). - `native_mods.rs`: `plain`, the stage path without a drive path's verbatim prefix. - `docs/native-mods.md`: what the toolchain brings on Windows, the Windows measurements, and Windows off the "unproven" list. - Tests: the MinGW pin, which zip entries land where (`share/` and anything outside `mingw64/` stay out), a zip unpacked for real, the `PATH` order, and `plain` (a drive path loses `\\?\`, a share and a Unix path don't change). What I tried before settling on this, all on the same machine: | | Result | |---|---| | Put rust-mingw's `self-contained` on `PATH` | dlltool found, fails without `as.exe` | | Rust `x86_64-pc-windows-gnullvm` + `rust-lld` (no MinGW) | `windows-sys` builds without dlltool and a small binary runs, but horizon-mixins doesn't link: no import libraries for crates linking `advapi32`/`cfgmgr32` the old way (`winapi`), and rust-mingw's are MSVCRT, not UCRT | | Binutils only (`as`, `dlltool` + 5 DLLs, 6.8 MB) | horizon-mixins builds; the game stops at `ring` (no C compiler) | | **MinGW-w64 (this)** | **the game builds and Veinminer works** | | MSVC host with Visual Studio Build Tools | builds (that's how I build Horizon here), but players would need Visual Studio | WinLibs is a third-party binary in the toolchain, so it's your call; if you'd rather pin another MinGW-w64 build (MSYS2's packages, w64devkit), only `MINGW` changes. It's 264 MB to download, once, and only for players who build native mods. ## Vanilla reference Horizon-only (the launcher's toolchain for native mods); no harness. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-J80C959, against origin/main at 1d6d4cf0a, 1 min 0 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +221 −12 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 399 run, FAILED (failures=1, skipped=12) (38 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ | | launcher clippy | ❌ failed (3 s) | | launcher tests | ❌ 220 passed, 2 failed (15 s) | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | All three ❌ are Windows-only and fail the same on `origin/main` here: launcher clippy stops at `unused import: std::os::windows::process::CommandExt` in `sources.rs:497` (Windows-only code, so Linux CI doesn't see it); the 2 launcher tests are `backend::tests::mojang_downloads_only_for_an_owner` and `servers::tests::deleting_a_stopped_server_moves_its_world_and_backups_to_trash`; the Python one is `test_port_publish.test_body_has_names_and_signatures_only`. Clippy has nothing on the two files this changes (`cargo +stable clippy --all-targets --locked`), and every `rust_toolchain` and `native_mods` test passes, the 5 new ones included. ## End to end With this launcher (a debug build: a release build of gpui needs the Windows SDK's `fxc.exe`, which this machine lacks), from no toolchain and an empty `native/target/`, no MinGW anywhere on the system, and the pinned horizon-mixins unchanged: ``` horizon-launcher native-build <veinminer-0.3.0> --version v0.2.94 --trust-native-code … native-83f15fa-4bbdb580b9ca built and selected for its instance (483 s). ``` Release compile 6 min 57 s, 8 min 3 s in all. In that build, `/veinminer` answers "Veinminer: on", and one break in a 3×3×3 coal ore vein leaves 0 ore and drops 35 coal. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:09:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4943
No description provided.