Skip to content

gta6rt: --init/--run stop with a clear message on a host without AVX - #9754

Closed
sennecools wants to merge 1 commit into
ProjectLeonida:mainfrom
sennecools:gta6rt-avx-preflight
Closed

sennecools wants to merge 1 commit into
ProjectLeonida:mainfrom
sennecools:gta6rt-avx-preflight

Conversation

@sennecools

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-NEW-AVX-PREFLIGHT (#9522 (comment)), from NolanCotter's finding in #9235

Depends on: none. It touches the same lines as #9197 (AVX2/FMA/BMI2 check, only in a -DLEONIDA_AVX2 build), #9477, #7111 and #8537 (main.cpp includes) and #9339, #9666 (build_runtime.ps1 file list): whichever lands second re-adds one line.

What and why

The game runs AVX code from its TLS callbacks on. On a host without AVX (a QEMU qemu64 guest) it died with a bare 0xC000001D, which reads like a loader bug. --init and --run now check CPUID.1 AVX/OSXSAVE and the XCR0 YMM state before anything is mapped; XGETBV runs only when OSXSAVE is set. On failure they print one line naming what is missing (and suggest QEMU -cpu host, or ROSETTA_ADVERTISE_AVX=1 under Rosetta) and exit 4, since 3 is LEONIDA_UNIMPLEMENTED=stop. LEONIDA_SKIP_CPU_CHECK=1 skips it; --dry-run never runs it. AVX only: no emulation (RT-500) and no AVX2/FMA (#9197, which could reuse missing_host_features). runtime/README.md and docs/boot.md describe it.

Tested

  • host_cpu_test (new): 9 blocks on synthetic CPUID/XCR0 words and the skip variable, passes; ctest -R ^host_cpu$ 1/1.
  • Negative control: with the check stubbed to report nothing, 6 failures.
  • gta6rt --init on an AVX host passes the check. The exit-4 path is covered by the unit test only.
  • Ryzen 7 9800X3D, Windows 11, MSVC 2022 (VS BuildTools), Ninja. No GPU involved.

AI-assisted: yes

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. (not a translator change)

The game runs AVX code from its TLS callbacks on, so a CPU or OS without
AVX (a QEMU qemu64 guest) died with a bare 0xC000001D. Check CPUID.1
AVX/OSXSAVE and XCR0 YMM state first, print one line and exit 4 (3 is
LEONIDA_UNIMPLEMENTED=stop). --dry-run is unchanged and
LEONIDA_SKIP_CPU_CHECK=1 skips the check.

AI-assisted.

@Grimkaaah Grimkaaah 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.

Independent review (Linux CPU) — PASS (code-only; Win host_cpu CTest not run)

Checked

  • New host_cpu preflight for --init/--run: AVX + OSXSAVE + XCR0 YMM; exit 4 with a clear missing-feature line; LEONIDA_SKIP_CPU_CHECK=1 / Rosetta note documented; synthetic host_cpu_test + CMake/ps1 wiring.
  • Diff is focused and the synthetic-CPUID test design is sound.

Not executed here: Windows host_cpu CTest / gta6rt without AVX.

No game files. Reviewer: Grimkeh (AI-assisted Cursor / Composer).

@catminou4 catminou4 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.

Partial verification on macOS 26 arm64 (Apple clang 21, no cmake/GPU here): compiled runtime/src/host_cpu.cpp standalone and ran a harness replicating every pure-function case from runtime/test/host_cpu_test.cpp (AVX/OSXSAVE/XCR0 decision table + the one-line message contents) — all passed. The PR's own host_cpu_test.cpp includes <windows.h> and SetEnvironmentVariableA, so it needs the Windows lane; main.cpp/CMake integration likewise unverified by me. The core logic looks right: XGETBV is correctly gated behind OSXSAVE, and the Rosetta note matches the header comment. AI-assisted (Devin).

@kawaii-shakal

Copy link
Copy Markdown

CPU-only review of ad6e5d6b on Linux x86-64. I applied the public diff to its base and verified all eight changed blob hashes against the diff. The supplied host_cpu_test.cpp passed with GCC in the POSIX and locally shimmed Win32 environment branches, with compiler AVX disabled. A harness using the startup branch passed 32 combinations of mode, bypass, and synthetic AVX availability, including exit 4 for init/run without AVX and zero probes for dry-run or bypass.

This covers the preflight and its wiring before mapping in the source. It does not run the native Windows executable or a real no-AVX host. Review and verification by OpenAI Codex, with synthetic inputs only.

@ItsNotRexed

Copy link
Copy Markdown
Member

Closing: pull requests on Leonida are now limited to ProjectLeonida members. Thanks for the contribution.

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.

5 participants