test(relinker): execute the AMD64-only conversion stubs on macOS #6524
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6524"
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 javierUDP on 2026-10-15T18:41:48Z.
What
Amd64OnlyConverterTests.cppcompiled its execution section for Linux x86-64 only, so the SSE4A, SHA-1, SHA-256, CLZERO and reciprocal stubs were never executed on a macOS x86-64 build, althoughAndnLoweringTests.cppalready builds its execution path on__APPLE__and the Rosetta conversion limits record that the other conversions were checked on a Mac outside this repository. The section now builds on macOS x86-64, where it runs under Rosetta.The CLZERO case with an address-size override needs a buffer below 4 GiB. A 64-bit Mach-O executable reserves the first 4 GiB as
__PAGEZERO, soMAP_32BIThas no address to return; the samemmapsucceeds when the executable is linked with a smaller zero page. The Apple x86-64 build links this test with a 64 KiB zero page and all four CLZERO cases run, so the mapping failure stays fatal on every platform. The arm64 build keeps the 4 GiB zero page, which it requires to start, and the section is not built there.Tested
Apple M5, macOS 26.4, AppleClang 21.0.0, relinker-only build of
44df21632:-DCMAKE_OSX_ARCHITECTURES=x86_64, executed under Rosetta: 173/173 ctest pass.amd64_only_converterruns the EXTRQ and INSERTQ register and immediate form stubs, SHA-1, SHA-256, all four CLZERO cases, the reciprocal stubs and the RIP-relative stub bodies.67h CLZERO stubcase maps its buffer at0x4632000, below 4 GiB, and the linked image reports__PAGEZEROwithvmsize 0x10000.__PAGEZEROstays atvmsize 0x100000000, and the section stays out of the build.extrqReferencefails the x86-64 run with "EXTRQ register form stub computed the wrong field", so the section executes instead of being skipped.python3 tools/check_conventions.py --base origin/mainpasses.Zero page measurements on this host, matching the review below:
MAP_32BITMAP_FIXEDat 0x10000000-arch x86_64, default link-arch x86_64,-Wl,-pagezero_size,0x100000x8c70000x10000000-arch arm64,-Wl,-pagezero_size,0x10000No Linux or Windows host was available, so the Linux x86-64 execution path was not re-run; its flags and its mapping requirement are unchanged.
Thanks to @jotitadev for identifying
__PAGEZEROas the cause and for the Linux coverage point; both are addressed ind67e7b738.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: n/a, test-only change.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T19:27:31Z.
Review: COMMENTED
Static review on macOS, head
6f100d3f6. Checked with a standalone snippet, not with this PR's test binary.Machine: Apple M2 Max, macOS 27.2 (26B5091g), Xcode 27 clang.
The missing low mapping comes from
__PAGEZERO, not from Rosetta. A 64-bit Mach-O executable gets a 4 GiB__PAGEZEROby default, so nothing below 4 GiB is free. Rosetta does map low memory when the executable leaves room for it.A snippet doing the same
mmap(..., MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT)and aMAP_FIXEDat0x10000000:MAP_32BITMAP_FIXED0x10000000-arch x86_64(Rosetta), default link-arch arm64, default link-arch x86_64(Rosetta),-Wl,-pagezero_size,0x100000x7d70000x10000000-arch arm64,-Wl,-pagezero_size,0x10000Linking only
amd64_only_converter_testswith-Wl,-pagezero_size,0x10000on Apple x86_64 would run the fourth CLZERO case under Rosetta too, so thecontinuewould not be needed on macOS. arm64 requires the 4 GiB zero page, but this section is x86_64-only anyway. Something like:Side effect on Linux.
if (buffer == nullptr && item.Low) continue;applies on every platform. IfMAP_32BITever fails on Linux, the low case is now skipped without any message, where it used to fail with "cannot map the CLZERO buffer". Limiting thecontinueto__APPLE__, or failing on Linux as before, would keep the Linux coverage strict.The rest of the description matches what I see:
MAP_32BITis defined in the macOS SDK (0x8000), so the section compiles on both architectures.Written with AI assistance (Claude Code). I ran the check above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T19:31:01Z.
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/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by javierUDP on 2026-10-15T20:14:19Z.
Confirmed on an M5 running macOS 26.4, AppleClang 21.0.0, with the same snippet:
MAP_32BITMAP_FIXEDat 0x10000000-arch x86_64, default link-arch x86_64,-Wl,-pagezero_size,0x100000x8c70000x10000000-arch arm64,-Wl,-pagezero_size,0x10000You are right that it is
__PAGEZEROand not Rosetta, and the fix removes the second problem as well.d67e7b738links the test with a 64 KiB zero page on Apple x86-64, so thecontinueis gone and the mapping failure is fatal again on every platform, as it was before this pull request.All four CLZERO cases now run on macOS: the
67h CLZERO stubcase maps its buffer at0x4632000andotool -lreports__PAGEZEROwithvmsize 0x10000. The arm64 build keepsvmsize 0x100000000, does not get the option, and still passes 173/173, as does the x86-64 build under Rosetta.The condition also covers a native Intel Mac, where
CMAKE_OSX_ARCHITECTURESis empty andCMAKE_SYSTEM_PROCESSORisx86_64. I have no such host, so that path is untested.The description no longer claims that Rosetta withholds low memory. Thanks for catching it.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T12:47:55Z.
Review: COMMENTED
Re-checked on macOS, head
d67e7b738merged ontomain82ddae75b.Machine: Apple M2 Max, macOS 27.2 (26B5091g), Xcode 27 clang, relinker-only Release builds.
-DCMAKE_OSX_ARCHITECTURES=x86_64 -DPython3_EXECUTABLE=/usr/bin/python3):amd64_only_converterpasses;otool -lreports__PAGEZEROvmsize 0x10000foramd64_only_converter_tests. Full ctest 170/173, the same 3 Python 3.9 failures asmain(pr_overlap_tools,release_package,linux_fixed_base), none related.extrqReferencemakes the x86_64 binary fail with "EXTRQ register form stub computed the wrong field", so the execution section runs here too.__PAGEZEROstays atvmsize 0x100000000.rdtscpExecutionto the same file): merges cleanly andamd64_only_converterstill passes on x86_64 under Rosetta.The zero page change resolves what I reported earlier.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T10:38:40Z.
Thanks, this looks good. The branch is about 600 commits behind main, so please rebase onto current main and we'll run full CI (the macos-15-intel job is the one that proves the change).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T11:05:47Z.
Correction to my earlier comment: no rebase is needed (our CI merges the PR into current main before building), and macos-15-intel isn't part of the proof, because no CI lane runs the relinker tests on Intel macOS. Full CI is green on this head. The arm64 macOS job shows the CMake gate keeps
-pagezero_sizeoff arm64, and your Rosetta run (x86_64, 173/173) covers the x86-64 execution. Nothing more needed from you.