fix(relinker): emit module-qualified guest imports in macOS output #21728
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21728"
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 AasishDairelSahayaGrinspan on 2026-11-16T17:18:26Z.
What
macOS output dropped module-qualified guest imports. When two bundled modules export the same NID, Linux rewrites the executable's imports to
name#moduleNand binds them in the declared provider; on macOS every one of those steps was gated off (bindingName, the declared-provider rename/type check,executableProviders, guest-moduleimportBindings, andBindingAliases), so an import needed from two providers failed conversion outright.macOS now uses the same mechanism: the guest-module writer emits each
BindingAliasesentry as an extra Mach-O export (ordinary intoExports, TLS intoTlsExports, weak flag copied), and dyld flat-namespace binds resolve the aliased name in the declared provider. The multi-provider rejection remains only when no provider is declared, matching Linux.BindNamedImportsByNidstays macOS-gated.Evidence: technical debt entry 92 — "still use flat symbol lookup on macOS; the requested provider is not retained" — and the tested Linux provider-qualified path (
test_linux_guest_qualified_imports.py).Tested
Linux (Omarchy 4.0.2), relinker-only build (
-DANYPS5_RELINKER_ONLY=ON, Release,BUILD_TESTING=ON):macos_guest_qualified_imports|linux_guest_qualified_imports|macos_guest_weak_imports|macos_guest_weak_exports|guest_symbol_names|macos_output— 6/6 passed (new test 0.05 s).The new fixture mirrors the macOS weak-import test and asserts the export trie and bind opcodes structurally; there is no Mach-O runtime on this machine, so runtime execution on macOS/Rosetta remains unmeasured and stays recorded in the debt entry.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-17T06:14:32Z.
Review: COMMENTED
Tested on macOS 27.2 on an Apple M4. This is an x86-64 build under Rosetta with Apple clang 21.0.0. As far as I can tell, this is the first macOS run of this PR; the description lists Linux only.
Method. I compared
mainata72186d3cfwith this PR merged onto it. The merge was clean. I ran the full relinker suite three times on each:macos_guest_qualified_importslinux_guest_qualified_importsThe new test catches the bug. I kept this PR's tests and restored
main'sMacOsGuestModuleWriter.cppandGuestModuleBuilder.cpp. Thenmacos_guest_qualified_importsfails attest_macos_guest_qualified_imports.py:65withAmbiguous guest import shared ... exported by .../a.prx .../b.prx. That is the old gate refusing the input. With the PR's sources back in place, it passes.Limitation. The new test checks the structure of the output: the export trie and the bind opcodes. It doesn't load the converted program with
dyldor run it. So even on macOS, nothing here confirms that a module-qualified import actually binds to the right PRX at run time. A test that runs the converted fixture and checks which module's export it reached would cover that. I didn't run any title with this change.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:12:33Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the synthetic fixtures cover declared-provider selection, ambiguous imports, aliases, and type mismatch handling.
What I ran
Reviewed head
ab2b4bf377034922fab374e7deb64afa01b0bad2againstmainusing the prepared diff andrepo_read.pyat the pinned head. I did not run commands or tests; author-reported test results are not independently verified.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build and test results reported in the PR description; macOS or Rosetta runtime behavior. Read all changed files listed in the review manifest; no changed files were excluded.
To get this to a good state
Nothing is required.