Skip to content

d3d12: build and test the workspace natively on Linux - #3176

Open
kett1m wants to merge 4 commits into
ProjectLeonida:mainfrom
kett1m:linux-d3d12-workspace
Open

kett1m wants to merge 4 commits into
ProjectLeonida:mainfrom
kett1m:linux-d3d12-workspace

Conversation

@kett1m

@kett1m kett1m commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-RUST-WORKSPACE-LINUX (#2570 (comment))

Depends on: (none)

Fixes: (closes none)

What and why

The d3d12/ Rust workspace (leonida.exe and its crates) was Windows-only, and the only CI workflow ran on windows-latest (with a note that Linux follows #2577). Finish the migration of the inline #[cfg(windows)] gates so the workspace builds and tests natively on Linux, alongside Windows, without changing Windows behavior:

  • Windows-only modules and functions stay gated (host accessors, dialogs and other display-dependent pieces, the line/behind machinery); portable shims return honest no-ops (a fallback or None/0, not a failure) instead of failing.
  • The title's own paths (C:\..., \\server\share\file.dll) are matched by file name on any host, so GetModuleHandleW / GetModuleFileNameW / image_named work off Windows: the file name comes from Path::file_name on the host's own paths (exact) and from a separator split only for the title's own verbatim Windows-style paths, which a Linux host does not understand. The file name itself comes from Path::file_name on the host's own paths (exact, including trailing separators and non-UTF-8 components) and from a separator split only for the title's own verbatim Windows-style paths, which a Linux host does not understand.
  • Nine own-binary PE tests are Windows-only (the test binary is a PE only there); the other tests keep their portable coverage. Ten added portable tests (six pin the path behavior — verbatim, UNC, .. segment, relative-host-path made absolute, trailing separators, non-UTF-8 file names — and four the clwb coverage).
  • leonida's validator and host-pipeline extras are skipped off Windows (reported as skipped, not silently ignored); the portability-checked commands (inspect, census, lib-exports, shader-info, translate, shaders, config) run; run says it needs Windows and stops.
  • CI: a d3d12-linux job mirrors the Windows one (build, shipped build, tests, policy, clippy; the replay test is skipped there — its test is Windows-gated). docs/linux.md: the workspace row and the Linux build commands, and the building-natively-vs-running-the-title distinction.

One behavior-affecting change, and only on hosts that do not understand the title's own paths: stored_path keeps the title's Windows-style absolute paths (drive letters and UNC) verbatim — the title's own paths, e.g. C:\title\..\game.exe, are recorded exactly as the title names them — while on the title's own host the standard normalization applies exactly as before. Relative host paths are made absolute either way. Both pinned by tests.

Note on behavior: translate/shaders on Linux report every shader as "no host" (the validator and host pipeline extras are skipped) — honest, but the cache is not used.

Tested

  • cargo test --workspace --exclude xtask --locked — all suites green (leonida-hle 159, ...)
  • cargo test -p leonida-gpu --features diagnostics --test replay --locked — 0 tests on Linux (its test is Windows-gated)
  • cargo build -p leonida --features diagnostics,mimalloc --locked — builds as shipped
  • cargo test -p xtask --locked — the asset-policy test fails with the same 3 violations as on Windows (host.rs / lower.rs over the 640 KiB limit, amplify_dxil.rs hex-literal count); reported, not blocking
  • CLI smoke: leonida config prints, leonida run some.exe reports "running titles requires Windows" and exits, leonida inspect --help works, warm/replay are absent on Linux (as designed)
  • python3 -I scripts/check_no_game_data.py — no output (clean)
  • cargo test -p leonida-hle --lib — includes the new portable path tests (the non-UTF-8 test fails without the exact-name fix)
  • python -m unittest discover -s tests -p "test_docs_*.py" — 57 docs tests green

GPUs tested: n/a — no GPU or game data needed (the tests are GPU-independent and skip themselves when they need one)

AI-assisted: yes — Inkling 2 Mini (authoring agent), with a separate read-only Claude Opus 5.5 review

Reported, unchanged from Windows (report-only in CI): xtask asset-policy test; cargo clippy findings; ~84 dead-code warnings on Linux in windows-only-caller chains (descriptive, not blocking)

Checklist

  • Based on current main and merges cleanly (branch is a single commit from current main)
  • One topic; follow-up work goes in a new pull request
  • No game data, keys or decryption (CONTRIBUTING.md)
  • A new translator rule is in the contract table of docs/design.md with how it was confirmed — n/a, this change adds no translator rule

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI is green on both d3d12 jobs (ubuntu 3m17s, windows 8m10s), and the Linux log confirms the new portable tests actually run and pass (3 path + 4 clwb = 7; the body says eight). The gate is real: d3d12-linux runs cargo test --workspace --exclude xtask without continue-on-error, and run still bails cleanly on Linux. The Windows-only parts becoming honest no-ops (line disabled, direct ValueWait, gated host heaps/view_format/allocator hooks) is the right shape. The stored_path guard is mutation-covered (left: "C:\\game.exe", right: "C:\\title\\..\\game.exe").

One docs distinction to fold into the Linux rewrite: docs/linux.md:163-165 says "what does build natively is everything that doesn't touch Win32", which now reads against a workspace that builds by stubbing Win32 but cannot run titles. Say "builds and tests" vs "runs the title" explicitly.

Heads-up: #2878 edits the same leonida-pe/src/image.rs gated test block, so one of the two will need a rebase. This PR also adds a row/commands to docs/linux.md and a job to d3d12.yml, which the planned docs rewrite and any CI PR will overlap.

Minor: image_named now uses to_string_lossy().rsplit(['\\','/']), which changes non-UTF-8 and trailing-separator behaviour versus Path::file_name; a fallback to the Path API would keep it exact.

No blocking code issues found; merge-tree is clean (d7c08a16).

@merzleckeier merzleckeier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tested 43c4f3e01 merged with main 5b1fff821 on x86_64 CachyOS (Rust 1.98.1). cargo build -p leonida --features diagnostics,mimalloc --locked built successfully. With RUST_LOG=info, cargo test --workspace --exclude xtask --locked --no-fail-fast had 758 passes and 11 ignored. No game files or GPU were needed, and I did not repeat the Windows job.

One local-test caveat explains the discrepancy with the green fork run. RUST_LOG=warn cargo test -p leonida --test settings_line --locked fails because the inherited filter hides the settings INFO event. The same test passes with RUST_LOG=info. apps/leonida/tests/settings_line.rs is unchanged by this PR. Setting a known filter on the test subprocess would make the existing assertion independent of the reviewer's shell.

AI-assisted: OpenAI Codex.

kett1m added a commit to kett1m/mandy-linux that referenced this pull request Dec 2, 2026
…e-title

Review on ProjectLeonida#3176, two items:

- image_named used to_string_lossy + split, which changed behaviour for a
  non-UTF-8 file name and for a trailing separator. image_name uses
  Path::file_name for host paths (exact) and falls back to the string
  split only for the title's own verbatim Windows-style paths (which a
  Linux host cannot understand); a trailing separator keeps the file name
  either way. Regression tests: a trailing separator (host and Windows-
  style) and a non-UTF-8 file name.
- docs/linux.md: 'builds and tests' vs 'runs the title' — the workspace
  builds and tests natively (Win32 parts gated or stubbed) but leonida.exe
  does not run the title there; it is a Windows program run under Wine or
  Proton. The 'Why there is no native Linux gta6rt' section and the
  workspace row both say so.

Tested: cargo test -p leonida-hle --lib (13 runtime tests; the non-UTF-8
test fails without the fix), cargo test --workspace --exclude xtask
(31 suites green), docs tests (57), check_no_game_data clean.

No game data, keys or decryption.
@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — both items folded in, 715c8ee.

  1. docs/linux.md: the build vs runs distinction now stated in the Why there is no native Linux gta6rt section and in the workspace row: the workspace builds and tests natively (Win32 parts gated or stubbed), but leonida.exe does not run the title there — it is a Windows program under Wine or Proton, like gta6rt (the native binary is not the one a Linux player plays). The earlier row told the same thing only through the CI link.

  2. image_named exactness: image_name() now uses Path::file_name() — exact for the host's own paths (trailing separators and non-UTF-8 components) — and falls back to the string split only for the title's own verbatim Windows-style paths (which a Linux host cannot understand). Regression tests: trailing separators (host and Windows-style) and a non-UTF-8 file name; the non-UTF-8 test fails without the exact-name base (red-green verified). Windows path with trailing separator: C:\title\ → title.

Tested: cargo test -p leonida-hle --lib (13 runtime tests), cargo test --workspace --exclude xtask (31 suites green), docs tests (57), check_no_game_data.py clean, fmt clean on the changed block.

Noted: #2878 also edits the same leonida-pe/src/image.rs gated test block — whichever of the two PRs lands second needs a rebase. Left as-is deliberately (no duplicate gates).

Also: the body now pins the actual new-test count (10: six path + four clwb, as the Linux log shows) instead of "eight".

@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Fork CI green on 715c8ee — both jobs (d3d12 windows-latest, d3d12 ubuntu-latest), D3D12 runtime / workflow_dispatch 46934506671. Review items addressed and merged into the branch at 715c8ee; body updated to the actual test counts.

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Verified #3176 natively on Linux: merged onto current main the workspace builds and all its tests pass (761 passed, 0 failed, 11 ignored); main alone does not build on Linux. Two points to settle before merge: a small Windows behaviour change in stored_path, and the model disclosure.

Head 715c8eed2f
Merged onto main 45dc41f95c (clean merge tree b6d6d1f5cc; merge base 3c106eb2ff, 21 commits behind), exported whole (with mods/, which leonida-lua's tests read)
Machine Linux x86_64, rustc 1.98.1 (from d3d12/rust-toolchain.toml), 4 cores, no GPU, no game files

Ran (from d3d12/)

merge:  cargo test --workspace --exclude xtask --locked --no-run    exit 0 (116 warnings, all existing kinds)
merge:  cargo test --workspace --exclude xtask --locked --no-fail-fast
        761 passed, 0 failed, 11 ignored                             exit 0
main:   cargo test --workspace --exclude xtask --locked --no-run    exit 101
        error: could not compile `leonida-gpu` (lib) due to 6 previous errors
        (E0433 cannot find `host` / `behind` / `toggled` / `texture` in `crate`; E0425 `line_on`, `host_resource`)
merge:  python -I tools/d3d12_switches.py --check d3d12/docs/switches.md   exit 0

That is the red/green for the PR's claim: red on main, green with the change, same toolchain and target directory. A first run from an export of d3d12/ alone had 6 leonida-lua failures (NotFound at crates/leonida-lua/src/tests.rs:1166/1267); they come from the missing mods/ folder in that export, not from the PR, and passed once the whole tree was exported.

Review (Windows side not built here)

  1. d3d12/crates/leonida-hle/src/runtime.rs stored_path: on Windows, Path::is_absolute() is true for C:\title\..\game.exe, so it is now stored verbatim where std::path::absolute (GetFullPathNameW) used to give C:\game.exe. Drive-relative C:foo and root-relative \foo are also kept as they are instead of being completed with the current drive or directory. The title reads these back through GetModuleFileNameW. The description names the change, but it conflicts with "without changing Windows behavior". Either keep std::path::absolute on Windows (#[cfg(windows)]) and keep the verbatim rule for non-Windows hosts, or say in the PR why the title is better served by the unnormalized form.
  2. The new d3d12-linux CI job mirrors the Windows one (build, shipped build, tests as the gate, policy and clippy as reports) and uses pinned action SHAs. Good: it will keep the Linux build from regressing.
  3. Process: the description names "Inkling 2 Mini" as the authoring model. CONTRIBUTING.md (AI-assisted contributions) lists Claude Opus or Fable, GPT Sol or Astra, Gemini Neon or Carbon for new code, and does not list Inkling. The reviewer model is given only as "default model". A maintainer should decide whether that is acceptable for a 26-file change.
  4. With 26 files of #[cfg(windows)] gates, this will touch many open d3d12 pull requests. The sooner it lands, the less rebasing.

Verdict: defects (minor). The Linux build and tests are confirmed. Item 1 needs a decision or a cfg(windows) guard, and item 3 needs a maintainer's call; no check runs are recorded on the head yet.

AI-assisted: Claude Opus 5.5 (Claude Code), verification only.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

kett1m added a commit to kett1m/mandy-linux that referenced this pull request Dec 2, 2026
…#3176 review)

MoonEyes' verification review flagged that stored_path kept Windows-style
absolute paths verbatim everywhere, so on Windows C:\title\..\game.exe
used to be normalized to C:\game.exe by std::path::absolute and now is
not - an undocumented behaviour change on the title's own host.

stored_path now keeps the original std::path::absolute normalization on
Windows (#[cfg(windows)]) and keeps unrecognized Windows-style paths
verbatim only on hosts that do not understand them (Linux). The verbatim
test pins both forms; the `..` segment now expects the normalized form
on Windows and the verbatim form off Windows. Windows behavior is
unchanged by construction (the exact original expression, gated).

Tested: cargo test -p leonida-hle (13 runtime tests; the windows-style
..` test passes on the Windows binary under the system prefix with the
cross-built PE: 12/12 runtime tests green), cargo test --workspace
--exclude xtask (31 suites green), check_no_game_data clean.

No game data, keys or decryption.
@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

MoonEyes' review, item 1 (stored_path Windows behaviour): fixed in ae0075d. stored_path now keeps the original std::path::absolute normalization on Windows (#[cfg(windows)]) and keeps unrecognized Windows-style paths verbatim only on hosts that do not understand them (Linux). Windows behavior is unchanged by construction. The verbatim/normalized test pins both forms (.. segment: C:\game.exe on Windows, C:\title\..\game.exe off Windows).

Verified locally, natively (Linux, tests green) and on the cross-built Windows PE under the system Wine prefix (runtime::tests: 12/12 green there, including the Windows-form expectation; the 3 failing full-suite tests — net, xgamesave, xmem — are unrelated modules and Wine-environment failures, not this change). cargo test --workspace --exclude xtask: 31 suites green.

Item 3 (model disclosure) is the maintainer's call, not a code fix — the PR names the actual model used (Inkling 2 Mini for the authoring agent) as CONTRIBUTING.md asks for honest disclosure; CONTRIBUTING.md's model list is a naming convention, so I left it and do not unilaterally promote it past what the repo lists. Item 2 (CI job) is as-is; item 4 (future rebasing) noted.

@Tauwni

Tauwni commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

macOS check of ae0075d: on an Apple M3 (arm64), the workspace builds and its tests pass once one test is kept to x86_64.

MEASURED on an Apple M3, macOS 26.5.1, with the pinned Rust 1.98.1 (aarch64-apple-darwin):

Step At ae0075d9a With the 3-line change below
cargo build --workspace --all-targets --locked fails: leonida-loader (lib test), unrecognized instruction mnemonic at crash.rs:857 (pushfq, pop) passes, no warning in crash.rs
cargo build -p leonida --features diagnostics,mimalloc --locked not run passes
cargo test --workspace --exclude xtask --locked, 3 runs does not build 760 passed, 0 failed, 11 ignored, each run

READ IN CODE: this PR adds copies of native_compare (x86 asm!: cmp, pushfq, pop) and compare_sets_flags_like_the_cpu to portable_tests, which is #[cfg(test)] only. On main they existed only in mod tests, in a crate that only builds on Windows. So any non-x86_64 host fails to build the tests, Linux on arm64 included. The ubuntu-latest job is x86_64, so CI won't show it. Not measured on Linux arm64.

The change I used, in d3d12/crates/leonida-loader/src/crash.rs (the third line keeps CMP_FLAGS from becoming an unused constant on arm64):

#[cfg(any(windows, all(test, target_arch = "x86_64")))]
pub(crate) const CMP_FLAGS: u32 = 0x8d5;
    /// The flags a native `cmp a, b` leaves.
    #[cfg(target_arch = "x86_64")]
    fn native_compare(a: u64, b: u64) -> u32 {
    #[test]
    #[cfg(target_arch = "x86_64")]
    fn compare_sets_flags_like_the_cpu() {

The other portable_tests cases (clwb_loops_decode_the_loop, clwb_lengths_decode, clwb_loop_end_skips_past_a_finished_loop) are plain byte decoding and pass on arm64.

Since leonida-gpu builds on macOS with this PR, the d3d12.yml comment "macOS is not covered yet: leonida-gpu does not build there" looks out of date. That is only about building and the no-GPU tests; I am not proposing a macOS CI job.

Checked by a separate reviewer agent on the same machine (logs and code re-read); not by a second human yet.
AI-assisted: yes (Claude Code)

@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Fork CI green on ae0075d — both jobs (d3d12 windows-latest, d3d12 ubuntu-latest), D3D12 runtime / workflow_dispatch 46942357491.

@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Sync: merged upstream/main (b417632) into the branch (5f92e05) so the PR carries current main. No conflicts (upstream touched none of this PR's files); full workspace suite re-run on the merge — 31 suites green; the diag exe rebuilt on the merge commit. Fork main stayed local per the never-push-to-main rule (it fast-forwarded locally to b417632); push it when you want.

@lixonik

lixonik commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Native Windows 10 regression check for PR #3176 (5f92e0508) merged cleanly onto main (f1a559851, Rust 1.98.1):

  • Clean-room check: python -I scripts/check_no_game_data.py PASS.
  • Workspace check: cargo check --workspace --all-targets --locked -- PASS (zero errors on Windows).
  • Native Windows tests:
    • cargo test -p leonida --locked: 43 unit + 5 integration (agility, census, settings_line) passed, 0 failed.
    • cargo test -p leonida-lua --lib --locked: 44 passed, 0 failed.

Verdict: PASS (native Windows build/test regression check clean; Linux build covered by CI).

AI-assisted: yes (Antigravity).

@kett1m
kett1m force-pushed the linux-d3d12-workspace branch from 5f92e05 to a055aea Compare December 2, 2026 20:54
@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Re-authored the merge commit: 5f92e05 was committed by a plain git merge and picked up the ambient Ralph <ralph@local> from the environment's git config instead of the repo's kett1m identity (the other three commits were made with explicit -c user.name=). Amended and force-pushed as a055aea: same merge content, now kett1m <benho0@proton.me>, both as author and committer.

@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Redone: a read-only review of the full diff was run with Claude Opus 5.5 (separate reviewer agent, read-only audit of the final branch contents — stored_path normalization, the image_named exactness fix, docs distinction, and the merge with upstream/main). No new findings to block the merge.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Dec 2, 2026
@MoonEyes

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

RUN (independent run on Windows, head a055aea74e26397440c77d0021b3864f0ce7274c, merged into main 8877be372bac025153488fc56c2b6122f98ec44d with git merge --no-ff)

That merge was clean, no conflict (merge commit 384233bd1, local only). The results below were measured on that merge. main has moved since (see "Conflict with current main"), so they do not carry over to a merge with current main.

Green

  • cargo test -p leonida-gpu --release --locked --lib: 703 passed, 0 failed, 59 ignored.
  • cargo test -p leonida-gpu --release --locked --features diagnostics --lib: 784 passed, 0 failed, 59 ignored. Run because switch.rs (toggled! / asked!) now gates the ab path on all(windows, feature = "diagnostics").
  • cargo test -p leonida-hle --release --locked --lib (where the new tests live): 253 passed, 0 failed, 2 ignored. In the runtime.rs test module there are 9 tests, 8 of which run on Windows, 5 of them the new path tests (the non-UTF-8 one is unix-only).
  • The PR touches no Python test.

Red

The new tests are portable path tests. On Windows, Path::file_name already understands C:\..., so main's version of image_named passes most of them: they are not red on Windows by construction (their value is on Linux, which I did not run). So I mutated the new code in runtime.rs (one at a time, restored after each), running the leonida-hle lib tests of that module:

  • M1, image_named back to p.file_name(): survives (all 8 Windows-run tests of the module pass).
  • M2, image_name takes the first split segment instead of the last non-empty one: survives. The Windows-style trailing-separator test never reaches that branch on Windows.
  • M3, the exact Path::file_name branch of image_name disabled: survives.
  • M4, the Windows branch of stored_path returns the path unchanged: killed by a_relative_host_path_is_made_absolute and a_windows_path_is_verbatim_not_normalized.

Numbering corrected: an earlier draft skipped M2 and quoted "10/10", which matches no test set in the diff; that count is withdrawn.

So on Windows, only the stored_path Windows behaviour is pinned (1 of 4 mutations killed). The image_name split logic is covered only by the Linux CI job.

Review

  • leonida-gpu diff, Windows side: mostly cfg gating and let _ = for unused variables. Also: toggled! / asked! in switch.rs lose #[cfg(windows)] and are now exported on every platform (their ab path is all(windows, diagnostics)). queue.rs gains a non-Windows behind stub module (on() returns false, alias_later runs the work inline) and a non-Windows behind_line no-op; before_sync, line_on, queued etc. lose #[cfg(windows)] but still call the same behind on Windows. stored_path keeps std::path::absolute on Windows (fixed after the review by MoonEyes).
  • LEONIDA_WAIT_ASK (list.rs, ValueWait): on Windows, with LEONIDA_WAIT_ASK=1 the wait returns true when the address is not committed (crate::texture::committed). Off Windows, asked is just the env flag, so with LEONIDA_WAIT_ASK=1 the wait always returns true without reading memory. With the variable unset the normal path runs. Nothing changes on Windows.
  • ValueWait read: on Windows the value is read through crate::host::read_into, a guarded read that makes the wait return true when it fails. Off Windows it becomes an unguarded unsafe copy_nonoverlapping. The risk is the lost fault-safe read: a bad address faults instead of returning true. No host runs the title off Windows, so it is not exercised; this is by reading the diff, not measured.
  • New CI job: d3d12-linux (.github/workflows/d3d12.yml, +52 lines, ubuntu-latest), the main deliverable: build, build as shipped (diagnostics, mimalloc), cargo test --workspace --exclude xtask --locked as the gate, asset policy and clippy as reports.
  • Default-off switches: no new switch, so docs/switches.md does not need regenerating.
  • Claim: D3D12-RUST-WORKSPACE-LINUX, in the coordination issue 2570 comment linked in the PR body.
  • CI on this head: all listed checks green (d3d12 (windows-latest), d3d12 (ubuntu-latest), no-game-data, check, semantic-tests and the others).
  • Reviewers, measured:
    • MoonEyes (Linux x86_64, 715c8eed2f merged on a then-current main): workspace builds and 761 passed, 0 failed, 11 ignored; main alone fails to build leonida-gpu (6 errors). Raised the stored_path Windows change and the model disclosure; the author reports stored_path fixed in ae0075d and the body now carries a model disclosure.
    • KelboLive: no blocking code issue; asked for the docs/linux.md build-vs-run wording (author reports done in 715c8ee) and warned that d3d12-pe: use synthetic PE32+ fixtures in portable image tests (D3D12-PE-PORTABLE-IMAGE-TESTS) #2878 edits the same leonida-pe/src/image.rs gated test block, so one of the two needs a rebase.
    • merzleckeier (CachyOS, 43c4f3e01): 758 passed, 11 ignored; the existing settings_line test fails under an inherited RUST_LOG=warn, a test this PR leaves unchanged.
    • Tauwni (Apple M3 arm64, ae0075d9a): BLOCKER, measured. cargo build --workspace --all-targets --locked fails in leonida-loader (lib test): unrecognized instruction mnemonic at crash.rs:857 (pushfq, pop), because the PR adds native_compare (x86 asm!) and compare_sets_flags_like_the_cpu to portable_tests without an x86_64 gate. With a 3-line target_arch = "x86_64" gate the workspace builds and 760 passed. I re-read the PR head a055aea7: native_compare and compare_sets_flags_like_the_cpu are still ungated in #[cfg(test)] mod portable_tests (crash.rs lines 853 and 873; the copies at 1223 and 1234 are in the Windows-only mod tests and play no part in the arm64 failure) and CMP_FLAGS is still #[cfg(any(windows, test))]. The blocker is unresolved on this head. I did not run it on arm64 myself.
    • lixonik (Windows 10, 5f92e0508): check_no_game_data.py and cargo check --workspace --all-targets --locked pass.
  • Overlap: d3d12-pe: use synthetic PE32+ fixtures in portable image tests (D3D12-PE-PORTABLE-IMAGE-TESTS) #2878 (PE portable image tests) is now merged; see the next section.
  • In-game run: none posted on this head. The diff changes Windows runtime code in list.rs (execute_indirect, ValueWait) and queue.rs. By reading, these are cfg-neutral on Windows, but under the render-PR rule (a 300 s in-game run without device loss before merge) the run is required and is missing.

Conflict with current main

git merge-tree --write-tree origin/main refs/rgr/3176 (read only; main f3865cae, PR head unchanged) reports CONFLICT (content): Merge conflict in d3d12/crates/leonida-pe/src/image.rs. #2878 merged into main and edits the same gated test block, as KelboLive foresaw. GitHub shows the PR as DIRTY (mergeable = CONFLICTING). I did not build or test that merge, and no cargo was run on it.

Not covered

  • Native Linux build and tests (the PR's actual target), macOS and arm64 (Tauwni's result above is a reviewer's, not mine).
  • A rendering run in the game (no game data used).
  • Windows tests of leonida-loader and other crates, the replay test, and cargo clippy.
  • Any test of the merge with current main.

Verdict

PARTIAL, not mergeable. Windows is green on the earlier merge and the gating looks neutral for Windows, but three points are open: (1) the PR conflicts with current main in leonida-pe/src/image.rs, so it needs a rebase and a new run; (2) Tauwni's measured arm64 build failure in crash.rs is not fixed on this head; (3) the required 300 s in-game run on this head is missing. Also, the Windows run pins only 1 of 4 mutations; the rest rests on the Linux CI job.

AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.

Finish the porting migration with #[cfg(windows)] gates so the d3d12
workspace builds and tests natively on Linux, alongside Windows:

- Windows-only modules and functions stay gated; portable shims return
  honest no-ops (no host GPU, no thread, no dialogs) instead of failing.
- The title's own paths (C:\..., \\server\share\file.dll) are kept
  verbatim and matched by file name on any host, so GetModuleHandleW /
  GetModuleFileNameW and image_named work off Windows (the recorded path is
  absolute by the title's own rules; the host's normalization is not applied).
- Nine own-binary PE tests are Windows-only (the test binary is a PE only
  there); crates that read this test binary keep the other tests portable.
- The CLI's validator/host-pipeline extras are skipped off Windows; the
  portability-checked commands run.

CI: a d3d12-linux job mirrors the Windows one (build, tests, policy, clippy);
the replay test is skipped there (tests/replay.rs is Windows-gated).
docs/linux.md: the workspace row and the Linux build commands.

Verified on Linux (x86-64): cargo test --workspace --exclude xtask --locked
(all suites green; the xtask asset-policy test fails as on Windows), build as
shipped (diagnostics, mimalloc), and the CLI config/run/--help smoke tests.
No game data, keys or decryption.
…e-title

Review on ProjectLeonida#3176, two items:

- image_named used to_string_lossy + split, which changed behaviour for a
  non-UTF-8 file name and for a trailing separator. image_name uses
  Path::file_name for host paths (exact) and falls back to the string
  split only for the title's own verbatim Windows-style paths (which a
  Linux host cannot understand); a trailing separator keeps the file name
  either way. Regression tests: a trailing separator (host and Windows-
  style) and a non-UTF-8 file name.
- docs/linux.md: 'builds and tests' vs 'runs the title' — the workspace
  builds and tests natively (Win32 parts gated or stubbed) but leonida.exe
  does not run the title there; it is a Windows program run under Wine or
  Proton. The 'Why there is no native Linux gta6rt' section and the
  workspace row both say so.

Tested: cargo test -p leonida-hle --lib (13 runtime tests; the non-UTF-8
test fails without the fix), cargo test --workspace --exclude xtask
(31 suites green), docs tests (57), check_no_game_data clean.

No game data, keys or decryption.
…#3176 review)

MoonEyes' verification review flagged that stored_path kept Windows-style
absolute paths verbatim everywhere, so on Windows C:\title\..\game.exe
used to be normalized to C:\game.exe by std::path::absolute and now is
not - an undocumented behaviour change on the title's own host.

stored_path now keeps the original std::path::absolute normalization on
Windows (#[cfg(windows)]) and keeps unrecognized Windows-style paths
verbatim only on hosts that do not understand them (Linux). The verbatim
test pins both forms; the `..` segment now expects the normalized form
on Windows and the verbatim form off Windows. Windows behavior is
unchanged by construction (the exact original expression, gated).

Tested: cargo test -p leonida-hle (13 runtime tests; the windows-style
..` test passes on the Windows binary under the system prefix with the
cross-built PE: 12/12 runtime tests green), cargo test --workspace
--exclude xtask (31 suites green), check_no_game_data clean.

No game data, keys or decryption.
…e::new

Tauwni's arm64 blocker: native_compare's asm! (cmp/pushfq/pop) is x86-only,
so it and compare_sets_flags_like_the_cpu are gated to target_arch = x86_64.
The portable tests (clwb_loops_decode_the_loop, clwb_lengths_decode,
clwb_loop_end_skips_past_a_finished_loop) stay portable.

Also fix the leftover .unwrap() on Runtime::new in a_link_to_nothing_is_not_written_through
(upstream 057cc94 removed the unwrap at the other sites; this one was left
behind and the lib test target fails to compile with E0599).
@kett1m
kett1m force-pushed the linux-d3d12-workspace branch from a055aea to 4c31594 Compare December 2, 2026 21:52
@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Read-only re-review of the full diff (head 4c31594, rebased onto f3865ca) — Claude Opus 5.5, read-only audit.

Rebase / conflicts. The branch is now a linear replay of the 3 PR commits onto current main: e4a864e (native Linux build), 16b37fd (image_named exactness), ef785ae (stored_path Windows), plus a new fix commit 4c31594. The image.rs conflict with #2878 is resolved by taking upstream's portable version (synthetic_pe_image + cfg(windows) only on own_image and parses_own_test_binary); the branch's now-redundant gates are dropped. The redundant sync merge commit from the previous rebase is gone; 4 commits, all kett1m benho0@proton.me.

Fixes on this head

  • crash.rs portable_tests: native_compare + compare_sets_flags_like_the_cpu (lines 853/873) gated to target_arch = x86_64 (Tauwni's blocker — the x86 pushfq/pop asm!). The portable tests (clwb loops, clwb_lengths, clwb_loop_end) stay portable. Also gated the windows-only copy in mod tests.
  • tests.rs a_link_to_nothing_is_not_written_through: dropped the leftover .unwrap() on Runtime::new left by upstream 057cc94 (pre-existing on main, was failing E0599).

Read-only audit of the full diff (27 files): cfg-neutral on Windows; stored_path keeps std::path::absolute on Windows, verbatim elsewhere; image_name is Path::file_name exact for host paths (trailing separators, non-UTF-8 bytes), separator split only for the title's own verbatim paths; the 6 new path tests pass natively on x86-64 (all 4 clone-in-window-style cases included). The non-Windows behavior changes are the documented ones: validator/host-pipeline extras skipped (reported as skipped), ValueWait's read is now an unguarded copy_nonoverlapping off Windows (a bad address faults instead of returning true — not exercised off Windows, consistent with the note), queue's behind_line is a no-op off Windows. docs/linux.md states the builds-vs-runs distinction and the new CI job.

Not verified here: the Windows run on this head (fork CI in progress, run 46978985860), the arm64 build (Tauwni's fix is cfg-gating, reviewed but not run on arm64), the in-game run (maintainer's 300 s rule — none posted on this head). Full workspace suite is green on x86-64 Linux (31 suites, 0 failed).

AI-assisted: yes — Inkling 2 Mini (authoring/executor), separate read-only Claude Opus 5.5 review.

@MoonEyes

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

RUN (independent run on Windows, head 4c31594b5a746358dc713b847bfdb21525c22c53, merged into main f3865cae87c963952067743a2684a9c2c3aaea5b with git merge --no-ff)

The head is the one the author named (gh pr view reports 4c31594). The merge was clean, no conflict (merge commit 7b9b51a2a, local only, nothing pushed). 27 files, +465/-34 against main.

Green

  • cargo test --workspace --exclude xtask --locked in d3d12/ (Windows 11, x86_64-pc-windows-msvc, debug profile): 32 test binaries (doctests included), 1735 passed, 0 failed, 75 ignored. No build error. Wall time 22 min (shared target dir, cold).
  • In leonida-loader, both crash::portable_tests::compare_sets_flags_like_the_cpu and the Windows-only crash::tests::compare_sets_flags_like_the_cpu run and pass (x86_64 satisfies the gate), as do the 3 clwb tests of portable_tests.

Author's claims checked

  • x86_64 gate: confirmed by reading the diff. In crash.rs, native_compare (pushfq/pop asm!) and compare_sets_flags_like_the_cpu in mod portable_tests both carry #[cfg(target_arch = "x86_64")]; the clwb tests and clwb_loop_end stay ungated and portable. The copy in the Windows-only mod tests (now #[cfg(all(test, windows))]) got the same attribute on the test. This is the fix for Tauwni's arm64 blocker (unrecognized instruction mnemonic). I could not confirm it on arm64 myself (see Red).
  • image.rs resolved by taking main's version: confirmed. The whole PR diff on leonida-pe/src/image.rs is one deleted blank line; the gated test block is main's (the d3d12-pe: use synthetic PE32+ fixtures in portable image tests (D3D12-PE-PORTABLE-IMAGE-TESTS) #2878 version).
  • The .unwrap() fix: confirmed, and it is real. main (f3865cae8) has Runtime::new(fake.clone(), Config::default()).unwrap() at leonida-lua/src/tests.rs:1089, but Runtime::new returns Runtime, not a Result. The PR removes the .unwrap(). See Red.
  • Windows behaviour unchanged: I read the diff of every non-test file and every removed line.
    • leonida-gpu: list.rs (execute_indirect, ValueWait) keeps the Windows lines as they were, only moved behind #[cfg(windows)] / let _ = for non-Windows. On Windows the LEONIDA_WAIT_ASK test is still env flag && !committed(...), the read is still host::read_into. queue.rs and switch.rs: toggled! / asked! lose #[cfg(windows)] and the diagnostics path becomes all(windows, feature = "diagnostics"), so Windows picks the same branch as before.
    • leonida-hle: SetThreadPriority now goes through host::set_thread_priority, which on Windows is the same windows_sys call; the non-Windows stub returns 1.
    • leonida-loader: crash.rs is gated #[cfg(windows)] / any(windows, test), so Windows still has everything it had.
    • Nit, not blocking: in kernel.rs the doc comment "Our caller's callers, as module+rva." now sits above set_thread_priority instead of callers().
    • Net: by reading, Windows code paths are the same. That is not a measurement of the game.
  • CI (gh pr checks 3176): all pass: d3d12 (ubuntu-latest) 2m37s, d3d12 (windows-latest) 8m8s, check, semantic-tests, linux-python-and-viewer, no-game-data, jactionlint, change-scope.

Red

  • The .unwrap() fix, demonstrated: with leonida-lua/src/tests.rs put back to main's version, cargo test -p leonida-lua --lib --no-run --locked fails: error[E0599]: no method named 'unwrap' found for struct 'Runtime' at tests.rs:1089:64, could not compile leonida-lua (lib test). With the PR's version it builds and the suite is green (above). So main currently cannot build the lib tests of leonida-lua, on Windows too; the PR fixes that. (File restored after the check.)
  • The x86_64 gate: not demonstrated. rustup target list --installed shows only x86_64-pc-windows-msvc, so cargo check --target aarch64-pc-windows-msvc --tests is not possible here, and I did not install a target. On x86_64 Windows the gate is true, so removing it would not turn anything red; a Windows run cannot tell the gate from its absence. The red for the gate is Tauwni's measured arm64 failure on the earlier head; whoever has an arm64 or Linux aarch64 machine should run cargo build --workspace --all-targets --locked on this head.

Not covered

  • arm64 and native Linux/macOS builds and tests (the PR's target); only the CI d3d12 (ubuntu-latest) job and reviewers' runs speak for them.
  • An in-game run: no game data used, leonida.exe was not running during my builds, and I did not start it.
  • cargo clippy, the diagnostics-feature build, and a release-profile test run (I ran the default debug profile).
  • The 3176 CI claim "windows still running" from the author is outdated: Windows CI is now green.

Verdict

PARTIAL, leaning PASS for the code. Clean merge on current main, Windows workspace tests green (1735 passed, 0 failed), the three author claims I could check hold, CI green, and the PR also repairs a leonida-lua test build that is broken on main. Still open: (1) the x86_64 gate fix is unconfirmed on arm64 by me; (2) the in-game run on this head is still required before merge (300 s, no device loss), since the diff touches Windows runtime code in list.rs and queue.rs; (3) the PR changes .github/workflows/d3d12.yml, so a maintainer queues it.

AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Dec 2, 2026
@kett1m
kett1m force-pushed the linux-d3d12-workspace branch from 9e099ec to 4c31594 Compare December 2, 2026 22:52
@kett1m

kett1m commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Status on the current head (4c31594), updating the review above:

CI: green end to end — 46989376570 (d3d12 windows-latest + ubuntu-latest, both success). The "windows still running" note from earlier is stale.

Verified on this head

  • The rebase: linux-d3d12-workspace is a linear replay onto f3865ca (no merge commit). image.rs carries the one-line diff (deleting a blank line) against main's version; the gated test block is main's d3d12-pe: use synthetic PE32+ fixtures in portable image tests (D3D12-PE-PORTABLE-IMAGE-TESTS) #2878 block (own_image gated to Windows, synthetic_pe_image portable).
  • The x86_64 gate: native_compare and compare_sets_flags_like_the_cpu in mod portable_tests are both #[cfg(target_arch = "x86_64")]; clwb_loops_decode_the_loop, clwb_lengths_decode and clwb_loop_end stay ungated and portable. compare_sets_flags_like_the_cpu runs and passes on x86_64.
  • The .unwrap() fix: main's leonida-lua/src/tests.rs:1089 has the stale .unwrap() on Runtime::new (returns Runtime, not Result) — lib test target fails E0599 on main; this head fixes it (red/green demonstrated).
  • cfg-neutral Windows behavior, by reading: list.rs/queue.rs/switch.rs/translate.rs keep the Windows branches as they were; nothing removed or reordered.

Still open, honestly

  • arm64: the gate is proven by reading and by x86-64 green, but I could not run an aarch64 build on this box (no aarch64 cross toolchain or SDK headers — blake3 needs arm_neon.h, lua needs _popen, apple-darwin needs a cross clang). Tauwni's measured arm64 failure is the red the gate answers; a maintainer's arm64 run is the real confirmation.
  • In-game run: the game boots with this head's exe — loader works, images map, imports bound, frame 1 presented, HDR/display init — then crashes at the swap-chain init under Wine 11.22 staging (first-chance 0xc0000005, wined3d.dll+0x16e470, read 0xffffffffffffffff). Environment (Wine staging + NVIDIA + GPU saturated by the LLM, 22.8 GiB of 24), not cfg-neutral code.

Workflow: the two artifact-upload commits were deleted pending maintainer agreement on running artifacts with checksum in the repo; the branch is back to the original d3d12.yml (the ubuntu job). The Windows folder (PR-3176/) ships an exe built from this code and verified against its CI checksum in run 46987389043 (the deleted head's artifact; same code).

@kett1m
kett1m force-pushed the linux-d3d12-workspace branch from 03548f4 to 4c31594 Compare December 2, 2026 23:22
@MoonEyes

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

RUN (in game, batch of five pull requests), each head merged with git merge --no-ff onto main ef35d683e, in one build: #3176 4c31594b5, #2657 c16b0424e, #2807 e2572082c, #3230 97eefdee4, #3247 3e5887f65. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (47 samples) median 15.8, mean 16.2
Rendered fps, last 120 s median 15.0
Time under 5 fps in the world 1 %

For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches today. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. #3247 has since moved to 3dc6c58b3, which only merges main (81efe4566) into the head above: git diff 3e5887f65 3dc6c58b3 leaves d3d12/scripts/play-nvidia.ps1 and tests/test_win_launchers.py unchanged. If another of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures; -PrecompileUsed was used because main now precompiles every known pipeline by default (88,631 for a new executable, over an hour on this card). The default start was therefore not exercised, and the F1 SAVE AND RESTART path of #3247 was not exercised in game. An earlier attempt of this batch is not counted: the run script gave up waiting while that full precompile ran.

AI-assisted (Claude Code).

@fiestorra

Copy link
Copy Markdown
Contributor

VERIFY-3176 — Windows nativo: red then green en el decodificador del informe de cuelgue; y su parte de Lua ya está en main

Own commit 4c31594b5 — but the branch carries 27 files / +465: leonida-loader/src/crash.rs (+116, the work), leonida-lua/src/tests.rs (2), crash.rs gate, d3d12.yml

Ran at the head

cargo test -p leonida-loader crash     24 passed; 0 failed
  crash::portable_tests::clwb_lengths_decode ... ok
  crash::portable_tests::clwb_loops_decode_the_loop ... ok
  crash::portable_tests::clwb_loop_end_skips_past_a_finished_loop ... ok
  crash::portable_tests::compare_sets_flags_like_the_cpu ... ok

Negative control (synthetic): I changed the ModRM /reg field clwb_len requires (from /6 to /0), rebuilt and ran:

FAILED. 22 passed; 2 failed

It bites.

The good part, and it is the reason I am not just filing this one away: the CLWB-loop decoder is pure byte-slice work with no Windows state, and it is tested on every platform (portable_tests, gated cfg(any(windows, test))) — including a test that compares the flags against a real cmp executed by the CPU (native_compare, x86_64 only, skipped elsewhere). That is the strongest kind of test in this repository: the oracle is the hardware.

And the part that needs saying before it merges: the leonida-lua/src/tests.rs hunk — let mut rt = Runtime::new(...) without .unwrap() — is already on main (via #3244, a22fa26d6). It is the same one-line fix, so it will merge as a no-op at best; the description should drop it rather than carry a second copy that a future rebase has to reconcile.

What I could not test

  • A real cuelgue: the crash handler runs when the title dies; the tests are the decoder and the flag comparison, not the handler.
  • The rest of the 27 files: this branch is a stack, and I ran the crate its own commit names.

Written with an AI assistant.

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.

7 participants