Skip to content

feat: macOS on Apple Silicon host support (Rosetta 2 and MoltenVK) - #7332

Closed
ycarogabriel-lgtm wants to merge 363 commits into
boykopovar:mainfrom
ycarogabriel-lgtm:feat/macos-host-support
Closed

ycarogabriel-lgtm wants to merge 363 commits into
boykopovar:mainfrom
ycarogabriel-lgtm:feat/macos-host-support

Conversation

@ycarogabriel-lgtm

@ycarogabriel-lgtm ycarogabriel-lgtm commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

macOS on Apple Silicon as a host: relinked titles run as x86-64 Mach-O under Rosetta 2 and draw through MoltenVK. This branch brings the community's open macOS pull requests together on current main, runs their test suites on an Apple Silicon Mac, and adds the fixes that only showed up once everything ran together. It is meant as one reviewable picture of the port; each part can still be taken from its own pull request, and I am glad to split it further, reduce it onto whichever of the overlapping PRs the maintainers prefer, or close it.

Integrated pull requests (merged or cherry-picked, conflicts resolved against current main)

Ported from #7201 (marion909's port; each commit is co-authored by @marion909, as @blawesom suggested reconciling the two)

  • every SPIR-V loop gets its own continue block, because SPIRV-Cross otherwise folds a continue construct holding the loop body into the for increment and drops the header phi updates, which hung the GPU
  • the last 32 draws and dispatches are listed when the GPU fails, and APS5_DUMP_DRAW_SHADER dumps every stage of the draws that use one shader
  • HTILE fills remain on the GPU; the experimental CPU fill path was reverted after M4 Pro frame traces showed stalls
  • host frames without DWARF unwind info (the prx dylibs and system libraries carry only compact unwind) are stepped with the system libunwind; exception_runtime now runs on macOS
  • the Vulkan library is found by the loader's and MoltenVK's usual names, or named with ANYPS5_VULKAN_LIBRARY
  • zero-area rect-list rectangles are culled instead of faulting on MoltenVK

Not ported from #7201, with the reason: AF_UNIX seqpacket pairs emulated over datagram sockets (XNU reports ECONNRESET and EDESTADDRREQ where FreeBSD's seqpacket gives EOF and EPIPE, so they stay refused as the debt file says); sendto with an address on a connected UDP socket turned into send (FreeBSD returns EISCONN, which guest_udp checks); presenting from the host main thread and its own guest runtime base (this branch already has equivalent, tested paths from mugurc and yripper); the AvPlayer end-of-stream wake-up (generic logic gated on __APPLE__ with no test that reproduces the problem).

From the review and title runs on this PR (thanks @jotitadev and @imellag)

  • guest modules are opened RTLD_GLOBAL on the macOS host, because relinked modules bind imports by flat lookup and dyld leaves RTLD_LOCAL images out of it; this is what stopped FMOD Studio from loading in Planet of Lana and God of War: Sons of Sparta. The guest's own dlsym scope is unchanged and guest_dynamic_loader now checks it
  • fix(libc): give the scripting heap hooks blocks from libc's own heap #6842 (milescoviello) is merged in, which fixes the IL2CPP heap-hook crash at God of War's start-up
  • precise waits sleep three quarters of the interval on macOS and spin the rest, since XNU adds about a quarter of leeway to every timed sleep; precise_wait now passes 10 of 10 on the M1 (it was 3 of 6, and 0 of 10 on the M4 Pro)
  • tools/macos/setup-game.sh unwraps with tools/unwrap_self.py, which accepts both SELF magics, instead of a duplicate that refused 0xEEF51454 dumps
  • XNU's occasional reset on a full loopback accept backlog: a blocking loopback connect that gets ECONNRESET is retried on a new socket put on the same descriptor, as @jotitadev worked out and measured (guest_refused_connect 90/90 on his M2 Max against 0/30 without it); co-authored
  • repeated shutdown calls and a shutdown after the peer closed answer as FreeBSD does, from @jotitadev's diagnosis and test; co-authored
  • guest_socket_read_write: the closed-peer write loop rides out XNU's asynchronous reset, from @jotitadev's root cause and test-only fix; co-authored
  • the macOS-only CPU path for HTILE fills (ported from Macos port #7201) is reverted: @imellag measured it costing most of the frame in Planet of Lana (menu 8.2 against 21.9 fps with the fills on the GPU)
  • exact f32 add, subtract and multiply are emitted as inline fma on MoltenVK instead of SPIRV-Cross's optnone helper calls, as @imellag found and measured (menu 22.1 to 40.6 fps, GPU time per frame about halved in gameplay, eight fewer GPU failures); the commit (a243f0c93) is his change behind a SpirvTarget flag, as he proposed

Upstream tests that only ran on Linux, now run on macOS

  • named shared memory: shm_open/shm_unlink of named objects work on macOS as files in $TMPDIR/anyps5-shm (XNU's POSIX shm takes names of at most 31 characters and refuses fchmod, O_TRUNC and a second ftruncate); guest_named_shm_open, _lifecycle, _permissions and _concurrency run there. Guest mmap of files and shm objects now uses the Linux path on macOS, and EBADF for empty-vector writes on read-only descriptors matches the console
  • the guest errno is the host errno, and on macOS the C++ runtime can change it while releasing an exception, so the posix memory calls now set it again after their catch blocks (a refused mprotect reported ENOENT instead of EACCES)
  • sceLibcBacktraceGetBufferSize/sceLibcBacktraceSelf work on macOS (guest_backtrace); exception_c_cleanup and guest_getlogin_no_session run too
  • still Linux-only, with the reason: the audio port-lock and resampling tests and the two shm descriptor-reuse tests interpose host functions through ELF symbol preemption, which the two-level namespace does not allow; cpu_topology, guest_image_anonymous, guest_module_info and the ELF relinker execution tests read Linux-only interfaces (sched_getaffinity, /proc, ELF fixtures)

Fixes added here (XNU and Apple libc++ differences, each with a test that failed before)

  • sockets: a blocking loopback connect that XNU resets on a full accept backlog is retried on a new socket put on the same descriptor (the retry @jotitadev worked out and measured, co-authored); a repeated shutdown, or one after the peer closed, answers as FreeBSD does (his diagnosis and test, co-authored); SO_ACCEPTCONN through proc_pidfdinfo; shutdown(SHUT_RD) after the peer's SHUT_WR and on unconnected datagram sockets; urgent TCP data reported to poll through select; datagram byte counts from SO_NREAD in kevent, fstat and ioctl, because XNU's FIONREAD adds the sender address; IPv4-mapped answers dropped from IPv6 lookups
  • memory: JIT shared memory through a file kept linked while it is mapped; RWX file maps through RW then mprotect; munlockall unlocks each recorded range; macOS AGC page checks cache the logical protection after write-watch handling, following the page generation and access serial
  • libc: acosf through double; mktime before 1900; fflush leaves reading streams alone; host terminations forwarded to the guest's terminate; statics that guest threads still use at exit kept alive
  • files: getdirentries refuses plain files with EINVAL, as upstream now requires
  • SSL: Mbed TLS stays private to libSceSsl (hidden visibility, the macOS equivalent of --exclude-libs), so a program linking Mbed TLS keeps its own allocator
  • AGC on Metal: integer color targets (raw 32-bit exports bitcast to the target's signedness), per-sample sample masks, the input layer without the Geometry capability, image and sampler tables sized from update-after-bind limits, and the 11_11_10 float packing kept apart from raw integer exports
  • tests: the shared process-parameter fixture and the host import lifetime tests work on macOS, and the Bessel references use libm's jn/yn, as Apple's libc++ has no C++17 special math functions
  • build: libusb kept off pipe2, which the Xcode 27 SDK weak-links and macOS 26 lacks; the title launcher enables the nano allocator for Rosetta small allocations, with MallocNanoZone=0 available for comparison
  • web converter: macOS on Apple Silicon as a conversion target (Intel/Rosetta lowering forced on, macOS libraries optional)
  • docs/user/MACOS.md and tools/macos scripts to set up and launch a title
  • new upstream code on macOS: the performance overlay reads the private memory from TASK_VM_INFO; sRGB storage images keep their UNORM format because Metal encodes stores to sRGB textures; the AGC driver memory that feat(agc): link calls through the AGC FS table #6160 maps at 0xfe0000000 is unavailable on this macOS host, so the driver starts without it and says so (AGC debt file)

Known limits (in the debt files)

  • Metal has no 64-bit floats or 64-bit atomics and MoltenVK has no VK_KHR_shader_clock, so those GPU tests fail by design.
  • Shared direct memory is copied instead of imported, so GPU stores through FLAT/GLOBAL addresses do not reach it.
  • KosmicKrisp in Vulkan SDK 1.4.363.0 is arm64-only and cannot be loaded by the x86-64 process under Rosetta.

Investigation notes (kept out of the repository): with MoltenVK 1.4.2, inline exact f32 FMA removes eight of the earlier AGC failures. The remaining failures in the last full run on the M1 were:

  • f32_constant_factor_tininess and f32_denormal_flush: Metal floating-point limits
  • the four clip/cull distance tests: MoltenVK offers no shaderCullDistance
  • tessellation: the instanced patch in column 0 does not take its colour from the relative patch index
  • pixel_interlock: MoltenVK does not compile raster_order_group on an argument-buffer field
  • rect_list_indirect: differs from the direct draw
  • image_plane_bias_on_single_level_volume: the device has no min/max sampler reduction
  • pixel_sample_iteration: an attachment-less 4x draw runs the fragment shader per sample on MoltenVK although the Metal function asks for no sample input
  • agc_driver_pooled_buffer_range from test(agc): load the Vulkan loader with portability enumeration on macOS #7886 exposes a MoltenVK robust-buffer read that returns stale pooled bytes; the test was previously skipped on macOS
  • the new agc_driver_native_multisample_depth path passes but reports VUID-VkImageViewCreateInfo-imageViewFormatSwizzle-04465 under Vulkan validation, because MoltenVK reports imageViewFormatSwizzle unavailable
  • cross_workgroup_flag remains timing-sensitive: its waiting workgroup reads coherently, while the other workgroup's GLC store becomes a plain Metal store

Title runs by @imellag on an M4 Pro (details in the comments): Planet of Lana (PPSA19450) and God of War: Sons of Sparta (PPSA28997) stopped on the FMOD Studio load and, for God of War, the IL2CPP heap crash, both addressed above; with them they reach the menu and gameplay at about 10 and 15 to 27 fps, with background corruption that mostly follows the macOS write watch and is not solved here. ccleste (PPSA59322) stops on a pixel shader that reads barycentrics without a vertex shader before it, as in #5079. A native Metal backend and KosmicKrisp under a native arm64 host were assessed and are not part of this pull request.

Tested

  • Apple M1, macOS 26.6.2, x86-64 under Rosetta 2, AppleClang 21, MoltenVK 1.4.2 from Vulkan SDK 1.4.363.0. Release build with BUILD_TESTING=ON passed at b5fddb65c, with upstream main merged through 44e3389c8.
  • On the immediately preceding integration head 8ee809880, the non-GPU suite (ctest -E "^agc|video_?out|flip|display" -j4) passed 842/843. patched_libraries timed out on the cold run and passed when repeated alone; the five focused host tests passed. The serial MoltenVK AGC suite passed 794/808. Eleven failures are established MoltenVK/M1 limits or the documented pixel_sample_iteration gap; depth_bounds_state and graphics exposed merge errors that were fixed, and sgpr_pattern_fill_keys passed alone. The three fixed cases passed in a subsequent five-test run.
  • On integration head 43f0ba860, 13 focused tests passed: guest_interfaces_mac, guest_pthread_host_fault_mask, guest_raise_exception, guest_socket_read_write, guest_fstatfs, agc_driver_depth_bounds_state, agc_driver_graphics, agc_driver_pixel_barycentric_emulation, agc_driver_pooled_buffer_range, agc_driver_sgpr_pattern_fill_keys, agc_driver_stream_copy, and both gated-dispatch capture variants. After the subsequent seven-commit stdio merge, final head b5fddb65c built successfully and 10 focused stdio, descriptor, exception and host-fault-mask tests passed. Full suites were run before the last two upstream merges; the final head has build and focused-test coverage, not a repeated full suite.
  • The Apple-only host fault signal mask change follows Cloud-Multiplayer's issue #1 finding. The typed FragCoord load follows Alexius0815's M4 validation. Neither title behavior nor M4 validation was reproduced on this M1.
  • python3 tools/check_conventions.py --base origin/main: 0 errors. git merge-tree --write-tree HEAD origin/main equals the committed tree.
  • Linux and Windows were not tested locally; CI covers their paths. No title was run on this M1.

Checklist

🤖 Generated with Claude Code

ycarogabriel-lgtm and others added 30 commits October 17, 2026 00:12
sceNetCtlGetInfo picks the interface and gateway a title reports from
the host's default IPv4 route, which it read from /proc/net/route; macOS
has no /proc, so the first network query threw and guest_net_ctl
aborted. The same routes come from the kernel through
sysctl(NET_RT_DUMP), whose rt_msghdr records give the interface index
and gateway of each default route. sceNetCtlGetIfStat had no macOS
branch at all and would have thrown next; its byte counters come from
the if_data that getifaddrs attaches to each AF_LINK entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sceNetResolverStartNtoa6 asks the host for AF_INET6 addresses. FreeBSD
returns none for a name or literal that only has an IPv4 address, so a
title's IPv6 lookup of "127.0.0.1" fails with ENODNS and it falls back
to IPv4. macOS getaddrinfo maps such answers to ::ffff:a.b.c.d instead,
so the lookup succeeded with an address the title never expects and
guest_sce_net failed. Mapped answers are now skipped on macOS, which
leaves a real IPv6 address as the only success.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sceKernelMunlockall called the host munlockall and then forgot the
ranges it had locked. macOS does not implement munlockall (it fails with
ENOSYS), so the guest's pages stayed wired and the failure overwrote
the guest's errno, which a successful munlockall must leave alone;
guest_mlock failed on that. On macOS the ranges the runtime recorded are
now unlocked one by one with munlock, and errno is restored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t module

guest_flexible_memory_declared loads a fixture that stands for a
converted guest module with 512 MiB of data and checks that its
segments are charged against the flexible memory budget. On macOS the
runtime finds guest images through the __APS5DATA,__meta program headers
the relinker writes into every converted module; the fixture is built
directly as a dylib and had none, so it was not counted and the test
failed. The fixture now carries the same metadata, one PT_LOAD segment
over its data, as a relinked module would.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The macOS branch backed JIT objects with shm_open, but XNU never maps
POSIX shared memory executable (its maximum protection is read-write),
so running JIT code through the executable view died with SIGBUS and
guest_jit_shared_memory failed. The object is now a temporary file; XNU
only allows its first executable mapping while the file still has a
path, so it is mapped executable once before being unlinked. XNU also
refuses read-write-execute in a single mmap of a file, so such a view is
mapped read-write and then made executable with mprotect.

Under Rosetta, code rewritten through one view after another view ran
it keeps its old translation; that is recorded as debt rather than
tracked here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libusb's configure check finds pipe2 in the Xcode 27 SDK, which declares
it for macOS 27, and compiles its event pipe with it. The symbol is then
weak-linked, so on macOS 26 and earlier, where libSystem has no pipe2,
libusb_init_context calls a null pointer and every title that touches
libSceUsbd crashes (guest_usbd died with SIGSEGV). Presetting HAVE_PIPE2
off makes libusb use pipe and fcntl, which every macOS has. A scan of the
weak imports of all built prx libraries found no other symbol missing on
macOS 26.6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guest exit handlers and static destructors still map and protect memory
while the host runs its own static destructors. DoMprotect asks
GuestThreadStack whether the range is a thread stack, which takes
stackLock, a static std::mutex. glibc keeps a destroyed mutex usable,
but libc++ on macOS destroys it with pthread_mutex_destroy, so a late
mprotect threw "mutex lock failed: Invalid argument" and
guest_memory_lifetime failed. The lock and the two stack maps are now
allocated once and never destroyed, as the write watch and the direct
memory state already are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ate on macOS

When an ITIMER_REAL expiry cannot be handled, the alarm thread throws,
and a guest that installed std::set_terminate expects its handler to run
with that error as the current exception, which is how titles report
fatal errors. On Linux the host and the guest share libc.prx's C++
runtime, so that is what happens. On macOS host code keeps libc++abi,
so the error ended in libc++abi's own terminate, the guest handler never
ran and guest_itimer failed. The macOS alarm thread now catches the
error and rethrows a copy through libc.prx's __cxa_throw, whose
terminate path calls the guest handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on watch

agc_write_tracking failed on macOS for two reasons that are properties
of the macOS write watch, not wrong results:

- ImportWatched opens the whole range for host writes during an import,
  because Metal keeps the protection a page had when it was imported. A
  watch based on page protection then cannot tell a page the import
  rewrote with the same bytes from one it never touched, so both count
  as possibly touched by the CPU. The block state stays exact; only the
  CPU mark is conservative, which costs a later comparison and loses no
  write. The test keeps the exact mark for Linux and Windows, and the
  limit is recorded as debt.
- The test's ProtectPage called mprotect directly. On macOS the driver
  reads a watched page's guest protection from the watch, which guest
  mprotect updates through DoMprotect; the helper bypassed that, so the
  driver still saw the page as readable. The helper now tells the watch,
  as DoMprotect does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The failure classification was written from reports on issue boykopovar#1 and left
the local run as pending, so it could not tell which causes apply to
this tree. The run on an M1 under Rosetta gives 525 of 590 passing and
30 failures, and the device's own feature list separates real device
limits (cull distance, min/max sampler reduction, geometry shaders) from
failures this tree can fix: the image tables are sized from the plain
per-stage limits although MoltenVK offers a million descriptors through
update-after-bind, and the recompiler asks for the Geometry capability
only to read the layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Metal

A fragment shader that reads the layer declared the Geometry capability,
which MoltenVK cannot enable because Metal has no geometry shaders, so
every such pipeline was refused ("SPIR-V requires unsupported device
capability 2") and six AGC tests failed on Apple GPUs. SPIR-V lets the
same input be read under ShaderViewportIndexLayerEXT, which MoltenVK
offers. The recompiler now uses it only when the device has the
extension and no geometry shaders; a device with geometry shaders, or
without the extension, still gets Geometry as before.

On an M1 through MoltenVK 1.4.2, layered_volume_draw,
layered_volume_vertex, layered_volume_vertex_no_gpl,
pixel_ancillary_word and relative_ancillary now pass;
sample_mask_multisample gets past pipeline creation and fails on its
per-sample mask instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous change mapped the JIT file executable once and then
unlinked it, which made guest_jit_shared_memory pass alone but fail in
about every second run: XNU refuses executable mappings of an unlinked
file intermittently, even while an earlier executable mapping of it is
still alive. Measured natively, 5 of 30 launches failed with the early
mapping kept and none of 30 with the file left linked. The file now
stays linked until the JIT object's last descriptor closes, when no new
mapping can be made, and is unlinked then; 20 consecutive runs pass and
leave no file behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… when needed

Bindless image and sampler tables were sized from the plain per-stage
limits, after reserving the fixed typed heaps (1792 sampled images, 32
samplers). MoltenVK reports plain limits of 256 sampled images and 16
samplers per stage, so both tables got a capacity of 0 and every title
using them stopped with "image tables need runtimeDescriptorArray ...
which the device lacks", although the M1 has those features and allows
a million sampled images and 1024 samplers per stage in update-after-bind
sets.

When the plain limits leave no room and the device supports sampled
image update-after-bind, the tables now use that mode: the feature is
enabled at device creation, the table bindings carry the
update-after-bind flag, their sets are created update-after-bind, and
layout validation and set allocation check each descriptor type against
its update-after-bind limit, as Vulkan requires for such sets (before,
only storage buffers used it). Devices whose plain limits already fit a
table keep the plain sets.

On an M1 through MoltenVK 1.4.2, bindless_images, image_sint8,
image_table, image_table_cache_bounds and image_table_reuse now pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous change checked update-after-bind sets against the
update-after-bind limit of each descriptor type alone. Vulkan requires
those limits to be at least the plain ones, but a context can carry only
some of them: agc_driver_graphics builds one with only the storage buffer
update-after-bind limits, so its sampled images were checked against 0
and the test failed. An update-after-bind set is now checked against the
larger of the two limits, which is the update-after-bind one on any
conforming device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The run after the two driver fixes needs to be on record next to the
first one, with the two failures that are not caused by them: a timeout
close to the 30 s limit and a write-tracking test that now fails on the
unchanged sources too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Metal

A fragment shader that reads the layer declared the Geometry capability,
which MoltenVK cannot enable because Metal has no geometry shaders, so
every such pipeline was refused ("SPIR-V requires unsupported device
capability 2") and six AGC tests failed on Apple GPUs. SPIR-V lets the
same input be read under ShaderViewportIndexLayerEXT, which MoltenVK
offers. The recompiler now uses it only when the device has the
extension and no geometry shaders; a device with geometry shaders, or
without the extension, still gets Geometry as before.

On an M1 through MoltenVK 1.4.2, layered_volume_draw,
layered_volume_vertex, layered_volume_vertex_no_gpl,
pixel_ancillary_word and relative_ancillary now pass;
sample_mask_multisample gets past pipeline creation and fails on its
per-sample mask instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… when needed

Bindless image and sampler tables were sized from the plain per-stage
limits, after reserving the fixed typed heaps (1792 sampled images, 32
samplers). MoltenVK reports plain limits of 256 sampled images and 16
samplers per stage, so both tables got a capacity of 0 and every title
using them stopped with "image tables need runtimeDescriptorArray ...
which the device lacks", although the M1 has those features and allows
a million sampled images and 1024 samplers per stage in update-after-bind
sets.

When the plain limits leave no room and the device supports sampled
image update-after-bind, the tables now use that mode: the feature is
enabled at device creation, the table bindings carry the
update-after-bind flag, their sets are created update-after-bind, and
layout validation and set allocation check each descriptor type against
its update-after-bind limit, as Vulkan requires for such sets (before,
only storage buffers used it). Devices whose plain limits already fit a
table keep the plain sets.

On an M1 through MoltenVK 1.4.2, bindless_images, image_sint8,
image_table, image_table_cache_bounds and image_table_reuse now pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous change checked update-after-bind sets against the
update-after-bind limit of each descriptor type alone. Vulkan requires
those limits to be at least the plain ones, but a context can carry only
some of them: agc_driver_graphics builds one with only the storage buffer
update-after-bind limits, so its sampled images were checked against 0
and the test failed. An update-after-bind set is now checked against the
larger of the two limits, which is the update-after-bind one on any
conforming device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…osts

sceKernelGetLibkernelTextLocation and
sceKernelInternalMemoryGetModuleSegmentInfo were only compiled outside
macOS, so a title whose bundled libc.prx imports the latter (the DOOM
homebrew PPSA99666 does) stopped in dyld before main with "symbol not
found in flat namespace '_-YTW+qXc3CQ'". Both only need the main
program's first load segment, which the macOS dl_iterate_phdr emulation
already lists from the relinker's program header metadata, so they now
read it from there.

With this, PPSA99666 relinked with --macos --to-rosetta starts on an M1,
passes its launcher, loads doom1.wad and renders the episode menu over
the demo through MoltenVK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and DOOM

The six signed-zero failures only go away with a MoltenVK built on a
SPIRV-Cross that has boykopovar#2704, which no MoltenVK release pins yet, and the
rebuilt library is silently ignored when the SDK's copy comes first in
DYLD_LIBRARY_PATH. Recording the build steps, the loading pitfall, the
resulting 15 failures and the first title that renders keeps the
results reproducible on another Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two pipelines that conforming Vulkan drivers accept fail on Apple GPUs
through MoltenVK.

Raw 32-bit exports into integer targets: the 32_R, 32_GR, 32_AR and
32_ABGR export formats store the exported bits as they are, so the
recompiler declares a float4 output and a game may point it at an
R32_UINT or other integer target. Vulkan leaves the converted value
undefined but drivers store the bits; Metal refuses the pipeline
("output of type float4 is not compatible with a MTLPixelFormatR32Uint
color attachment"). ExportPackings now reports RawUint or RawSint for
an unpacked integer target, and the fragment output specialization that
already retypes 10_11_11 outputs bitcasts such an output to uint4 or
int4, which stores the same bits everywhere. Validation accepts the
retyped output with the signedness of the target; the existing check
that a 10_11_11 module is refused for an unpacked target now uses a
float target, since on an R32_UINT target a uint4 output is correct.

Uniform sample masks under per-sample shading: a uniform partial mask
went only to the pipeline's pSampleMask, which MoltenVK emulates with a
constant sample_mask output that Metal ignores when the fragment runs
per sample, so masked samples were written. When the pixel inputs
select per-sample shading the uniform mask now also goes to the
shader's existing per-quad mask path, and that path keeps only the
current sample's bit (SampleId) of the input coverage, which is all a
conforming driver reports there anyway while Metal reports the whole
pixel.

On an M1 with MoltenVK and SPIRV-Cross boykopovar#2704, front_face_all_bits and
sample_mask_multisample pass; the full suite has 576 of 590 passing and
all 640 non-GPU tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the integer target and per-sample mask fixes the suite is at 576
of 590 on an M1, and DOOM reaches gameplay in E1M1. The remaining
failures are grouped by cause so the next work goes to the ones this
tree can fix (host memory write-back, tessellation) and not to device
limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings the Codex and fork sessions' Metal work into the fork's main: the native Metal backend and KosmicKrisp assessments, the MoltenVK GPU results on an M1 (576 of 590 passing) with the 14 remaining failures classified, the SPIRV-Cross boykopovar#2704 MoltenVK build notes and the DOOM gameplay run. Its three code commits are already on macos/integration under other hashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds macOS on Apple Silicon as a target of the online converter (Mach-O through Rosetta 2), so the fork's main carries the user-facing entry point together with the runtime it needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fork was 500 commits behind boykopovar/AnyPS5. Merging rather than
rebasing keeps the published history and links valid.

Conflicts, where both sides changed the same code:
- Image registration: upstream split it into collectImagePages and
  registerImagePages and registers guest modules on demand. Its
  structure is kept; on macOS the main registration still reads the
  Mach-O segments, because dl_iterate_phdr there only reports relinked
  images, and per-module registration returns early for an image that
  registration already covers.
- DoMprotect: upstream's on-demand module registration runs outside
  macOS; macOS keeps TrimToRegistered for dyld's 4 KiB slides.
- DPP lane reads: upstream's EmitSubgroupShuffleInHalf is used, with the
  convergent store Metal needs when the host has subgroups.
- Descriptor limits: the update-after-bind limits from this branch with
  upstream's detailed sampler limit errors.
- GuestMemory test, BUILD.md and the libkernel debt: both sides kept.

Upstream code that did not build on macOS: PF_R added to the macOS ELF
types, the image search in DirectMemory and the link_map unregister in
dlclose limited to the hosts that have them. ZArchive and zstd are new
submodules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Path resolution now asks the app archive whether a path is inside
app0.zar, which locks the archive state's mutex. The state and the
descriptor table were ordinary statics, destroyed while guest exit
handlers still resolve paths. glibc keeps a destroyed mutex usable, so
Linux never noticed; libc++ on macOS destroys it, and guest path calls
during exit threw "mutex lock failed: Invalid argument"
(guest_path_lifetime). They are now allocated once and never destroyed,
like the path aliases and the working directory beside them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
connect on a listening stream socket must fail with EOPNOTSUPP whatever
the address, as FreeBSD checks the listening state first. The runtime
does that check, but asks the host through getsockopt(SO_ACCEPTCONN),
which XNU rejects; the socket never looked like a listener, the address
family check ran instead and returned EAFNOSUPPORT, and
guest_socket_connect_listening failed. The state now comes from the
kernel's so_options through proc_pidfdinfo, as getsockopt(SO_ACCEPTCONN)
already does on macOS. The query lives in SocketOptions.cpp because
libproc's headers define EVFILT_* macros that clash with Equeue.hpp in
Udp.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on macOS

On FreeBSD and Linux, sceNetShutdown(SHUT_RD) on a datagram socket that
was never connected still wakes a thread blocked in recvfrom, which
returns 0, and later receives return 0 at once. Titles stop their
network threads that way. XNU fails that shutdown with ENOTCONN and
changes nothing, bound or not (measured), so the blocked thread never
returned and guest_sce_net timed out.

On macOS the read shutdown is now emulated when the host refuses it:
the socket is bound to an ephemeral port if it had none and receives an
empty datagram from a loopback sender, which wakes the blocked reader
with 0, and later receives on that socket run without blocking and
return 0 once nothing is queued. The shutdown still reports ENOTCONN, as
Linux does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Linux, libc.prx is the C++ runtime of both the host code and the
guest, so a fatal host error (an exception leaving a noexcept export, an
unhandled error on a runtime thread) reaches the terminate handler the
title installed, which is how titles report fatal errors. On macOS host
code keeps libc++abi, so such errors ended in libc++abi's own terminate
and the guest handler never ran: guest_kernel_app_archive_mmap failed,
and guest_itimer needed a special case in the alarm thread.

libc.prx now installs a libc++abi terminate handler on macOS that
rethrows the current host std::runtime_error or std::logic_error
through libc.prx's __cxa_throw, so the guest's terminate path runs with
it as the current exception, and calls the guest terminate directly for
anything else. This covers every host thread, so the alarm thread's
special case is removed, and the uncaught-exception report is again the
"what():" form that guest_host_standard_error expects on every host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… macOS

Upstream added two checks at the top of sceKernelGetdirentries on Linux
and Windows: a socket is EINVAL, and a file read from app0.zar throws
not implemented instead of listing a placeholder descriptor. The macOS
variant, which lists through a separate descriptor because APFS leaves
d_seekoff at 0, is a separate function and did not get them, so
guest_kernel_app_archive_archive failed on macOS. It now starts with the
same two checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
Keeps the macOS port current with 260 upstream commits.

- Draws whose pixel shader reads barycentrics take upstream's
  tessellation emulation when the device has no geometry shaders (the
  MoltenVK case); the emulation test keeps the fork's built-in path and
  only skips when none of the three paths exists. These resolutions are
  the ones the macOS pull request (boykopovar#7332) already carries.
- Rect lists take upstream's multi-distance clip forwarding, so the
  fork's single-distance validation (f32[1]) is dropped; it refused the
  new arrays.
- SpirvTarget keeps both the fork's fragmentBarycentricBuiltins and
  upstream's robustBufferAccess2; Time.cpp keeps both platforms'
  includes; the force-TLS-destructor test stays off macOS beside
  upstream's new inet address test; the new flexible memory tests run on
  every host.
- GuestMath's Bessel references come from libm's jn and yn on macOS,
  whose libc++ has no C++17 special math functions.
- The macOS relinker fixtures spell their attributes with [[gnu::]], as
  in the pull request, so check_conventions accepts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
…on macOS

Relinked Mach-O modules bind every import by flat lookup, and dyld leaves images opened RTLD_LOCAL out of that lookup, while on the console and in ELF a module's dependencies resolve its imports whatever mode they were loaded with. sceKernelLoadStartModule and a plain dlopen open modules locally, so libfmodstudio could not find the libfmod it depends on ('symbol not found in flat namespace'), the load failed only through dlerror and both Planet of Lana (PPSA19450) and God of War: Sons of Sparta (PPSA28997) waited forever, as imellag traced on boykopovar#7332 and checked by opening modules globally.

On macOS the host dlopen now always uses RTLD_GLOBAL. The guest's own scope is unchanged: dlsym with the default handle skips the image of a module the guest opened without RTLD_GLOBAL, which GuestDynamicLoader now checks on every host. The remaining difference is in the libkernel debt file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
…ocks from libc's own heap (@milescoviello)

Brings the open upstream fix for the IL2CPP scripting heap hooks: without it God of War: Sons of Sparta (PPSA28997) ends with SIGSEGV at start-up through the IL2CPP free and abort chain, as imellag traced on boykopovar#7332, where boykopovar#6842 merged cleanly and its tests and the title check passed on macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
Keeps the fork's main on the same upstream base as the macOS pull
request branch (boykopovar#7332), so the two do not drift apart and later
community macOS merges resolve against current code. The merge was
conflict-free here and leaves the code identical to the PR branch,
including upstream's port-zero connect check, which the PR branch had
to restore by hand after its boykopovar#7559 merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
…#7332

The fork's main had fallen behind the pull request branch on two
fronts: the 169 upstream commits (53 on its first-parent line) since the last sync, and the commits
made on the PR branch from the M4 Pro review (the precise wait capped
at 6 ms of spin above 24 ms, the guest scope test loading a real .prx,
the 0xfc0000000 range attributed to the macOS host rather than
Rosetta) and the web converter's macOS batch fixes. Each conflict is
resolved to the PR branch's version, which already combines upstream
with the macOS paths, and the files the PR branch changed outside the
conflicts are taken from it too. The relinker CLI now keeps
--macos-fixed-base beside upstream's --patches and --verify-patches,
and refuses it in verify mode like the other fixed bases.

The code is identical to the PR branch afterwards; only the fork's own
notes (docs/metal-exploration, the macOS validation section) differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
Brings the fork's main to the state of boykopovar#7332 after the upstream merges
of today (main at d71853c), so the fork keeps the same code as the
pull request. That includes the empty-vector write check living beside
main's GPU flush in Stdio.cpp, the libkernel debt lines from both
sides, and the multisample retirement test that skips storage promotion
on devices without multisampled storage images.

The fork keeps its own layout: the macOS validation section in
TechnicalDebt.md and the guide under tools/macos/README.md, so the
identical copy at docs/user/MACOS.md that the PR branch carries is
removed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
Keeps the fork's main on the state of boykopovar#7332 after it took 183 more
upstream commits: the macOS build fixes main's new code needed (host
stack pages, std::atomic<shared_ptr>, the main stack test), the retry
of loopback connects XNU resets, worked out by jotitadev, and the GPU
test fixes for MoltenVK. The fork's own notes and its guide under
tools/macos stay as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycarogabriel-lgtm added a commit to ycarogabriel-lgtm/AnyPS5 that referenced this pull request Oct 25, 2026
Keeps the fork's main on the state of boykopovar#7332 after it took 118 more
upstream commits: the serialization version that main's depth range
remap and this branch's barycentric flag now share, the shutdown
answers jotitadev traced on the M2 Max, and boykopovar#7706's refusal of
branches into trapped GS instructions. The fork's own notes and its
guide under tools/macos stay as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build ci .github docs libc libkernel needs rebase Conflicts with main, rebase needed prx relinker shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.