fix(libkernel): build the fcntl status flags and the getrlimit test on macOS #4555

Merged
Xabilimon1 merged 1 commit from upstream-pr/4555 into main 2026-10-13 14:36:39 +00:00
Xabilimon1 commented 2026-10-12 15:34:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Xabilimon1 on 2026-10-12T15:34:48Z.


What

Two pieces of code added to main since mugurc:macos-port was last re-stacked do not compile on macOS:

  • InitialEntry (DescriptorControl.cpp, from #3840) maps the host's O_DIRECT to the guest's Direct status flag. The macOS SDK's sys/fcntl.h has no O_DIRECT (the closest is F_NOCACHE, an fcntl command), so libkernel stops with use of undeclared identifier 'O_DIRECT'. The flag is now read only where the host defines it. Linux keeps the same code, and the function is compiled only outside _WIN32, so neither Linux nor Windows changes.
  • GuestGetrlimit.cpp (from #3765) iterates over braced lists without including <initializer_list>. libc++ requires it: cannot deduce type of initializer list because std::initializer_list was not found.

@mugurc, found while merging macos-port with main for a test. Two other errors from that merge are not here because they only exist on the branch: WatchMapping in DirectMemory.cpp is built on __APPLE__ there but uses g_physicalSpans, which main declares for __linux__ only, and the branch's __APPLE__ include block in GuestKernelStackProtect.cpp has no <sys/mman.h>, which the mmap that main added to that test needs.

Tested

macOS 27.0.1, Apple M3, Apple clang 21, x86-64 under Rosetta, on mugurc:macos-port de3ef5d53 merged with main 0ef9dc928:

  • without these changes: the two errors above;
  • with them: both files compile, the full build and libs finish, and guest_getrlimit and guest_kernel_fcntl pass.

Not built on Linux or Windows; on both the preprocessor keeps the code as it is. 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 in TechnicalDebt
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4831605668 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4555). Originally posted by [Xabilimon1](https://github.com/Xabilimon1) on 2026-10-12T15:34:48Z. --- ### What Two pieces of code added to `main` since `mugurc:macos-port` was last re-stacked do not compile on macOS: - `InitialEntry` (`DescriptorControl.cpp`, from #3840) maps the host's `O_DIRECT` to the guest's `Direct` status flag. The macOS SDK's `sys/fcntl.h` has no `O_DIRECT` (the closest is `F_NOCACHE`, an `fcntl` command), so libkernel stops with `use of undeclared identifier 'O_DIRECT'`. The flag is now read only where the host defines it. Linux keeps the same code, and the function is compiled only outside `_WIN32`, so neither Linux nor Windows changes. - `GuestGetrlimit.cpp` (from #3765) iterates over braced lists without including `<initializer_list>`. libc++ requires it: `cannot deduce type of initializer list because std::initializer_list was not found`. @mugurc, found while merging `macos-port` with `main` for a test. Two other errors from that merge are not here because they only exist on the branch: `WatchMapping` in `DirectMemory.cpp` is built on `__APPLE__` there but uses `g_physicalSpans`, which `main` declares for `__linux__` only, and the branch's `__APPLE__` include block in `GuestKernelStackProtect.cpp` has no `<sys/mman.h>`, which the `mmap` that `main` added to that test needs. ### Tested macOS 27.0.1, Apple M3, Apple clang 21, x86-64 under Rosetta, on `mugurc:macos-port` `de3ef5d53` merged with `main` `0ef9dc928`: - without these changes: the two errors above; - with them: both files compile, the full build and `libs` finish, and `guest_getrlimit` and `guest_kernel_fcntl` pass. Not built on Linux or Windows; on both the preprocessor keeps the code as it is. `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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot] commented 2026-10-12 15:34:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-12T15:34:53Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5492911372 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4555#pullrequestreview-5492911372). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-12T15:34:53Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Xabilimon1 commented 2026-10-13 08:30:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Xabilimon1 on 2026-10-13T08:30:43Z.


Heads-up: #4629 carries the same <initializer_list> hunk in GuestGetrlimit.cpp, byte for byte, so either PR merges cleanly after the other. The O_DIRECT guard in DescriptorControl.cpp is only here; main at ad653c9bc still has it unguarded, and the macOS SDK defines no O_DIRECT

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141549106 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4555#issuecomment-6141549106). Originally posted by [Xabilimon1](https://github.com/Xabilimon1) on 2026-10-13T08:30:43Z. --- Heads-up: #4629 carries the same <initializer_list> hunk in GuestGetrlimit.cpp, byte for byte, so either PR merges cleanly after the other. The O_DIRECT guard in DescriptorControl.cpp is only here; main at ad653c9bc still has it unguarded, and the macOS SDK defines no O_DIRECT
adriadam10 commented 2026-10-13 14:20:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:20:46Z.


Checked the diff, build + ctest on the scoped libkernel/libs set (146 tests green, guest_getrlimit passes). On Linux O_DIRECT is defined so the code is unchanged; the file is not compiled on Windows. macOS compilation itself is not something we can run here. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147702794 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4555#issuecomment-6147702794). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T14:20:46Z. --- Checked the diff, build + ctest on the scoped libkernel/libs set (146 tests green, `guest_getrlimit` passes). On Linux `O_DIRECT` is defined so the code is unchanged; the file is not compiled on Windows. macOS compilation itself is not something we can run here. 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!4555
No description provided.