fix(libkernel): create the JIT shared memory backing on macOS hosts #6928
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6928"
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 jotitadev on 2026-10-16T19:29:23Z.
What
libkernel/DirectMemory/Jit.cppcreates the JIT shared memory backing withmemfd_create(..., MFD_CLOEXEC)on every non-Windows host (#3787), so the file does not compile on macOS, which has neither. On macOS the backing is now an unlinkedmkostempfile in the temporary directory, opened withO_CLOEXEC; the sizing, aliasing and mapping code is shared with Linux as before. Linux and Windows are unchanged: on Linux the only difference after preprocessing is the<filesystem>include, which moved out of the Windows block, and Windows includes the same headers.A file and not a
shm_openobject, as @yripper found in #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6179438307): pages mapped from ashm_openobject cannot be made executable, and the JIT needs executable aliases. The same unlinked temporary file is whatmacos-portuses for anonymousshm_openobjects.@yripper offered to review it (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6182812735).
Reported in #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6178527997); @mugurc asked for it as a separate PR (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6180063305).
Tested
macOS 27.2 on an Apple M2 Max, Xcode 27.0 (Apple clang 21.0.0, libc++). Base:
mainab9a47684. I compiled the file with the libkernel command line of the full build (-std=gnu++20 -fexperimental-library -fPIC -O3,core/libsandcore/libs/nid/includeon the include path), for-arch x86_64and-arch arm64:main:error: use of undeclared identifier 'MFD_CLOEXEC'(line 143) on both.A standalone program with the same backing code (
mkostemp+unlink+ftruncate, one shared read-write view and one shared read-only view switched to read-execute withmprotect) runs code written through the writable view, as x86-64 under Rosetta and as arm64. The descriptor hasFD_CLOEXECset. With an anonymousshm_openobject themprotectto read-execute fails withEACCES. One thing for the macOS mapping code, which is not part of this PR: on macOS 27.2 a singlemmapwithPROT_EXECof this file (or of any regular file) returnsEPERM, whilePROT_READfollowed bymprotectworks.Not run: libkernel does not link on macOS yet, so
guest_jit_shared_memorydoes not run there. Not built on Linux or Windows; the preprocessed code for both is unchanged apart from the include move above.Rebased onto
main1b1f8483c; the files this changes are unchanged since the tested base.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-16T19:43:26Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/DirectMemory/Jit.cppL142-143Some 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/libs/prx/libkernel/DirectMemory/Jit.cppcore/libs/prx/libkernel/DirectMemory/Jit.cppcore/libs/prx/libkernel/DirectMemory/Jit.cppPull request closed