test(relinker): run the macOS guest module argument check under Rosetta #7519
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7519"
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 Destroyers212x on 2026-10-18T11:14:22Z.
What
test_guest_module_args.pyloads the converted Mach-O module to check the arguments its initializer receives. It ran that check only when Python itself reportsx86_64. On Apple silicon, Python is arm64, including in therelinker (macos-latest, clang++, x86_64)job from #7322, so the check was skipped there ("native execution skipped") even though the host library and module are x86-64.The macOS branch now keys on the host library's architecture: an x86-64 Mach-O, read from its header. It loads through a small x86-64 C loader built with
xcrun clang -arch x86_64and started with/usr/bin/arch -x86_64on arm64, the same patterntest_macos_guest_weak_imports.pyuses. The loader does what the Python--loadpath does: itdlopens the host withRTLD_GLOBAL, callsSetPendingArgs(ARGS, ARGP), thendlopens the module. A native arm64 build still skips the check, because its host library is arm64 and cannot load the x86-64 module. Linux is unchanged.#6149 adds a Linux-only case to the same file in a different block; whichever merges second needs a small rebase.
Tested
Apple M1, macOS 26.6.2, AppleClang, arm64 Python 3.11, relinker-only Release builds with the CI configure line:
-DCMAKE_OSX_ARCHITECTURES=x86_64:guest_module_argsprints "Guest module argument tests passed" (previously "...: native execution skipped").guest_deferred_dependenciesandmacos_guest_weak_importspass.ARGS + 1, the test fails withAssertionError: args=1122334455667789 ..., so the check does reach the module's initializer.python3 tools/check_conventions.py --base origin/mainpasses.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T11:35:04Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/relinker/relinker/tests/test_guest_module_args.pyImported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-18T13:53:36Z.
Tested on an Apple M4 Pro (MacBook Pro, 24 GB), macOS 27.0.1 (26A434), Rosetta 2, Apple clang 21.0.0, CMake 4.4.4, Ninja 1.13.2, Xcode's Python 3.9.6 (runs as arm64).
PR head
f08068ff5merged into currentmain(385ed71f2), relinker-only Release builds with the CI configure line:guest_module_args-DCMAKE_OSX_ARCHITECTURES=x86_64main: "native execution skipped")guest_module_args_host.prxis x86_64 in the first build and arm64 in the second, somacho_x86_64picks the expected branch in both.Negative controls on the x86_64 build, editing only the loader source in the test and restoring it afterwards:
ARGS + 1: fails withAssertionError: args=1122334455667789 argp=99aabbccddeeff00(your control, reproduced here);SetPendingArgs: fails withAssertionError: args=0000000000000000 argp=0000000000000000, so the recorded values reach the module initializer through the host library and are not a default.--repeat until-fail:20on the x86_64 build: 20/20, about 0.5 s per run including the loader compile.guest_deferred_dependenciesandmacos_guest_weak_importspass in the same build.Not checked: Linux and Windows (their branches are unchanged), and
guest_module_fini, which still skips on macOS because it converts to Linux ELF only.AI-assisted: yes (Claude Code). I ran all of the above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T22:36:19Z.
Read the diff and checked CI on the current head, including the new
relinker (macos-latest, clang++, x86_64)job; the x86-64 loader mirrors the Python--loadpath, native arm64 still skips, Linux is unchanged. Also confirmed on an M4 Pro by @imellag; merged.