feat(build): record the CPU flags a build compiled with #2673

Open
github-sync wants to merge 3 commits from github/pr/2673 into main
Owner

@steefzilla opened this pull request on GitHub · 2026-11-12 05:29 UTC · original

A finished game could not say which -march it was built for, so two builds of the same release could not be told apart.

The build writes that CPU flag list to hookshot_flags.txt and prints it as the log's second line. The list is -march, -ffp-contract=off, an -mtune when one is set, and any extra RX_CPU_FLAGS. Include paths are left out. Reading those flags back on an update is left to #2577.

Tested with the game-free unit tests, then a full Linux build (i7-11700KF, RTX 3080, driver 595.99.02, Ubuntu 24.04) into a separate folder. The log printed -march=rocketlake -ffp-contract=off -mprefer-vector-width=256, hookshot_flags.txt matched, and the game was played with DLSS on.

Fixes #2576

Summary

  • Record the CPU flags a build actually used, in hookshot_flags.txt and the game log.
  • Cover the list, the file, and the log line with game-free tests.

Test plan

  • python3 -I -B tests/test_compile_flags.py
  • python3 -I -B tests/test_cpu_target.py
  • Full Linux build on an i7-11700KF and RTX 3080; log line and hookshot_flags.txt match; the game was played

Made with Cursor

> [@steefzilla](https://github.com/steefzilla) opened this pull request on GitHub · 2026-11-12 05:29 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2673) A finished game could not say which -march it was built for, so two builds of the same release could not be told apart. The build writes that CPU flag list to hookshot_flags.txt and prints it as the log's second line. The list is -march, -ffp-contract=off, an -mtune when one is set, and any extra RX_CPU_FLAGS. Include paths are left out. Reading those flags back on an update is left to #2577. Tested with the game-free unit tests, then a full Linux build (i7-11700KF, RTX 3080, driver 595.99.02, Ubuntu 24.04) into a separate folder. The log printed `-march=rocketlake -ffp-contract=off -mprefer-vector-width=256`, hookshot_flags.txt matched, and the game was played with DLSS on. Fixes #2576 ## Summary - Record the CPU flags a build actually used, in hookshot_flags.txt and the game log. - Cover the list, the file, and the log line with game-free tests. ## Test plan - [x] `python3 -I -B tests/test_compile_flags.py` - [x] `python3 -I -B tests/test_cpu_target.py` - [x] Full Linux build on an i7-11700KF and RTX 3080; log line and hookshot_flags.txt match; the game was played Made with [Cursor](https://cursor.com) <!-- github-sync:item:2673 -->
A finished game could not say which -march it was built for, so nothing later could tell two builds of the same release apart.
The game-free run already builds each define into the job that consumes it. The flag record was only calling the helper and searching the source.
Author
Owner

@Joey-Magnus reviewed on GitHub · 2026-11-12 14:33 UTC · original

I merged this into current main and ran the full tests/run_all.py: 427 passed, with only test_lift_cache failing, as on main here. tests/test_compile_flags.py and test_cpu_target.py pass. Passing the -D to hos_main.c alone matches how HOOKSHOT_VERSION is done.

Points for the maintainers and you:

  • #2608 (JooaoPedro15, opened earlier, now conflicting) implements the same request, #2576, with a JSON file. Only one should land, so someone needs to pick. #2576 itself was closed as a duplicate of #2505, and the reopen request there is unanswered.
  • RX_CPU_FLAGS is new. It's more than recording: it injects arbitrary flags into every object, lifted code included. nx2/compile_flags.py:22 drops only -I, --sysroot and -ffp-contract, so -ffast-math or -Ofast would get through and break the exact float behaviour the lifted code relies on (the same reason contraction is off). I'd either keep it to -m* flags or leave the knob out of this PR.
  • make_game.py:2368 writes the file from compile_flags.current(), which re-derives the flags in make_game's process instead of taking what build.py printed. They match today, but a later env tweak in make_game would make them drift silently.
> [@Joey-Magnus](https://github.com/Joey-Magnus) reviewed on GitHub · 2026-11-12 14:33 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2673#pullrequestreview-5876229230) I merged this into current main and ran the full tests/run_all.py: 427 passed, with only test_lift_cache failing, as on main here. tests/test_compile_flags.py and test_cpu_target.py pass. Passing the -D to hos_main.c alone matches how `HOOKSHOT_VERSION` is done. Points for the maintainers and you: - #2608 (JooaoPedro15, opened earlier, now conflicting) implements the same request, #2576, with a JSON file. Only one should land, so someone needs to pick. #2576 itself was closed as a duplicate of #2505, and the reopen request there is unanswered. - `RX_CPU_FLAGS` is new. It's more than recording: it injects arbitrary flags into every object, lifted code included. nx2/compile_flags.py:22 drops only -I, --sysroot and -ffp-contract, so `-ffast-math` or `-Ofast` would get through and break the exact float behaviour the lifted code relies on (the same reason contraction is off). I'd either keep it to `-m*` flags or leave the knob out of this PR. - make_game.py:2368 writes the file from `compile_flags.current()`, which re-derives the flags in make_game's process instead of taking what build.py printed. They match today, but a later env tweak in make_game would make them drift silently. <!-- github-sync:r:5876229230 -->
RX_CPU_FLAGS keeps only -m flags, so a float flag cannot reach the lifted code. The game folder copies the line the compile printed, the same line the log shows.
Author
Owner

@steefzilla commented on GitHub · 2026-11-12 17:15 UTC · original

Thank you for running the suite and for the notes. Two of them are in e715a35f.

RX_CPU_FLAGS now keeps only flags that start with -m, such as -mprefer-vector-width=256. -ffast-math and -Ofast are left out. hookshot_flags.txt is the compile flags: line the compile printed, not a second look at the environment. That line is also compiled into hos_main.c and printed on every start, as the second line of the log, the same way the version line is. There is no extra command for it. The file sits beside the game for a later update to read (#2577, not part of this change).

#2608 records the same idea and also embeds its text in the binary. Its cpu list is the real argument list. The lifted, hot, and host fields are normalized, with include paths removed, so they are not a command an update can run again. This pull request keeps only the CPU list, which is the part that can be reused, and the log line stays one short line. #2608 does publish that file through the installer and leaves the previous record in place if the write fails. We do not. Happy to close this one if the JSON record is the one you want.

> [@steefzilla](https://github.com/steefzilla) commented on GitHub · 2026-11-12 17:15 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2673#issuecomment-6830629628) Thank you for running the suite and for the notes. Two of them are in e715a35f. `RX_CPU_FLAGS` now keeps only flags that start with `-m`, such as `-mprefer-vector-width=256`. `-ffast-math` and `-Ofast` are left out. `hookshot_flags.txt` is the `compile flags:` line the compile printed, not a second look at the environment. That line is also compiled into `hos_main.c` and printed on every start, as the second line of the log, the same way the version line is. There is no extra command for it. The file sits beside the game for a later update to read (#2577, not part of this change). #2608 records the same idea and also embeds its text in the binary. Its `cpu` list is the real argument list. The `lifted`, `hot`, and `host` fields are normalized, with include paths removed, so they are not a command an update can run again. This pull request keeps only the CPU list, which is the part that can be reused, and the log line stays one short line. #2608 does publish that file through the installer and leaves the previous record in place if the write fails. We do not. Happy to close this one if the JSON record is the one you want. <!-- github-sync:c:6830629628 -->
Commenting is not possible because the repository is archived.
No description provided.