d3d12: export the Agility SDK symbols from a gnullvm build too (D3D12-GNULLVM-BUILD) #3238

Open
bercedev wants to merge 1 commit from upstream-pr/3238 into main
bercedev commented 2026-12-02 21:55:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bercedev on 2026-12-02T21:55:37Z.


Claimed in the coordination issue as: D3D12-GNULLVM-BUILD (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7359018429)

What and why

build.rs only told the msvc linker to export D3D12SDKVersion / D3D12SDKPath and delay-load d3d12.dll, so a leonida.exe built on linux with llvm-mingw (x86_64-pc-windows-gnullvm) exported nothing and loaded d3d12.dll before main. lld's mingw driver takes the same switches, so the gnullvm target gets them too. tests/agility.rs now runs for that target, and docs/linux.md shows how to build leonida.exe on linux without xwin.

Tested

  • llvm-readobj on the gnullvm exe: before, no exports and d3d12.dll a normal import. after, both exports and d3d12.dll in the delay-import table
  • tests/agility.rs under wine 11.23: 2 failed with main's build.rs, 2 passed with this one
  • msvc build via xwin: exports and delay-load identical before and after
  • docs tests (tests/test_docs_*.py) pass

GPUs tested: n/a (link and export change, no gpu code)

AI-assisted: yes. code by claude opus, reviewed by separate read-only claude opus and claude sonnet reviewer agents, checked by me.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5615399148 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3238). Originally posted by [bercedev](https://github.com/bercedev) on 2026-12-02T21:55:37Z. --- Claimed in the coordination issue as: D3D12-GNULLVM-BUILD (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7359018429) ### What and why build.rs only told the msvc linker to export D3D12SDKVersion / D3D12SDKPath and delay-load d3d12.dll, so a leonida.exe built on linux with llvm-mingw (x86_64-pc-windows-gnullvm) exported nothing and loaded d3d12.dll before main. lld's mingw driver takes the same switches, so the gnullvm target gets them too. tests/agility.rs now runs for that target, and docs/linux.md shows how to build leonida.exe on linux without xwin. ### Tested - llvm-readobj on the gnullvm exe: before, no exports and d3d12.dll a normal import. after, both exports and d3d12.dll in the delay-import table - tests/agility.rs under wine 11.23: 2 failed with main's build.rs, 2 passed with this one - msvc build via xwin: exports and delay-load identical before and after - docs tests (tests/test_docs_*.py) pass GPUs tested: n/a (link and export change, no gpu code) AI-assisted: yes. code by claude opus, reviewed by separate read-only claude opus and claude sonnet reviewer agents, checked by me.
MoonEyes commented 2026-12-02 21:59:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T21:59:43Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360074380 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3238#issuecomment-7360074380). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T21:59:43Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
merzleckeier commented 2026-12-02 22:05:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T22:05:15Z.

Review: COMMENTED


Reviewed 7fa7043e on f3865cae8. I compiled both versions of build.rs with Rust 1.98.1 and compared their output. The MSVC and plain GNU directives match main, and rustc --print cfg confirms target_env="gnu", target_abi="llvm" for the gnullvm target.

I passed the exact emitted gnullvm arguments through Clang/lld 23.1.5 when linking a synthetic x86-64 PE with a stub d3d12.dll import library. With the base directives, llvm-readobj reports a plain import and no Agility exports. With the PR directives, the PE exports D3D12SDKPath and D3D12SDKVersion and reports d3d12.dll only as a delay import. This checks the linker argument handling and PE tables. The full runtime build and Wine integration are covered by the author’s tests.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6159850597 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3238#pullrequestreview-6159850597). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T22:05:15Z. **Review:** COMMENTED --- Reviewed `7fa7043e` on `f3865cae8`. I compiled both versions of `build.rs` with Rust 1.98.1 and compared their output. The MSVC and plain GNU directives match `main`, and `rustc --print cfg` confirms `target_env="gnu", target_abi="llvm"` for the gnullvm target. I passed the exact emitted gnullvm arguments through Clang/lld 23.1.5 when linking a synthetic x86-64 PE with a stub `d3d12.dll` import library. With the base directives, `llvm-readobj` reports a plain import and no Agility exports. With the PR directives, the PE exports `D3D12SDKPath` and `D3D12SDKVersion` and reports `d3d12.dll` only as a delay import. This checks the linker argument handling and PE tables. The full runtime build and Wine integration are covered by the author’s tests.
bercedev commented 2026-12-02 22:57:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bercedev on 2026-12-02T22:57:54Z.


run report for 7fa7043eb merged onto main f3865cae8 (no conflicts), plus main alone for comparison

setup: rtx 4050 laptop 6 gb, nvidia 620.73.04, i5-14500hx, 32 gb, cachyos linux 7.3.6, proton experimental 11.0 wine with protonida's wineserver patch, vkd3d-proton master f8c1cae83. both exes built the same way (x86_64-pc-windows-gnullvm, --features diagnostics), same prefix, same play-linux.sh settings, series s. numbers from tools/game_gate.py summary on each run folder (i drove the runs from a bash loop since game-gate.ps1 is windows only)

run exe world s median fps result
warm-up (discarded) pr 331 10.8 clean exit, 11 s pipeline gap
1 main 334 13.6 clean exit, 10.5 s pipeline gap
2 pr 183 12.3 device lost (0x887A0005)
3 pr 332 12.2 PASS, clean exit
4 main 106 11.5 hung, no device lost message, had to kill it

so both sides went down once. the pr only adds two exports and delay-loads d3d12.dll on the gnullvm target, and the msvc link is unchanged, so i don't think either failure comes from it. the kernel log showed NVRM intermapRegisterDmaMapping errors on both sides (most before run 2's device loss), and vram sat at ~5.2/5.2 gb, so it looks like this 6 gb card + linux setup being on the edge rather than the change. run 3 went through the same scripted corridor scene where run 2 died

one thing that makes every linux run noisier than it should be: the log says "no host pipeline library: pipelines are not kept" on every start, so nothing is persisted and each launch recompiles hundreds of psos (the 10 s gaps above, LEONIDA_PIPELINE_WAIT_MS=10000). that's the empty-slice CreatePipelineLibrary call vkd3d-proton rejects with E_INVALIDARG, which #2654 fixes. merging #2654 would make linux gate runs a lot more meaningful

AI-assisted: yes (claude). runs played by me

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361388132 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3238#issuecomment-7361388132). Originally posted by [bercedev](https://github.com/bercedev) on 2026-12-02T22:57:54Z. --- run report for 7fa7043eb merged onto main f3865cae8 (no conflicts), plus main alone for comparison setup: rtx 4050 laptop 6 gb, nvidia 620.73.04, i5-14500hx, 32 gb, cachyos linux 7.3.6, proton experimental 11.0 wine with protonida's wineserver patch, vkd3d-proton master f8c1cae83. both exes built the same way (x86_64-pc-windows-gnullvm, --features diagnostics), same prefix, same play-linux.sh settings, series s. numbers from tools/game_gate.py summary on each run folder (i drove the runs from a bash loop since game-gate.ps1 is windows only) | run | exe | world s | median fps | result | |---|---|---|---|---| | warm-up (discarded) | pr | 331 | 10.8 | clean exit, 11 s pipeline gap | | 1 | main | 334 | 13.6 | clean exit, 10.5 s pipeline gap | | 2 | pr | 183 | 12.3 | device lost (0x887A0005) | | 3 | pr | 332 | 12.2 | PASS, clean exit | | 4 | main | 106 | 11.5 | hung, no device lost message, had to kill it | so both sides went down once. the pr only adds two exports and delay-loads d3d12.dll on the gnullvm target, and the msvc link is unchanged, so i don't think either failure comes from it. the kernel log showed NVRM intermapRegisterDmaMapping errors on both sides (most before run 2's device loss), and vram sat at ~5.2/5.2 gb, so it looks like this 6 gb card + linux setup being on the edge rather than the change. run 3 went through the same scripted corridor scene where run 2 died one thing that makes every linux run noisier than it should be: the log says "no host pipeline library: pipelines are not kept" on every start, so nothing is persisted and each launch recompiles hundreds of psos (the 10 s gaps above, LEONIDA_PIPELINE_WAIT_MS=10000). that's the empty-slice CreatePipelineLibrary call vkd3d-proton rejects with E_INVALIDARG, which #2654 fixes. merging #2654 would make linux gate runs a lot more meaningful AI-assisted: yes (claude). runs played by me
fiestorra commented 2026-12-02 23:02:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:02:02Z.


VERIFY-3238 — Windows nativo (MSVC): el camino de siempre sigue exportando; la rama nueva no se puede construir aquí

Own commit 7fa7043eb — apps/leonida/build.rs (+26/−5), tests/agility.rs (1 line), docs/linux.md
Merge base recent

Ran

cargo test -p leonida --test agility      2 passed; 0 failed

And that test is the right one for this change: the_exe_exports_the_agility_sdk_symbols reads the built executable's exports for D3D12SDKVersion and D3D12SDKPath, and d3d12_dll_is_delay_loaded reads the import table — precisely the four link arguments the build.rs change rearranges. Both pass, so the MSVC path the refactor touches still produces the same exports and delay-load.

What the change is: the CARGO_CFG_TARGET_ENV == "msvc" check becomes a match over target env and ABI, so x86_64-pc-windows-gnullvm (llvm-mingw's clang and lld) gets the same exports through lld's MinGW driver — -Xlinker to keep the comma that -Wl, would split on, and mingw-w64's own runtime for the delay-load helper — while GNU ld (x86_64-pc-windows-gnu) gets neither, which the comment says outright. docs/linux.md gains the three lines that tell a reader to use it.

What I could not test — and it is the whole new branch: there is no x86_64-pc-windows-gnullvm toolchain on this machine, so the code path the pull request adds is never compiled here. What I verified is that the refactor did not break the MSVC path, which is the regression risk of turning an if into a match; the new path itself needs a gnullvm build on the runner that has it.

One note for whoever reviews the build logic: -Xlinker with a space-separated argument is the correct way to hand lld a comma inside one switch, and the comment states it — that is the kind of detail that is invisible until a link line is read, and it is documented here.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361478020 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3238#issuecomment-7361478020). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:02:02Z. --- ## VERIFY-3238 — Windows nativo (MSVC): el camino de siempre sigue exportando; **la rama nueva no se puede construir aquí** | | | |---|---| | Own commit | `7fa7043eb` — `apps/leonida/build.rs` (+26/−5), `tests/agility.rs` (1 line), `docs/linux.md` | | Merge base | recent | **Ran** ``` cargo test -p leonida --test agility 2 passed; 0 failed ``` **And that test is the right one for this change**: `the_exe_exports_the_agility_sdk_symbols` reads the built executable's exports for **`D3D12SDKVersion` and `D3D12SDKPath`**, and `d3d12_dll_is_delay_loaded` reads the import table — **precisely the four link arguments the `build.rs` change rearranges**. Both pass, so **the MSVC path the refactor touches still produces the same exports and delay-load**. **What the change is**: the `CARGO_CFG_TARGET_ENV == "msvc"` check becomes a `match` over **target env and ABI**, so `x86_64-pc-windows-gnullvm` (llvm-mingw's clang and lld) gets the same exports **through lld's MinGW driver** — `-Xlinker` to keep the comma that `-Wl,` would split on, and mingw-w64's own runtime for the delay-load helper — while **GNU ld (`x86_64-pc-windows-gnu`) gets neither**, which the comment says outright. `docs/linux.md` gains the three lines that tell a reader to use it. **What I could not test — and it is the whole new branch**: **there is no `x86_64-pc-windows-gnullvm` toolchain on this machine**, so the code path the pull request adds is **never compiled here**. What I verified is that **the refactor did not break the MSVC path**, which is the regression risk of turning an `if` into a `match`; **the new path itself needs a gnullvm build on the runner that has it.** **One note for whoever reviews the build logic**: `-Xlinker` with a space-separated argument is the correct way to hand `lld` a comma inside one switch, and the comment states it — that is the kind of detail that is invisible until a link line is read, and it is documented here. Written with an AI assistant.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3238:upstream-pr/3238'
git switch 'upstream-pr/3238'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3238'
git switch 'upstream-pr/3238'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3238'
git switch 'upstream-pr/3238'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3238'
git switch 'main'
git merge --squash 'upstream-pr/3238'
git switch 'main'
git merge --ff-only 'upstream-pr/3238'
git switch 'main'
git merge 'upstream-pr/3238'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
ProjectLeonida/mandy!3238
No description provided.