fix(libSceFiber): map fiber host stacks on hosts without MAP_STACK #5735

Merged
mugurc merged 1 commit from upstream-pr/5735 into main 2026-10-15 13:05:24 +00:00
mugurc commented 2026-10-14 08:34:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mugurc on 2026-10-14T08:34:38Z.


What

AllocateHostStack in libSceFiber maps the fiber host stack with MAP_STACK since #4265. The macOS SDK's sys/mman.h defines MAP_NORESERVE but not MAP_STACK, so Export.cpp stops with use of undeclared identifier 'MAP_STACK' on macOS, as @thuanquang found on #4628.

The mapping flags are built in a local variable, and MAP_STACK is added only where the host defines it. Linux keeps the same flags, and the function is compiled only outside _WIN32, so Windows does not change.

Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).

Tested

  • macOS 26.5.1, Apple M5 Max, Apple clang 21, -arch x86_64 -std=c++20 -fexperimental-library, main 107190d11 (which has #4628) with this change: core/libs/prx/libSceFiber/Export.cpp compiles. On main without it the same command stops with the MAP_STACK error.
  • Not run: the fiber tests on macOS. The rest of the macOS series is still open, so a macOS build of main does not link the guest tests yet.
  • Linux and Windows are not built. On Linux MAP_STACK is defined by glibc, so the flags are the same as before, and the function sits in the branch that _WIN32 does not compile.
  • python3 tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4855171642 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5735). Originally posted by [mugurc](https://github.com/mugurc) on 2026-10-14T08:34:38Z. --- ### What `AllocateHostStack` in libSceFiber maps the fiber host stack with `MAP_STACK` since #4265. The macOS SDK's `sys/mman.h` defines `MAP_NORESERVE` but not `MAP_STACK`, so `Export.cpp` stops with `use of undeclared identifier 'MAP_STACK'` on macOS, as @thuanquang found on #4628. The mapping flags are built in a local variable, and `MAP_STACK` is added only where the host defines it. Linux keeps the same flags, and the function is compiled only outside `_WIN32`, so Windows does not change. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298). ### Tested - macOS 26.5.1, Apple M5 Max, Apple clang 21, `-arch x86_64 -std=c++20 -fexperimental-library`, `main` 107190d11 (which has #4628) with this change: `core/libs/prx/libSceFiber/Export.cpp` compiles. On `main` without it the same command stops with the `MAP_STACK` error. - Not run: the fiber tests on macOS. The rest of the macOS series is still open, so a macOS build of `main` does not link the guest tests yet. - Linux and Windows are not built. On Linux `MAP_STACK` is defined by glibc, so the flags are the same as before, and the function sits in the branch that `_WIN32` does not compile. - `python3 tools/check_conventions.py --base origin/main` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 12:09:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:02Z.


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.

Pull request Shared files not compared
#6222 core/libs/prx/libSceFiber/Export.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191693580 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5735#issuecomment-6191693580). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:09:02Z. --- <!-- pr-overlap --> 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. | Pull request | Shared files not compared | |---|---| | #6222 | `core/libs/prx/libSceFiber/Export.cpp` |
adriadam10 commented 2026-10-15 12:19:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T12:19:32Z.


Checked the diff: MAP_STACK is now added only where the host defines it, so Linux keeps the same mmap flags and Windows is untouched (function is outside _WIN32). Built on main + this PR and libSceFiber ctest passes (1/1). macOS compile not reproducible here; relying on the macOS check in the description. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191884352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5735#issuecomment-6191884352). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T12:19:32Z. --- Checked the diff: `MAP_STACK` is now added only where the host defines it, so Linux keeps the same mmap flags and Windows is untouched (function is outside `_WIN32`). Built on main + this PR and libSceFiber ctest passes (1/1). macOS compile not reproducible here; relying on the macOS check in the description. Merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5735
No description provided.