Linux and macOS support
This adds linux-x64 and osx-x64 (under Rosetta 2) as hosts. Since the CPU backend executes guest x86-64 code natively, both targets run the whole process as x86-64. The Windows-only host primitives get platform-dispatched equivalents; Windows paths are untouched.
Rough breakdown by commit:
Host memory / TLS / ABI layer. New HostMemory facade with Win32 semantics over mmap/mprotect/munmap, plus a shadow region table to answer VirtualQuery. Everything that used kernel32 P/Invokes goes through it now. Exact-address mappings use MAP_FIXED_NOREPLACE on Linux and a hint-and-verify mmap on macOS — plain MAP_FIXED there happily maps over the .NET JIT heap, which under Rosetta surfaces as "no code fragment associated with the given arm pc". PosixHostStubs provides pthread-backed TLS and Win64-ABI stubs for the kernel32 helpers the backend embeds into emitted code (TlsGetValue, QueryPerformanceCounter, ...), with a Win64→SysV thunk for managed callbacks. Guest stack/TLS/stub regions move from 0x7FFx down to 0x6FFx, since dyld and the Rosetta runtime live up there.
Signal bridge. sigaction handlers for SIGSEGV/SIGBUS/SIGILL rebuild the Win64 EXCEPTION_POINTERS/CONTEXT view from the platform mcontext (offsets checked against Darwin and glibc headers) and run the same recovery chain as the VEH path, then write the repaired registers back so sigreturn resumes the guest. One Rosetta quirk cost a while: the whole recovery path has to be executed once with fabricated inputs before the handlers are installed — a handler that has never been translated is silently never invoked and the faulting instruction retries forever. Unrecovered faults chain to the runtime's handler so .NET keeps its managed exceptions.
Guest memory layout fixes. libc.prx reads below the TLS base (fault was at TLS − 0x1708), so the prefix mapping below it grows to 64KB on POSIX. Plus the mmap fix above and moving the direct-memory search base off 4GB, which is the Mach-O image base on macOS.
macOS presenter. AppKit only runs on the real main thread (SIGILL from NSUpdateCycleInitialize otherwise), so on macOS emulation moves to a worker thread and the presenter posts its window loop to a pump on the main thread. MoltenVK needs VK_KHR_portability_enumeration/subset, and robustBufferAccess2 has to be gated on actual device support — Metal doesn't have it and vkCreateDevice failed. Pad exports also stop calling user32 GetAsyncKeyState off Windows and read the window's keyboard through Silk.NET instead.
CoreAudio + MoltenVK loading. sceAudioOut ports play through an AudioQueue backend on macOS, behind the same interface as the WinMM path. The presenter feeds vkGetInstanceProcAddr straight into glfwInitVulkanLoader, so no DYLD_LIBRARY_PATH is needed; scripts/fetch-macos-moltenvk.sh stages the official universal dylib next to the build.
ALSA audio for Linux. sceAudioOut ports play through libasound on Linux, behind the same interface. The PCM device opens in blocking mode with ~170ms of device buffer (the time-equivalent of the 32KB queue the other backends keep), so snd_pcm_writei itself provides the backpressure pacing. The "default" device routes through PulseAudio/PipeWire on desktops; SHARPEMU_ALSA_DEVICE overrides it, and a missing libasound or device falls back to the silent path.
TLS patch register preservation (all platforms, including Windows). The handler that replaces guest mov reg, fs:[...] instructions clobbered rcx/rdx/r8–r11 and the arithmetic flags around its TlsGetValue call, so guest code holding live values across a TLS access deterministically computed garbage. Now saved/restored. Same commit also switches the present blit to linear filtering for fractional scales, stops ClampViewport from trimming the guest viewport (the scissor already confines rendering), and adds a set of env-gated rendering diagnostics.
Screenshot
Dreaming Sarah [PPSA02929] in gameplay on macOS (MacBook Pro M4, Rosetta 2):
Testing
macOS: runs to gameplay out of the box — window, keyboard and audio all work with no environment setup.
Linux: not fully tested, fair warning. I only have headless amd64 Docker containers (on an ARM Mac via Rosetta for Linux), so what's verified is: the guest boots, signal recovery works, the game runs its main loop through millions of imports without faults, and the ALSA port opens and streams sceAudioOutOutput against the null device for a full run (with graceful silent fallback when no device exists). Real speakers and the display side have not been exercised — keyboard input goes through the presenter window, which should work on a Linux desktop but I couldn't try it. If someone can run this on real Linux hardware I'd appreciate it.
Windows: paths unchanged, x64 and arm64 builds clean.
Where is CI for Mac/Linux builds?
Added in 316dda3, but there's some issues with glfw, fixing right now
Added in 316dda3, but glfw doesn't get embedded in the binary, will push new commit with a fix soon
Yes, glfw needs to stay alone with binary file. This problem will be fixed when I switch to SDL Window. Also, as far as I can see right now, Mac and Linux builds do not give release builds, this should produce separate release zips just like win64.
This is what I see for now, I will look at this PR in detail again later. Nice work.
Since the macOS target currently depends on Rosetta 2 and an x64 process, would it be worth failing early with a clear diagnostic when Rosetta is unavailable or the process starts under an unsupported architecture? That could make startup failures easier to distinguish from MoltenVK, signal-handler, or guest-memory problems. A small host-capability check could also document the supported macOS execution model in one place.
Since the macOS target currently depends on Rosetta 2 and an x64 process, would it be worth failing early with a clear diagnostic when Rosetta is unavailable or the process starts under an unsupported architecture? That could make startup failures easier to distinguish from MoltenVK, signal-handler, or guest-memory problems. A small host-capability check could also document the supported macOS execution model in one place.
Absolutely
@par274 The glfw problem is fixed in bbc5243 — the KeepGlfwOutsideSingleFile target only matched the Windows filename (glfw3.dll), so libglfw.3.dylib/libglfw.so.3 were getting embedded where Silk.NET's loader can't find them. It now matches the lib-prefixed names too, and the POSIX builds keep glfw loose next to the binary exactly like win64. Verified by downloading the CI-built osx-x64 archive and running it to gameplay on a Mac.
Releases added in 089d0ec: linux-x64 and osx-x64 now publish per-RID releases with the same tag scheme as win64 (<rid>-<ref>-<sha>), on main pushes and manual dispatch. One note: they're tar.gz rather than zip so the executable bit survives extraction. The job is gated the same way as the win64 release, so it hasn't fired on this branch — worth a manual dispatch after merge to confirm.
@hiSandog Added in b94f410. CLI mode now checks the process architecture before any emulation starts and exits with a message naming the supported model (x86-64 process; osx-x64 under Rosetta 2 on Apple Silicon, including the softwareupdate --install-rosetta hint). The GUI-only path stays usable in an arm64 process. The one case that can't be diagnosed in-process is Rosetta being absent entirely — the x64 binary never launches, so no code of ours runs; the error message and the check's doc comment document that model in one place.
We need a Linux tester
Please rebase onto main and resolve the merge conflicts
My game doesn't display on Linux sharpemu_dreaming_sarah_full_fps.log
sharpemu_dreaming_sarah_summary.log sharpemu_dreaming_sarah_dump_run.log
My game doesn't display on Linux sharpemu_dreaming_sarah_full_fps.log
sharpemu_dreaming_sarah_summary.log sharpemu_dreaming_sarah_dump_run.log
Can confirm this, game does not output video but audio seems to be working.
The PR owner would know better, but there's probably a glfw issue; the window isn't drawing.
@j92580498-max Your log shows the window and swapchain working — frames present at ~6 fps (presented_fps only ticks after vkQueuePresentKHR succeeds), so it's not a glfw/window issue. What stands out is that your GPU reports two features missing that the shaders need:
GPU does not support shaderStorageImage(Read|Write)WithoutFormat GPU does not support VK_KHR_maintenance8
When the guest shaders hit those, they fail and the frame renders blank while audio keeps working. To see which GPU/driver the loader is using, can you paste the output of:
vulkaninfo --summary | grep -iE 'deviceName|driverName|driverInfo|deviceType|apiVersion'
(no vulkaninfo? sudo apt install vulkan-tools, or pacman -S / dnf install equivalent)
That'll tell us your exact GPU + driver version — with those two features it's likely a driver/version thing, and knowing the driver points at whether an update or a different Mesa/driver stack fixes it.
@TheLeCrafter can you upload your logs?
Please rebase onto main and resolve the merge conflicts
done
Once the Linux side is complete, I'll merge it. After merging that, I'll look at the SDL Windowing part.
@j92580498-max Your log shows the window and swapchain working — frames present at ~6 fps (presented_fps only ticks after vkQueuePresentKHR succeeds), so it's not a glfw/window issue. What stands out is that your GPU reports two features missing that the shaders need:
GPU does not support shaderStorageImage(Read|Write)WithoutFormat GPU does not support VK_KHR_maintenance8
When the guest shaders hit those, they fail and the frame renders blank while audio keeps working. To see which GPU/driver the loader is using, can you paste the output of:
vulkaninfo --summary | grep -iE 'deviceName|driverName|driverInfo|deviceType|apiVersion'
(no vulkaninfo? sudo apt install vulkan-tools, or pacman -S / dnf install equivalent)
That'll tell us your exact GPU + driver version — with those two features it's likely a driver/version thing, and knowing the driver points at whether an update or a different Mesa/driver stack fixes it.
@TheLeCrafter can you upload your logs?
This is the log I copied from the console with log level info. Should I also post log level debug or trace?
The RTX 5080 log is a different issue from the earlier reports — that GPU has every feature, and frames are presenting fine. The tells are libdecor-gtk.so failed to init and the 1.4x-scaled window, both meaning a Wayland session: GLFW's native Wayland backend doesn't reliably map the Vulkan window with some drivers (NVIDIA especially), so the surface presents but stays invisible while audio works.
Pushed a fix (eed66af): on a Wayland session that also has an X server available, the presenter now steers GLFW to X11/XWayland before it initializes. SHARPEMU_ENABLE_WAYLAND=1 opts back into native Wayland. I don't have a Wayland box to test on, so if whoever hit this can grab the next build (or run today's with WAYLAND_DISPLAY= ./SharpEmu <game> to force XWayland manually) and confirm the window shows, that'd verify it.
Tried your newest fix, still no display and still the same libdecor-gtk.so error.
Thanks for testing. The libdecor error still showing is the useful part — libdecor is Wayland-only, so GLFW was still on Wayland, meaning my previous env-var approach did not actually switch it.
Pushed a better fix (f65320e): it now uses GLFW’\s real backend selector — glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11) before init — instead of the env trick. It also logs GLFW windowing platform in use: <X11|Wayland> right after the window comes up, so we can see exactly what GLFW picked.
Could you grab the next CI build and paste two things from the new run:
- the
GLFW windowing platform in use: ...line - the output of
echo "$DISPLAY / $XDG_SESSION_TYPE"
If it shows X11 and the window appears — fixed. If it still shows Wayland, or $DISPLAY is empty (no XWayland to fall back to), that points at exactly what to do next.
[LOADER][INFO] GLFW windowing platform in use: X11
and my display and session type are :0 / wayland
Found the actual root cause — and it was on our side, not the driver. GLFW requires window creation and event processing on the process main thread on every platform (GLFW intro guide, thread-safety); X11 in particular has a single event queue that must be serviced from the main thread, and a window created/polled on another thread may never map. That is exactly "the game runs — audio, imports, even Vulkan present — but no window ever appears."
macOS already ran the window on the main thread (AppKit needs it) and Windows is fine (per-thread event queues); Linux was the gap — it spawned a background thread for the presenter. Pushed e13a97d: it extends the existing main-thread pattern to Linux (emulation on a worker thread, the window loop on the main thread).
Verified macOS still boots to its window and the Linux headless path runs clean with no deadlock, but I don't have a Linux desktop to see the actual window — @j92580498-max / @TheLeCrafter / whoever has the RTX 5080, could you grab the next build and check if the window shows now? With this fix native Wayland may also work again; if you were forcing XWayland you can drop it.