Skip to content

hw_oracle: build the launcher with MSVC when there is no MinGW gcc - #1255

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Dom-in:hw-oracle-msvc
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Dom-in:hw-oracle-msvc

Conversation

@Dom-in

@Dom-in Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #1218 (comment) (new BUILD item, follow-up to FUZZ-23)

What and why

tools/hw_oracle/runner.py find_cc() accepted only MinGW gcc. So a Windows contributor with an AMD GPU and Visual Studio got hardware oracle unavailable: no MinGW gcc for hw_oracle.c, although Visual Studio is already required for the runtime stage. hw_oracle.c builds cleanly with cl /O1 (checked on the #1160 and #1202 heads; one C4996 warning for scanf).

  • Order:
    1. LEONIDA_HOST_CC (gcc, or now also cl.exe / clang-cl);
    2. gcc on PATH or in C:\msys64, unchanged and still first;
    3. on Windows, a cl on PATH (a Developer shell);
    4. otherwise the Visual Studio that vswhere finds, with the same -requires ...VC.Tools.x86.x64 query as scripts/build_runtime.ps1, through its vcvars64.bat.
  • vcvars path: the call goes through a small .cmd in the oracle's work folder. cmd.exe strips /c's outer quotes, and the VS path has spaces. The script puts the VS Installer folder on PATH first, because vcvars64.bat runs vswhere itself and otherwise prints "'vswhere.exe' is not recognized" (as scripts/build_llvm_mc.ps1 does).
  • cl details:
    • objects go to the work folder (/Fo), not the caller's cwd;
    • compile errors, which cl prints on stdout, reach the Unavailable message;
    • the temporary launcher name ends in .exe, so cl doesn't append a second one.
  • Docs: docs/shader_validation.md now says the runtime's Visual Studio is enough.

It merges cleanly with #1228, which touches Oracle.__init__ in the same file.

Tested

Windows 11 Pro 26300, VS 2022 Build Tools (MSVC 14.44), Python 3.13, AMD Radeon RX 9070 (gfx1201, driver 26.11.2), rocm-sdk-core==10.0.0 clang:

  • python -I tests/test_hw_oracle.py: OK. Two new tests cover:
    • the compiler choice: nothing found raises Unavailable naming Visual Studio, gcc stays first, then a Developer-shell cl, then vcvars, and both LEONIDA_HOST_CC forms;
    • the gcc, cl and vcvars commands, including the .cmd script's quoting of a path with a space.
  • End to end with no gcc and no cl on PATH, the cached launcher deleted first, and hw_oracle: run on RDNA4 (gfx12xx); an unknown architecture is unavailable, not a traceback #1228 merged in for gfx1201:
    • find_cc() returned ('vcvars', '...\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat');
    • runner.py built the launcher and printed hardware oracle ready: device=AMD Radeon RX 9070 arch=gfx1201;
    • salu_diff --oracle hw --programs 500 --seed 7: 275 pass, 0 mismatch, 225 skipped;
    • crosslane_fuzz --oracle hw --wave both --programs 200 --seed 21: 100/100 wave32, 100/100 wave64, 0 mismatch.
  • tests/test_crosslane_fuzz.py: OK. python -m compileall -q tools tests: OK.

Not tried: an MSYS2 machine (that path is unchanged), and clang-cl as LEONIDA_HOST_CC, which is only covered by the unit test.

AI-assisted (Claude Code).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

@bobcatchris

Copy link
Copy Markdown
Contributor

Independent CPU-side verification of f668c7dc on Windows 11 Build 26200, Python 3.12.10; no GPU run and no actual MSVC compile here:

  • python -I tests/test_hw_oracle.py -v: 11 tests OK, 1 skipped.
  • python -m pytest -q tests/test_hw_oracle.py: 11 passed, 3 skipped.
  • python -m compileall -q tools/hw_oracle/runner.py tests/test_hw_oracle.py: clean.
  • Negative control with this PR's test file copied into a detached main (e7584c52) worktree: 2 failed, 9 passed, 3 skipped. Both new cases fail there — find_cc() returns a bare path instead of (kind, path), and runner.build_command() does not exist. So the behaviour is pinned.

Static review of the changed logic also checks out: gcc keeps priority, cl.exe/clang-cl get /Fe + /Fo into the oracle work folder, the vcvars path goes through a quoted .cmd with the VS Installer directory on PATH, and a failed compile surfaces stdout as well as stderr because cl writes errors there. One local-environment note: an existing missing-tools test invokes reg.exe, which this sandbox blocks; the test still passed through its Unavailable path and I did not retry it.

The author's RX 9070 end-to-end run remains their hardware evidence. From the CPU checks, this looks ready; CI approval seems to be the only listed gate.

find_cc() accepted only gcc, so a Windows contributor with Visual Studio (already required for the runtime)
got "hardware oracle unavailable: no MinGW gcc". hw_oracle.c builds cleanly with cl /O1.

- Order: LEONIDA_HOST_CC (gcc, or cl.exe / clang-cl), gcc on PATH or in C:\msys64, then on Windows a cl on
  PATH (Developer shell), then the Visual Studio vswhere finds, through its vcvars64.bat in a .cmd script.
- cl's objects go to the oracle's work folder, its errors (on stdout) reach the Unavailable message, and the
  temporary launcher name ends in .exe so cl doesn't append another one.
- Unit tests for the choice and the commands; docs/shader_validation.md says the runtime's VS is enough.

Checked end to end on an RX 9070 with no gcc and no cl on PATH: the launcher is built through vcvars64.bat,
salu_diff and crosslane_fuzz --oracle hw run with 0 mismatches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oVolkra

oVolkra commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 7249dcb on Windows 11 (no AMD GPU: NVIDIA RTX 3060, driver 617.14): pass for the compiler selection and the MSVC build; the oracle itself was not run.

Reviewed the diff (tools/hw_oracle/runner.py, tests/test_hw_oracle.py, docs/shader_validation.md): the compiler is chosen from LEONIDA_HOST_CC, gcc, a cl on PATH, then vswhere/vcvars64.bat; no network access, the vcvars script is written in the oracle's own work folder.

Base is main e7584c5 (0 commits behind, merges clean). Python 3.12.8, MSVC 14.44 (portable, so no vswhere: the vcvars branch is only covered by the unit test).

  • python -I tests/test_hw_oracle.py -v: 12 tests OK, 1 skipped. pytest tests/test_hw_oracle.py: 12 passed, 3 skipped (main: 10 passed, 3 skipped).
  • pytest tests -q --ignore=tests/semantic: 3124 passed, 30 skipped.
  • With gcc hidden from PATH, find_cc() returns ("msvc", <cl.exe>); build_command("msvc", ...) run from the work folder compiled hw_oracle.c with exit 0, wrote hw_oracle.exe (185,856 bytes) and hw_oracle.obj into that folder only, and the exe starts and prints its usage line.

Not run: the oracle on an AMD GPU, and the vcvars64.bat path on a real Visual Studio install.

AI-assisted: this check was run and written with Claude Code; the numbers above are its unedited output.

@ItsNotRexed
ItsNotRexed merged commit 1cfd638 into ItsNotRexed:main Nov 22, 2026
11 checks passed
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.

4 participants