AppImage: say up front when its renderer needs AVX2 the CPU lacks #414

Merged
Wpaif merged 1 commit from fix/cpu-without-avx2 into main 2026-11-08 16:49:22 +00:00
Wpaif commented 2026-11-08 00:03:13 +00:00 (Migrated from github.com)

Refs #363

Thanks for 2c48613: the build now follows the CPU, which covers the reporter's case (Windows builder, everything compiled locally). I reduced this PR to what that commit leaves open, and dropped my own CPU detection in favour of yours.

What is still open

The Linux AppImage's hookshot_vk.so comes prebuilt from CI (HOOKSHOT_VK_PREBUILT). On a CPU without AVX2 the game is now built for x86-64-v2, but that renderer is still x86-64-v3, so the game stops at its start after the whole build.

Change

  • nx2/host_cpu.py: host_march() moved there unchanged (byte-identical to 2c48613), so make_game.py can ask it without importing build.py (which does work at import). build.py imports it; its MARCH/CPU lines are untouched.
  • nx2/make_game.py: check_cpu() stops before the game is read, with a plain message pointing to a source build, when HOOKSHOT_VK_PREBUILT is set and the CPU is not x86-64-v3. A player-set RX_MARCH skips it.
  • scripts/linux/appimage.sh: the prebuilt renderer is pinned to RX_MARCH=x86-64-v3, so with host_march() it no longer depends on the CI runner's CPU.
  • tests/test_cpu_target.py (game-free, in source-regressions): host_march() on Haswell / Ivy Bridge / Core 2 cpuinfo, an unreadable cpuinfo, and the Windows IsProcessorFeaturePresent path (faked); check_cpu() stopping only for the AppImage without AVX2, and running before the game is read.

Testing

  • python -I -B tests/test_cpu_target.py: 9/9 pass; it fails when the AppImage stop is disabled.
  • The rest of the suite passes on Linux (test_cpp_preflight.py already fails on main; #409 fixes it).
  • Not run on a pre-AVX2 CPU or on Windows (I only have a Linux PC with AVX2).

If you'd rather keep host_march() in build.py, I can instead have make_game.py import it from there.

🤖 Generated with Claude Code

Refs #363 Thanks for 2c48613: the build now follows the CPU, which covers the reporter's case (Windows builder, everything compiled locally). I reduced this PR to what that commit leaves open, and dropped my own CPU detection in favour of yours. ## What is still open The Linux AppImage's `hookshot_vk.so` comes prebuilt from CI (`HOOKSHOT_VK_PREBUILT`). On a CPU without AVX2 the game is now built for x86-64-v2, but that renderer is still x86-64-v3, so the game stops at its start after the whole build. ## Change - **`nx2/host_cpu.py`**: `host_march()` moved there **unchanged** (byte-identical to 2c48613), so `make_game.py` can ask it without importing `build.py` (which does work at import). `build.py` imports it; its `MARCH`/`CPU` lines are untouched. - **`nx2/make_game.py`**: `check_cpu()` stops before the game is read, with a plain message pointing to a source build, when `HOOKSHOT_VK_PREBUILT` is set and the CPU is not x86-64-v3. A player-set `RX_MARCH` skips it. - **`scripts/linux/appimage.sh`**: the prebuilt renderer is pinned to `RX_MARCH=x86-64-v3`, so with `host_march()` it no longer depends on the CI runner's CPU. - **`tests/test_cpu_target.py`** (game-free, in source-regressions): `host_march()` on Haswell / Ivy Bridge / Core 2 cpuinfo, an unreadable cpuinfo, and the Windows `IsProcessorFeaturePresent` path (faked); `check_cpu()` stopping only for the AppImage without AVX2, and running before the game is read. ## Testing - `python -I -B tests/test_cpu_target.py`: 9/9 pass; it fails when the AppImage stop is disabled. - The rest of the suite passes on Linux (`test_cpp_preflight.py` already fails on `main`; #409 fixes it). - Not run on a pre-AVX2 CPU or on Windows (I only have a Linux PC with AVX2). If you'd rather keep `host_march()` in `build.py`, I can instead have `make_game.py` import it from there. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Wpaif commented 2026-11-08 01:29:31 +00:00 (Migrated from github.com)

Checked the no-visual-studio release (which closed #363 and its duplicate #410) to confirm the AppImage case this PR covers.

I extracted usr/lib/hookshot/hookshot_vk.so from Hookshot-no-visual-studio-x86_64.AppImage (read from its squashfs, without running it) and disassembled it with objdump -d. It is built for x86-64-v3 throughout, e.g.:

Instructions (x86-64-v3 only) Count
BMI2 shlx/shrx/sarx/rorx/bzhi/pdep/pext/mulx 1068
AVX2 vpbroadcast* 310
AVX2 vpsllv/vpsrlv/vpsrav 197
AVX2 vpermd/vpermq 176
AVX2 vextracti128 / vinserti128 163 / 108
lzcnt/tzcnt 146
movbe 94

So on Linux, a CPU like the Xeon E3-1230 v2 from #410 now gets the game built for x86-64-v2 by host_march(), but the AppImage's renderer still stops at its first AVX2/BMI2 instruction, after the ~40-minute build. The Windows builder compiles hookshot_vk.dll locally, so it isn't affected. check_cpu() in this PR says so before the game is read, and pinning RX_MARCH=x86-64-v3 in appimage.sh keeps the prebuilt renderer from depending on the CI runner's CPU.

Checked the `no-visual-studio` release (which closed #363 and its duplicate #410) to confirm the AppImage case this PR covers. I extracted `usr/lib/hookshot/hookshot_vk.so` from `Hookshot-no-visual-studio-x86_64.AppImage` (read from its squashfs, without running it) and disassembled it with `objdump -d`. It is built for x86-64-v3 throughout, e.g.: | Instructions (x86-64-v3 only) | Count | |---|---| | BMI2 `shlx`/`shrx`/`sarx`/`rorx`/`bzhi`/`pdep`/`pext`/`mulx` | 1068 | | AVX2 `vpbroadcast*` | 310 | | AVX2 `vpsllv`/`vpsrlv`/`vpsrav` | 197 | | AVX2 `vpermd`/`vpermq` | 176 | | AVX2 `vextracti128` / `vinserti128` | 163 / 108 | | `lzcnt`/`tzcnt` | 146 | | `movbe` | 94 | So on Linux, a CPU like the Xeon E3-1230 v2 from #410 now gets the game built for x86-64-v2 by `host_march()`, but the AppImage's renderer still stops at its first AVX2/BMI2 instruction, after the ~40-minute build. The Windows builder compiles `hookshot_vk.dll` locally, so it isn't affected. `check_cpu()` in this PR says so before the game is read, and pinning `RX_MARCH=x86-64-v3` in `appimage.sh` keeps the prebuilt renderer from depending on the CI runner's CPU.
Commenting is not possible because the repository is archived.
No description provided.