fix(relinker): select guest startup dependencies from required roots #5559
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5559"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-13T23:53:20Z.
What
Choose guest module startup dependencies from the roots that actually need them. Dependencies of runtime-only modules discovered with --module-dir stay deferred until a required root uses them. A relocated executable import resolved to a unique guest provider requires that module and its dependency chain even without a DT_NEEDED entry; previously the import was renamed for guest binding but its provider could remain unloaded. Unreferenced dynamic symbols and R_X86_64_NONE relocations do not require an otherwise deferred module.
The branch includes the earlier unpublished runtime-only dependency fix (original commit b32fd1141, preserved as a separate commit) and the executable-import correction. Windows retains its current eager dependency handling. Linux and macOS select startup roots from required modules and executable bindings. Logical export-library namespaces are unchanged.
Tested
Rebased as three linear commits on main
d92a8dad390af1807cc91622b924252141816a5a, published heada38314933da4209c8ee36faafa3e7c6a8f7976ea. The third commit copies the existing synthetic host module underlibkernel.prxas well aslibc.prx, following Zinebyte's reproduction of the required initializer dependency when this topic is composed with #6106. It changes only the test fixture. The branch merges cleanly into current main.Fresh Linux Release relinker-only build passed; 173/173 CTests passed, including
guest_deferred_dependencies, with zero skips. Local conventions and whitespace checks passed. The current PR's relinker CI matrix also passed on Linux, macOS and Windows; full project build jobs were skipped.Composition with current #6106 head
78b906fb67a8edff3969f60d26ced129f981139echerry-picked cleanly and passedguest_deferred_dependencies; 172/173 relinker CTests passed initially. Its newguest_module_dirtest failed to load syntheticlibOptional.prxon this host because the fixture requested an executable stack. I reproduced the identical deterministic failure with #6106 alone on current main. A local two-line non-executable-stack ELF header correction in that test made 172/172 #6106-alone CTests and 173/173 composed CTests pass. That correction is separate and is not part of this PR.Earlier validation
('imported', 'provider', ['libc.prx']).90c683946plus other development changes. Local topic and integration conventions pass.The initial fork review used base
1acfa7f78; those integration results are historical.Full CI run 38323687739 passed at the earlier topic head
25c1cc8ac. Linux: 937 passed and 43 skipped (980 total); Windows: 639 passed and 357 skipped (996 total). All Linux, Windows and macOS relinker jobs, register-context jobs and write-watch jobs passed. These full runs validate the independent topic, beyond the earlier local integration. GitHub conventions passed.Checklist
Historical upstream validation
Former head
c37a4b8b6b85d94cb9bcc6c75b8b86905ebf3c29contains maind1670009fbfdfe57f8f26ee09ced77fe6b18c2ca. The topic's production change is unchanged by the latest rebase. Previous validated build passes at4b26d31b1db2317ca538a3e7fd0e614257db1520against main7a0c838ca48; those results apply to their explicitly recorded earlier head/base. Earlier full Linux and Windows validation passes forc37a4b8b6; expected skips remain unvalidated.Independent macOS validation
jotitadev reports testing former head
c37a4b8b6on main84b01f9cd, Apple M2 Max / macOS 27.2 / AppleClang. The arm64 relinker-only build passed 157/157 cases. Under Rosetta 2, 151/157 passed; the same six failures reproduced on unmodified main, andguest_deferred_dependenciespassed. Dependency inspection confirms that the imported executable loads its required provider while leaving the unused consumer deferred.Their runtime check used the synthetic imported-module fixture, a stand-in startup shim and the separate #5362 fixture correction. With those stated conditions, the relocated call returned 42 and the provider initialized once. The uncorrected fixture fails dyld on both main and this topic. This is contributor-reported fixture evidence, not a native game run or a claim that this branch includes #5362.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T15:46:20Z.
macOS data point, since the description only inspects the macOS dependency lists.
Apple M2 Max, macOS 27.2 (26B5091g), AppleClang, Ninja Release, relinker-only (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON). Headc37a4b8b6merged without conflicts intomain84b01f9cd.ctest --parallel 8 --timeout 30157/157 pass, includingguest_deferred_dependencies.-DCMAKE_OSX_ARCHITECTURES=x86_64, x86_64 Python): 151/157. The 6 failures (pr_overlap_encoding,progress_history,stubgen_stdout_newlines,release_package,linux_fixed_base,guest_module_args) fail the same way on unmodifiedmain84b01f9cdon this machine (five are Python 3.9 incompatibilities of the only x86_64 Python here;guest_module_argsis the fixture #5362 fixes);guest_deferred_dependenciespasses.mainrelinker fails at the first scenario:('runtime', 'consumer', [...provider..., ...consumer..., 'libc.prx']).importedscenario,otool -L:mainloadsprovider.prx.guest.prxandconsumer.prx.guest.prx; this PR loads onlyprovider.prx.guest.prx.Runtime check of the
importedMach-O output under Rosetta 2, withlibs/libc.prx= x86_64guest_module_args_hostandlibs/libkernel.prx= a stand-in whoseAps5StartGuest_nid_no_patchswitches to the prepared stack and jumps to the entry (the fixture's Linuxexitsyscall is caught as SIGSYS and turned into_exit(rdi)):BIND_OPCODE_DO_BIND pointer bind is in executable segment '__ELF0'. Same withmain; it is theargs_moduleRWX GOT that #5362 moves out of the executable segment.args=recorded once), matching what the Linux branch of the test expects.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Zinebyte on 2026-10-14T22:56:40Z.
Small Linux fixture correction for composition with #6106 (
d3e2f294ddc6d9252ab6dfd1904a234b622153c5), checked against this PR's current headc37a4b8b6b85d94cb9bcc6c75b8b86905ebf3c29.test_guest_deferred_dependencies.pysupplies the host fixture aslibs/libc.prx, but #6106 makes the generated initializer helpers'libkernel.prxdependency explicit. The deferred load at line 127 consequently fails with:Copying the same existing host fixture under the required kernel name fixes it:
Fresh local verification: Linux x86-64, GCC 13.3, Release relinker-only build, main
6239ceffc84e0c104904e5454f8f3c1eb22a4049composed with #6100, #6103, #6105, #6106, #6080 and this PR. Without this line,guest_deferred_dependenciesfails in 0.18 s. With only this fixture correction, 174/174 CTests pass in 22.82 s, including that test in 0.23 s. Conventions and whitespace checks pass. Earlier isolation also confirmed that this PR alone passes and adding #6106 triggers the failure.This follows the two-copy fixture pattern already used in
test_guest_module_args.pyand preserves required-library enforcement. Could you include this one-line fixture update?Prepared and verified with OpenAI Codex assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:16:25Z.
Checked the dependency selection on the merged tree: relinker build and ctest 133/133 with no skips, and
guest_deferred_dependenciesfails whenGuestModuleBuilder.cppis reverted. It covers runtime-only deferral, executable/bundled roots, imported provider (native run returns 42), unreferenced symbols and no-op relocations, plus macOS dependency lists. Merging once the full build is green.