host_cpu: move gta6rt's AVX preflight decision into a testable preflight() (OLD-9915) #1311

Open
github-bot wants to merge 1 commit from github-bot/gh-1311 into main AGit
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 21:41 UTC · original
ambroseautomation:carry/old-9915-host-cpu-preflight → main · +58 −5 · 4 files · 1 commits · open

Summary

Coordination item: OLD-9915 (carry-forward of old-pr/9915, preserving original author Sunkiller-qc).

Problem & Root Cause

gta6rt's AVX / host CPU preflight decision (checking missing ISA features, respecting dry_run, and formatting the refusal message) lived inline in runtime/src/main.cpp, so it could not be unit-tested directly against synthetic feature masks.

Implementation

  • Moves the preflight decision into host_cpu::preflight(...) in runtime/src/host_cpu.h and runtime/src/host_cpu.cpp, returning whether startup should proceed and any refusal message.
  • Updates runtime/src/main.cpp to call host_cpu::preflight(...).
  • Extends runtime/test/host_cpu_test.cpp to test preflight() directly across synthetic feature combinations and dry_run modes.

Tests Run

Environment: Windows 11 Pro 64-bit, Visual Studio 18 Community (cl.exe x64, /std:c++20 /W4 /WX).

  • cl /nologo /std:c++20 /EHsc /W4 /WX /Iruntime/src runtime/test/host_cpu_test.cpp runtime/src/host_cpu.cpp + host_cpu_test.exe — PASS (host: 0 missing feature(s), host_cpu_test: all passed)
  • .\scripts\build_runtime.ps1 -jobs 8 — PASS (runtime/build/gta6rt.exe built cleanly)
  • python -I scripts/check_no_game_data.py runtime/src/host_cpu.cpp runtime/src/host_cpu.h runtime/src/main.cpp runtime/test/host_cpu_test.cpp — PASS

Disclosure

AI-assisted: yes (carry-forward, rebase onto current main, and local MSVC build/test verification; original implementation by Sunkiller-qc).

**@⁠ambroseautomation** on GitHub · 2026-11-24 21:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1311) `ambroseautomation:carry/old-9915-host-cpu-preflight` → `main` · +58 −5 · 4 files · 1 commits · open ## Summary Coordination item: `OLD-9915` (carry-forward of `old-pr/9915`, preserving original author `Sunkiller-qc`). ### Problem & Root Cause `gta6rt`'s AVX / host CPU preflight decision (checking missing ISA features, respecting `dry_run`, and formatting the refusal message) lived inline in `runtime/src/main.cpp`, so it could not be unit-tested directly against synthetic feature masks. ### Implementation - Moves the preflight decision into `host_cpu::preflight(...)` in `runtime/src/host_cpu.h` and `runtime/src/host_cpu.cpp`, returning whether startup should proceed and any refusal message. - Updates `runtime/src/main.cpp` to call `host_cpu::preflight(...)`. - Extends `runtime/test/host_cpu_test.cpp` to test `preflight()` directly across synthetic feature combinations and `dry_run` modes. ## Tests Run Environment: Windows 11 Pro 64-bit, Visual Studio 18 Community (`cl.exe` x64, `/std:c++20 /W4 /WX`). - `cl /nologo /std:c++20 /EHsc /W4 /WX /Iruntime/src runtime/test/host_cpu_test.cpp runtime/src/host_cpu.cpp` + `host_cpu_test.exe` — PASS (`host: 0 missing feature(s)`, `host_cpu_test: all passed`) - `.\scripts\build_runtime.ps1 -jobs 8` — PASS (`runtime/build/gta6rt.exe` built cleanly) - `python -I scripts/check_no_game_data.py runtime/src/host_cpu.cpp runtime/src/host_cpu.h runtime/src/main.cpp runtime/test/host_cpu_test.cpp` — PASS ## Disclosure AI-assisted: yes (carry-forward, rebase onto current `main`, and local MSVC build/test verification; original implementation by Sunkiller-qc).
Follow-up to ad6e5d6. The check itself was tested, but the decision in
gta6rt's wmain (only --init/--run, LEONIDA_SKIP_CPU_CHECK=1, the message and
exit code 4) lived inline in main.cpp, where no test reaches it.

rt::host_cpu::preflight(starts_game, skipped, missing, error) now makes that
decision with an injectable feature source, and preflight(starts_game, error)
binds it to the running host. wmain prints the returned line and exits with
the returned code; behaviour is unchanged (--dry-run still reads neither the
CPU nor the environment). host_cpu_test covers --dry-run, the skip, a host
without AVX, an AVX host and a null error pointer.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:46:58 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-24 23:48 UTC · original

Verified on Windows host (AI-assisted review), commit 6bb811398, MSVC RelWithDebInfo Ninja build.

  • Rebuilt runtime incrementally (vcvars64 + Ninja, 22 targets) — clean, no new warnings.
  • runtime/build/host_cpu_test.exe: "host: 0 missing feature(s) / all passed" — the new preflight() cases all pass: --dry-run and LEONIDA_SKIP_CPU_CHECK=1 skip the CPU probe entirely (fake_missing call count stays 0), --init/--run on a missing-AVX fake host returns kExitCode with message() text, null error pointer tolerated.
  • main.cpp refactor is behaviour-preserving: init || run maps to starts_game, and check_skipped() is only consulted inside preflight when starts_game is true — same short-circuit as before, so --dry-run still doesn't read the environment.
  • No GPU-visible behaviour (startup CPU gate only); ctest host_cpu entry is the test binary itself, which I ran directly.

Verdict: LGTM.

**@⁠whoalin1** on GitHub · 2026-11-24 23:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1311#issuecomment-7147811548) Verified on Windows host (AI-assisted review), commit 6bb811398, MSVC RelWithDebInfo Ninja build. - Rebuilt runtime incrementally (vcvars64 + Ninja, 22 targets) — clean, no new warnings. - `runtime/build/host_cpu_test.exe`: "host: 0 missing feature(s) / all passed" — the new preflight() cases all pass: --dry-run and LEONIDA_SKIP_CPU_CHECK=1 skip the CPU probe entirely (fake_missing call count stays 0), --init/--run on a missing-AVX fake host returns kExitCode with message() text, null error pointer tolerated. - main.cpp refactor is behaviour-preserving: `init || run` maps to starts_game, and check_skipped() is only consulted inside preflight when starts_game is true — same short-circuit as before, so --dry-run still doesn't read the environment. - No GPU-visible behaviour (startup CPU gate only); ctest host_cpu entry is the test binary itself, which I ran directly. Verdict: LGTM.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1311/head:github-bot/gh-1311'
git switch 'github-bot/gh-1311'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1311'
git switch 'github-bot/gh-1311'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1311'
git switch 'github-bot/gh-1311'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1311'
git switch 'main'
git merge --squash 'github-bot/gh-1311'
git switch 'main'
git merge --ff-only 'github-bot/gh-1311'
git switch 'main'
git merge 'github-bot/gh-1311'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.