Fix psxrecomp_add_game_runtime for --no-recomp-ui headless builds - #199
Open
flyingclimber wants to merge 1 commit into
Open
Fix psxrecomp_add_game_runtime for --no-recomp-ui headless builds#199flyingclimber wants to merge 1 commit into
flyingclimber wants to merge 1 commit into
Conversation
psxrecomp_add_game_runtime() (added in mstan#110) is unusable with PSX_RECOMP_UI=OFF and real generated game C linked — a documented, supported config ("PSX_RECOMP_UI OFF for headless/generated builds", BUILDING.md) that nothing currently exercises. Found while bringing up a new title with recomp-ui intentionally left out initially. Two independent breaks in that combination: 1. main.cpp calls psx_game_codegen_forward_if_built() from main() whenever PSX_HAS_GAME_CODEGEN is set (i.e. any time real game C is linked), but only *declares* it under the narrower RECOMP_LAUNCHER guard. Any no-launcher build with generated game C fails with "use of undeclared identifier". Introduced a precise PSX_HAS_CODEGEN_SETUP_HOST macro (set only when a codegen-setup host is actually linked) and re-guarded both the declaration and the call site on it instead of the mismatched pair of guards. 2. psxrecomp_codegen_host.c was unconditionally added to every game target's extras, but it unconditionally #includes recomp_launcher.h from the recomp-ui submodule. Any --no-recomp-ui build fails with "recomp_launcher.h file not found". Gated its inclusion on PSX_RECOMP_UI. Verification: - Built and ran a new title (headless: PSX_RECOMP_UI=OFF, real generated game C, no launcher) end to end: OpenBIOS -> game entry -> continuous gameplay, clean atexit shutdown, no crash. - Regression-checked the one existing title that actually calls psxrecomp_add_game_runtime() (TombaRecomp; every other shipped title calls the lower-level psxrecomp_add_runtime_target directly and never reaches this code): built TombaRecomp's real production config (PSX_RECOMP_UI=ON, ENABLE_SETUP_WIZARD, recomp-ui launcher, mod catalog, setup-host/no-disc mode) against this branch via -DPSXRECOMP_ROOT override, no submodule surgery. Clean build, ran to the launcher with no regressions. Both changes are conditionally gated on flags Tomba always sets the opposite way, so this is expected and was confirmed empirically, not just by inspection. Not covered by this PR: CMAKE_CXX_STANDARD 17 is also never inherited by a game repo that include()s runtime.cmake directly (as opposed to add_subdirectory()-ing runtime/CMakeLists.txt), which silently compiles text_xlate.cpp's std::filesystem usage against whatever the host compiler's default standard is. Six of seven other title repos work around this by setting it themselves; happy to send a follow-up if that's wanted here instead of per-repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
psxrecomp_add_game_runtime()(added in #110) breaks withPSX_RECOMP_UI=OFFand real generated game C linked — a documented, supported config (docs/BUILDING.md: "PSX_RECOMP_UI OFF for headless/generated builds") that, as far as I can tell, nothing currently exercises. Found while bringing up a new title with recomp-ui intentionally left out for the first bring-up pass.Two independent breaks in that combination:
Declaration/call-site guard mismatch (
runtime/src/main.cpp).main()callspsx_game_codegen_forward_if_built()wheneverPSX_HAS_GAME_CODEGENis set (i.e. any time real game C is linked), but the function is only declared under the narrowerRECOMP_LAUNCHERguard. Any no-launcher build with generated game C fails to compile:use of undeclared identifier 'psx_game_codegen_forward_if_built'.Fix: introduced a precise
PSX_HAS_CODEGEN_SETUP_HOSTmacro (set only when a codegen-setup host is actually linked, i.e.CODEGEN_SETUP_SOURCESwas provided) and re-guarded both the declaration and the call site on it, instead of the previous mismatched guard pair.Unconditional recomp-ui dependency (
runtime/runtime.cmake).psxrecomp_codegen_host.cwas unconditionally appended to every game target's extras sources, but it unconditionally#includesrecomp_launcher.hfrom the optional recomp-ui submodule. Any--no-recomp-uibuild fails:recomp_launcher.h file not found.Fix: gated its inclusion on
PSX_RECOMP_UI.Why nothing caught this
psxrecomp_add_game_runtime()is currently used by exactly one shipped title — TombaRecomp — and Tomba always setsPSX_RECOMP_UI=ON. Every other title repo (ApeEscapeRecomp, Tomba2Recomp, MegaManX4/5/6Recomp, TsumuLightRecomp) calls the lower-levelpsxrecomp_add_runtime_target()directly and never reaches this code path at all.Verification
PSX_RECOMP_UI=OFF, real generated game C, no launcher. OpenBIOS → game entry → continuous gameplay, cleanatexitshutdown, no crash, nointerp_unsupportedfaults.PSXRECOMP_ROOTat this branch via configure-time override (no submodule surgery, perdocs/BUILDING.md#linking-the-framework), and built Tomba's real production config —PSX_RECOMP_UI=ON,ENABLE_SETUP_WIZARD, recomp-ui launcher, mod catalog, setup-host/no-disc mode. Clean build, ran to the launcher, no regressions. Both changes are conditionally gated on flags Tomba always sets the opposite way from the broken config, so this result was expected — but confirmed empirically rather than left as inference.ctestsuite before/after: same pass rate (47/51; the 4 pre-existing failures are unrelated — a timing-sensitive overlay-pair-lock flake and three content checks against files that only exist when therecomp-ui/recomp-netsubmodules are populated).Not covered here
CMAKE_CXX_STANDARD 17(runtime/CMakeLists.txt) is also never inherited by a game repo thatinclude()sruntime.cmakedirectly rather thanadd_subdirectory()-ing the framework's ownCMakeLists.txt— this silently compilestext_xlate.cpp'sstd::filesystemusage against whatever the host compiler's default standard happens to be. Six of seven other title repos work around this by settingCMAKE_CXX_STANDARD 17themselves. Happy to send a follow-up PR enforcing it insideruntime.cmakedirectly if that's preferred over per-repo workarounds — kept out of this PR to keep it focused on the one bug.Test plan
ctestinrecompiler/build— same pass/fail counts before and after