Skip to content

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

Open
steefzilla wants to merge 3 commits into
NotRexed:mainfrom
steefzilla:build/record-compile-flags
Open

steefzilla wants to merge 3 commits into
NotRexed:mainfrom
steefzilla:build/record-compile-flags

Conversation

@steefzilla

Copy link
Copy Markdown

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

Steve Mattsen added 2 commits November 12, 2026 00:28
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.

@Joey-Magnus Joey-Magnus 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.

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.

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

Copy link
Copy Markdown
Author

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

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.

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.

Record the compile flags a build actually used

2 participants