build(libkernel): compile Process on macOS #11282

Closed
iamthehimansh wants to merge 1 commit from upstream-pr/11282 into main
iamthehimansh commented 2026-10-25 23:42:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-25T23:42:44Z.


What

Next part of splitting #8658: libkernel's System/src/Process.cpp does not compile on macOS (sched_getcpu, RUSAGE_THREAD). Each change is macOS-only; Linux and Windows compile the same code as before.

  • Process arguments: read from _NSGetArgc / _NSGetArgv, since macOS has no procfs command line.
  • sceKernelGetCurrentCpu: Darwin cannot report the current core, so macOS passes host CPU 0 to GuestCpuFromHost. That still maps into the thread's guest affinity, so the result is always a CPU the thread is allowed on.
  • getrusage for the calling thread: macOS has no RUSAGE_THREAD. User and system time come from thread_info(THREAD_BASIC_INFO) on the thread's Mach port. The other fields come from the process getrusage.

I compared the added lines with every open PR that touches Process.cpp. #11108 shares one line and nothing else does, so no open PR carries this macOS code.

Tested

macOS 26 on an Apple M2 Pro, x86_64 under Rosetta 2, Release with Ninja, on main at b90d009d9: System/src/Process.cpp.o compiles, where main fails it. The libkernel tests cannot run on macOS until the rest of libkernel builds, so this is a compile check only. In #8658's full macOS run the same code passed guest_process_arguments, guest_current_cpu, guest_getrusage, guest_process_time and guest_thread_cpu_clock. For Linux and Windows, I checked the file's view under unifdef -U__APPLE__, with -D__linux__ and with -D_WIN32: it equals main. 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Cana)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5009859341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11282). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-25T23:42:44Z. --- ### What Next part of splitting #8658: `libkernel`'s `System/src/Process.cpp` does not compile on macOS (`sched_getcpu`, `RUSAGE_THREAD`). Each change is macOS-only; Linux and Windows compile the same code as before. - Process arguments: read from `_NSGetArgc` / `_NSGetArgv`, since macOS has no procfs command line. - `sceKernelGetCurrentCpu`: Darwin cannot report the current core, so macOS passes host CPU 0 to `GuestCpuFromHost`. That still maps into the thread's guest affinity, so the result is always a CPU the thread is allowed on. - `getrusage` for the calling thread: macOS has no `RUSAGE_THREAD`. User and system time come from `thread_info(THREAD_BASIC_INFO)` on the thread's Mach port. The other fields come from the process `getrusage`. I compared the added lines with every open PR that touches `Process.cpp`. #11108 shares one line and nothing else does, so no open PR carries this macOS code. ### Tested macOS 26 on an Apple M2 Pro, x86_64 under Rosetta 2, Release with Ninja, on `main` at `b90d009d9`: `System/src/Process.cpp.o` compiles, where `main` fails it. The `libkernel` tests cannot run on macOS until the rest of `libkernel` builds, so this is a compile check only. In #8658's full macOS run the same code passed `guest_process_arguments`, `guest_current_cpu`, `guest_getrusage`, `guest_process_time` and `guest_thread_cpu_clock`. For Linux and Windows, I checked the file's view under `unifdef -U__APPLE__`, with `-D__linux__` and with `-D_WIN32`: it equals `main`. `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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes ([Cana](https://cana.build))
MarcZX10 commented 2026-10-25 23:45:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:45:15Z.

Review: APPROVED


Reviewed exact head 3ac106f1dd623f8d8e5d9efdbc47ba18c306102e. The platform-specific branches are scoped to __APPLE__; argument acquisition uses Darwin’s _NSGetArgc/_NSGetArgv, and thread CPU times come from thread_info(THREAD_BASIC_INFO) while process usage remains from getrusage(RUSAGE_SELF). I found no blocking correctness issue in the diff. The author reports the macOS 26 arm64/Rosetta object compile; hosted eligibility, conventions, intake, labels and report checks pass. Product and relinker jobs are skipped for these paths, so this is not a hosted full-build result.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645974635 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11282#pullrequestreview-5645974635). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T23:45:15Z. **Review:** APPROVED --- Reviewed exact head `3ac106f1dd623f8d8e5d9efdbc47ba18c306102e`. The platform-specific branches are scoped to `__APPLE__`; argument acquisition uses Darwin’s `_NSGetArgc`/`_NSGetArgv`, and thread CPU times come from `thread_info(THREAD_BASIC_INFO)` while process usage remains from `getrusage(RUSAGE_SELF)`. I found no blocking correctness issue in the diff. The author reports the macOS 26 arm64/Rosetta object compile; hosted eligibility, conventions, intake, labels and report checks pass. Product and relinker jobs are skipped for these paths, so this is not a hosted full-build result.
MarcZX10 commented 2026-10-26 00:49:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:49:39Z.

Review: CHANGES_REQUESTED


I found a material overlap that the PR body misses. #7201 (Macos port, currently open and labeled needs rebase) adds the same __APPLE__ branches in Process.cpp: _NSGetArgc/_NSGetArgv argument loading, thread_info(THREAD_BASIC_INFO) for thread usage, and sceKernelGetCurrentCpu returning host CPU 0. #7804 and #5021 also carry the argument-loading and thread-usage changes in this file. This is overlapping implementation work, not just an unrelated shared-file warning.

Please coordinate merge order with the affected PR authors, update the overlap/Depends on information to record the agreed integration path, and clarify how this focused split is distinct from the existing open macOS work. I am not asking anyone to close a PR. Until the overlap is reconciled, the checklist's Depends on: none and the statement that only #11108 shares a line are not accurate.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5646246658 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11282#pullrequestreview-5646246658). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T00:49:39Z. **Review:** CHANGES_REQUESTED --- I found a material overlap that the PR body misses. #7201 (`Macos port`, currently open and labeled `needs rebase`) adds the same `__APPLE__` branches in `Process.cpp`: `_NSGetArgc`/`_NSGetArgv` argument loading, `thread_info(THREAD_BASIC_INFO)` for thread usage, and `sceKernelGetCurrentCpu` returning host CPU 0. #7804 and #5021 also carry the argument-loading and thread-usage changes in this file. This is overlapping implementation work, not just an unrelated shared-file warning. Please coordinate merge order with the affected PR authors, update the overlap/`Depends on` information to record the agreed integration path, and clarify how this focused split is distinct from the existing open macOS work. I am not asking anyone to close a PR. Until the overlap is reconciled, the checklist's `Depends on: none` and the statement that only #11108 shares a line are not accurate.

Pull request closed

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!11282
No description provided.