fix(libs): spell inline assembly symbols for Mach-O hosts #4628
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4628"
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 mugurc on 2026-10-12T17:03:08Z.
What
C symbols in Mach-O carry a leading underscore, and the Mach-O assembler has no
.typeor.size. The inline assembly of libSceFiber, the signal mask helpers,getcontextand their tests spells every symbol the ELF way, so they do not link on macOS.APS5_ASM_SYMBOL(name)names a symbol the way the host assembler expects it.APS5_ASM_FUNCTION_END(name)closes a function:.sizeon ELF, nothing elsewhere.APS5_ASM_FUNCTION(name)has a macOS definition.SignalSets.cpp,UserContext.cpp,GuestSignalSets.cppandGuestUserContext.cppuse them instead of writing the spelling out. The signal helpers stillcall name@PLTon Linux.Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).
Tested
main,ninja,ninja libsandctest -j4on macOS ran 940 tests in the last full run (main2a5eca11c): 582 passed, 357 were skipped (no Vulkan loader in the environment, no guest address-space arena on macOS) and 1 failed. The failure isguest_socket_read_write, an existing test this series does not touch: after the peer has closed, the write that it expects to fail withEPIPEfails withECONNRESETorEAGAINon macOS, in 8 of 60 runs of the test alone.main33ae282e4), run on my fork: 960 tests on Linux and 966 on Windows pass (https://github.com/mugurc/AnyPS5/actions/runs/38256280627). I preprocessed the five files for Linux (-D__linux__ -U__APPLE__) from main and from this branch and compared the text of everyasm(...)block: identical forSignalSets.cpp,UserContext.cpp,GuestSignalSets.cppandGuestUserContext.cpp;libSceFiber/Export.cppdiffers only in whitespace and in where the directives sit, with the same directives and instructions.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-14T02:44:21Z.
Checked
core/libs/prx/libSceFiber/Export.cppon macOS 27.0.1 (Apple clang 21.0.0, SDK 27.0),xcrun clang++ -arch x86_64 -std=c++20 -fexperimental-library -c -I core/libs, againstmaina21d73733:main,-DMAP_STACK=0<inline asm>:4:5: error: unknown directive(also lines 27, 30)main+ this PR,-DMAP_STACK=0nm -mshows_Aps5FiberSwitchStack_nid_no_patch,_Aps5FiberTrampoline_nid_no_patchand_Aps5FiberMain_nid_no_patchexternal in__TEXT,__textmain+ this PRExport.cpp:300:112: error: use of undeclared identifier 'MAP_STACK'The asm change works on current
main, but the file still does not compile on macOS for a reason outside this diff: #4265 (merged 2026-10-13) maps fiber host stacks withMAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_STACK, and the macOS SDK'ssys/mman.hhas noMAP_STACK.macos-portand theci/macos-series*branches predate #4265.AI-assisted: yes (Claude Code)