Build: a GNU (non-MSVC) build exports no D3D12SDKVersion/D3D12SDKPath, so every start asks Windows for SM 6.5 #1899

Closed
opened 2026-11-29 02:06:33 +00:00 by github-bot · 1 comment
Owner

@⁠wzl271 on GitHub · 2026-11-29 02:01 UTC · original

What happens

Building with a GNU toolchain (x86_64-pc-windows-gnu, MinGW-w64) produces a victory.exe that refuses to start:

Error: this PC's Direct3D 12 runs shader model 6.5, and the game needs 6.6: every shader would be refused and the game would close at once. Microsoft's newer runtime is in place (D3D12 beside victory.exe), so it is the graphics driver: update it, or use Windows 11

The D3D12\D3D12Core.dll (Agility 1.614.1) is beside the exe, and the driver is fine — the same folder starts fine with the MSVC-built release v2026.11.28.03.

Why

apps/victory/build.rs exports the two names Direct3D 12 reads, but only for the MSVC target:

if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") {
    println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKVersion,DATA");
    println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKPath,DATA");
    println!("cargo:rustc-link-arg-bins=/DELAYLOAD:d3d12.dll");
    println!("cargo:rustc-link-arg-bins=delayimp.lib");
}

GNU ld has no /EXPORT: switch, so the exe's export directory stays empty (objdump -p victory.exe → Export Directory ... 0000000000000000 00000000) and Windows falls back to its own d3d12.dll (SM 6.5 on Windows 10 19045).

Fix that works here

A module definition file as a link input covers both, and being exported also keeps the two statics from --gc-sections:

_ => {
    let out = std::path::PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR"));
    let def = out.join("victory-exports.def");
    std::fs::write(&def, "EXPORTS\nD3D12SDKVersion DATA\nD3D12SDKPath DATA\n").expect("write def");
    println!("cargo:rustc-link-arg-bins={}", def.display());
}

After that, objdump -p shows both names in the export table and the log says:

INFO victory_gpu::device: D3D12.X device version=0x20004
INFO victory_gpu::host: host shader model model=6.8 runtime=Some("...\\D3D12\\D3D12Core.dll")
INFO victory_gpu::host: host D3D12 device ready

Note d3d12.dll stays a normal import on this path, so it is loaded before main — match_d3d12_core() then only ever confirms the 614 the static already holds, which is harmless (the D3D12 folder here is 1.614.1). Delay-loading would still be nicer for people who drop a different Agility version in place.

Environment

  • Windows 10 19045, no MSVC/VS Build Tools (a non-admin session), so GNU is the only option
  • rustc 1.100.1 (stable-x86_64-pc-windows-gnu), MinGW-W64 gcc 16.2.0, CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=gcc
  • cargo build --release --locked -p victory --target x86_64-pc-windows-gnu — builds clean apart from warnings
  • RX 7900 GRE 16 GB / R5 5600 / 48 GB / Adrenalin 32.0.32029.2010
**@⁠wzl271** on GitHub · 2026-11-29 02:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1899) ### What happens Building with a **GNU toolchain** (`x86_64-pc-windows-gnu`, MinGW-w64) produces a `victory.exe` that refuses to start: ``` Error: this PC's Direct3D 12 runs shader model 6.5, and the game needs 6.6: every shader would be refused and the game would close at once. Microsoft's newer runtime is in place (D3D12 beside victory.exe), so it is the graphics driver: update it, or use Windows 11 ``` The `D3D12\D3D12Core.dll` (Agility 1.614.1) is beside the exe, and the driver is fine — the same folder starts fine with the MSVC-built release `v2026.11.28.03`. ### Why `apps/victory/build.rs` exports the two names Direct3D 12 reads, but only for the MSVC target: ```rust if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") { println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKVersion,DATA"); println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKPath,DATA"); println!("cargo:rustc-link-arg-bins=/DELAYLOAD:d3d12.dll"); println!("cargo:rustc-link-arg-bins=delayimp.lib"); } ``` GNU `ld` has no `/EXPORT:` switch, so the exe's export directory stays empty (`objdump -p victory.exe` → `Export Directory ... 0000000000000000 00000000`) and Windows falls back to its own `d3d12.dll` (SM 6.5 on Windows 10 19045). ### Fix that works here A module definition file as a link input covers both, and being exported also keeps the two statics from `--gc-sections`: ```rust _ => { let out = std::path::PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR")); let def = out.join("victory-exports.def"); std::fs::write(&def, "EXPORTS\nD3D12SDKVersion DATA\nD3D12SDKPath DATA\n").expect("write def"); println!("cargo:rustc-link-arg-bins={}", def.display()); } ``` After that, `objdump -p` shows both names in the export table and the log says: ``` INFO victory_gpu::device: D3D12.X device version=0x20004 INFO victory_gpu::host: host shader model model=6.8 runtime=Some("...\\D3D12\\D3D12Core.dll") INFO victory_gpu::host: host D3D12 device ready ``` Note `d3d12.dll` stays a normal import on this path, so it is loaded before `main` — `match_d3d12_core()` then only ever confirms the 614 the static already holds, which is harmless (the D3D12 folder here is 1.614.1). Delay-loading would still be nicer for people who drop a different Agility version in place. ### Environment - Windows 10 19045, no MSVC/VS Build Tools (a non-admin session), so GNU is the only option - rustc 1.100.1 (`stable-x86_64-pc-windows-gnu`), MinGW-W64 gcc 16.2.0, `CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=gcc` - `cargo build --release --locked -p victory --target x86_64-pc-windows-gnu` — builds clean apart from warnings - RX 7900 GRE 16 GB / R5 5600 / 48 GB / Adrenalin 32.0.32029.2010
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 02:06:33 +00:00
Author
Owner

@⁠kalberts0089-hash on GitHub · 2026-11-29 08:00 UTC · original

Two things to add to the analysis above, plus a corroborating link test. I don't have MinGW (Windows 11, RTX 4070 Ti, MSVC toolchain), so I couldn't check anything against GNU ld itself.

Nothing would catch a GNU build that has lost the exports. apps/victory/build.rs:11-16 has no non-MSVC branch. rust-toolchain.toml lists only x86_64-pc-windows-msvc. .github/workflows/ci.yml builds only on windows-latest with that toolchain. The MSVC builds are fine. The published v2026.11.28.03 exe, my build of that tag and my build of main at e1f2eb6 all show the same thing:

dumpbin /exports victory.exe
    ordinal hint RVA      name
          1    0 008828B0 D3D12SDKPath
          2    1 00AB1080 D3D12SDKVersion
dumpbin /imports victory.exe
  Section contains the following delay load imports:
    d3d12.dll

The error message points at the driver in this case. apps/victory/src/play.rs:827-829 says "it is the graphics driver" whenever D3D12Core.dll is in the D3D12 folder, so a build with no exports gets the same message as a real driver problem. exported_sdk_version() (apps/victory/src/main.rs:63) already parses a PE export table. Run on std::fs::read(current_exe()), it tells the two cases apart. With a throwaway test calling it on the exes below and on the release exes:

exe exported_sdk_version()
test exe, no exports None
test exe, .def input Some(614)
test exe, /EXPORT:...,DATA Some(614)
published v2026.11.28.03 victory.exe Some(614)
main e1f2eb6 release build Some(614)

Link test with rust-lld (not GNU ld). I used the pinned 1.98.1 toolchain with the x86_64-pc-windows-gnu std, -Clinker-flavor=ld.lld and stub libs. The test is a no_std exe declaring the same two statics as main.rs:45-49 and main.rs:195-200:

link args dumpbin /headers export directory
none (what build.rs gives GNU today) 0 [0]
victory-exports.def (the one in this issue) 2038 [61], both names
/EXPORT:D3D12SDKVersion,DATA etc. 2038 [63], both names

The /EXPORT: row only shows that lld's MinGW driver passes / options through. It says nothing about GNU ld.

On delay-loading: with d3d12.dll as a normal import, a GNU build always asks for 614. Per main.rs:30-43, asking for 614 failed with 0x887E0003 in two cases: with a 1.618/1.620 D3D12 folder, and on Windows 11 22H2 with no folder. That is what 0f0ada1 fixed for MSVC. A possible route for GNU is a delay-import library from dlltool -y (--output-delaylib) for d3d12.dll. I haven't tried it.

**@⁠kalberts0089-hash** on GitHub · 2026-11-29 08:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1899#issuecomment-7252828156) Two things to add to the analysis above, plus a corroborating link test. I don't have MinGW (Windows 11, RTX 4070 Ti, MSVC toolchain), so I couldn't check anything against GNU `ld` itself. **Nothing would catch a GNU build that has lost the exports.** `apps/victory/build.rs:11-16` has no non-MSVC branch. `rust-toolchain.toml` lists only `x86_64-pc-windows-msvc`. `.github/workflows/ci.yml` builds only on `windows-latest` with that toolchain. The MSVC builds are fine. The published v2026.11.28.03 exe, my build of that tag and my build of main at e1f2eb6 all show the same thing: ``` dumpbin /exports victory.exe ordinal hint RVA name 1 0 008828B0 D3D12SDKPath 2 1 00AB1080 D3D12SDKVersion dumpbin /imports victory.exe Section contains the following delay load imports: d3d12.dll ``` **The error message points at the driver in this case.** `apps/victory/src/play.rs:827-829` says "it is the graphics driver" whenever `D3D12Core.dll` is in the D3D12 folder, so a build with no exports gets the same message as a real driver problem. `exported_sdk_version()` (`apps/victory/src/main.rs:63`) already parses a PE export table. Run on `std::fs::read(current_exe())`, it tells the two cases apart. With a throwaway test calling it on the exes below and on the release exes: | exe | `exported_sdk_version()` | |---|---| | test exe, no exports | `None` | | test exe, `.def` input | `Some(614)` | | test exe, `/EXPORT:...,DATA` | `Some(614)` | | published v2026.11.28.03 `victory.exe` | `Some(614)` | | main e1f2eb6 release build | `Some(614)` | **Link test with rust-lld (not GNU ld).** I used the pinned 1.98.1 toolchain with the `x86_64-pc-windows-gnu` std, `-Clinker-flavor=ld.lld` and stub libs. The test is a `no_std` exe declaring the same two statics as `main.rs:45-49` and `main.rs:195-200`: | link args | `dumpbin /headers` export directory | |---|---| | none (what build.rs gives GNU today) | `0 [0]` | | `victory-exports.def` (the one in this issue) | `2038 [61]`, both names | | `/EXPORT:D3D12SDKVersion,DATA` etc. | `2038 [63]`, both names | The `/EXPORT:` row only shows that lld's MinGW driver passes `/` options through. It says nothing about GNU `ld`. On delay-loading: with `d3d12.dll` as a normal import, a GNU build always asks for 614. Per `main.rs:30-43`, asking for 614 failed with 0x887E0003 in two cases: with a 1.618/1.620 D3D12 folder, and on Windows 11 22H2 with no folder. That is what 0f0ada1 fixed for MSVC. A possible route for GNU is a delay-import library from `dlltool -y` (`--output-delaylib`) for `d3d12.dll`. I haven't tried it.
This discussion has been locked. Commenting is limited to contributors.
No milestone
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
github/trustno1-coder--VIctory-NVIDIA#1899
No description provided.