test(libkernel): describe the flexible memory fixture's segment on macOS #9972

Merged
tkcm01 merged 1 commit from upstream-pr/9972 into main 2026-10-24 14:50:57 +00:00
tkcm01 commented 2026-10-23 01:18:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tkcm01 on 2026-10-23T01:18:26Z.


What

guest_flexible_memory_declared loads guest_flexible_memory_module.guest.prx, a host-built fixture whose 512 MiB array must count against the flexible memory budget (GuestImageSegmentBytes). On macOS, dl_iterate_phdr (libc/src/specifics/macos/GuestImages.cpp) reports only images that carry the relinker's __APS5DATA,__meta program headers. Every relinked guest module has them, but the host-built fixture doesn't, so it was left out and the test failed at its budget check (GuestFlexibleMemoryBudget.cpp, GuestImageSegmentBytes_nid_no_patch() > 448u * 1024u * 1024u).

On macOS the fixture now fills its own __APS5DATA,__meta at load, with one PT_LOAD header for the array, as ProcessParametersFixture.hpp already does for the test program. The module target gets ${LIBS_INCLUDE_DIR} for ElfTypes.hpp. Linux and Windows are unchanged. The runtime is unchanged too: #7201 would make the test pass by synthesising program headers in dl_iterate_phdr for every host image, which this test alone doesn't need. Announced on #1, where @mugurc listed the failure as known in #7631.

Tested

macOS 27.0.1, Apple M4, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS from main alone, so the run is on mugurc's ci/macos-series-2 (53db0badb, main 3fd1cc393) with #7524, the code commits of #7937 and the libSceSsl change from #7332, as described on #1, plus my local macOS fixes listed there. The patch applies to that tree as is.

  • ctest -R '^guest_flexible_memory_': without this change 4 of 5 pass, and declared aborts with Flexible memory budget check failed at .../GuestFlexibleMemoryBudget.cpp:108. With it all 5 pass.
  • Full ctest -j4 with Vulkan (MoltenVK 1.4.2) on the same tree, with and without this change: 1648 tests. guest_flexible_memory_declared is the only test that now passes. The one that differs the other way, agc_driver_pass_input_hazard, failed once under load and passed 20 of 20 on its own and in 4 other full runs. No new failure.
  • python3 tools/check_conventions.py --base upstream/main: passed. tools/pr_overlap.py lists open PRs that change libkernel/CMakeLists.txt, and #6044, which moves the test sources; none changes this fixture.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4976376093 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9972). Originally posted by [tkcm01](https://github.com/tkcm01) on 2026-10-23T01:18:26Z. --- ### What `guest_flexible_memory_declared` loads `guest_flexible_memory_module.guest.prx`, a host-built fixture whose 512 MiB array must count against the flexible memory budget (`GuestImageSegmentBytes`). On macOS, `dl_iterate_phdr` (`libc/src/specifics/macos/GuestImages.cpp`) reports only images that carry the relinker's `__APS5DATA,__meta` program headers. Every relinked guest module has them, but the host-built fixture doesn't, so it was left out and the test failed at its budget check (`GuestFlexibleMemoryBudget.cpp`, `GuestImageSegmentBytes_nid_no_patch() > 448u * 1024u * 1024u`). On macOS the fixture now fills its own `__APS5DATA,__meta` at load, with one `PT_LOAD` header for the array, as `ProcessParametersFixture.hpp` already does for the test program. The module target gets `${LIBS_INCLUDE_DIR}` for `ElfTypes.hpp`. Linux and Windows are unchanged. The runtime is unchanged too: #7201 would make the test pass by synthesising program headers in `dl_iterate_phdr` for every host image, which this test alone doesn't need. Announced on #1, where @mugurc listed the failure as known in #7631. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> macOS 27.0.1, Apple M4, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS from `main` alone, so the run is on mugurc's `ci/macos-series-2` (53db0badb, `main` 3fd1cc393) with #7524, the code commits of #7937 and the libSceSsl change from #7332, as described on #1, plus my local macOS fixes listed there. The patch applies to that tree as is. - `ctest -R '^guest_flexible_memory_'`: without this change 4 of 5 pass, and `declared` aborts with `Flexible memory budget check failed at .../GuestFlexibleMemoryBudget.cpp:108`. With it all 5 pass. - Full `ctest -j4` with Vulkan (MoltenVK 1.4.2) on the same tree, with and without this change: 1648 tests. `guest_flexible_memory_declared` is the only test that now passes. The one that differs the other way, `agc_driver_pass_input_hazard`, failed once under load and passed 20 of 20 on its own and in 4 other full runs. No new failure. - `python3 tools/check_conventions.py --base upstream/main`: passed. `tools/pr_overlap.py` lists open PRs that change `libkernel/CMakeLists.txt`, and #6044, which moves the test sources; none changes this fixture. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-23 04:17:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T04:17:08Z.

Review: APPROVED


Reviewed exact head 2fd0c1b8fa against current main. The fixture metadata uses the same v2 offsets and PT_LOAD representation consumed by the existing macOS dl_iterate_phdr shim, and points the segment at the fixture's 512 MiB array. The change is limited to the host test fixture and its test-target include path; it does not change runtime image enumeration. The reported no-change platform results and macOS before/after tests exercise the intended regression.

The convention check against current main, exact-head 171-script registration audit, and git diff --check pass. The author reports 5/5 targeted macOS tests and a 1,648-test full run with one additional pass; the one intermittent opposite-direction failure is documented with its repeated standalone result. I could not run the macOS tests locally from this Linux workspace. Hosted policy checks pass and product build jobs are skipped. The PR is mergeable, and I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5623830521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9972#pullrequestreview-5623830521). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T04:17:08Z. **Review:** APPROVED --- Reviewed exact head 2fd0c1b8fa5a3402920765188d253cfc69a03a8f against current main. The fixture metadata uses the same v2 offsets and `PT_LOAD` representation consumed by the existing macOS `dl_iterate_phdr` shim, and points the segment at the fixture's 512 MiB array. The change is limited to the host test fixture and its test-target include path; it does not change runtime image enumeration. The reported no-change platform results and macOS before/after tests exercise the intended regression. The convention check against current main, exact-head 171-script registration audit, and `git diff --check` pass. The author reports 5/5 targeted macOS tests and a 1,648-test full run with one additional pass; the one intermittent opposite-direction failure is documented with its repeated standalone result. I could not run the macOS tests locally from this Linux workspace. Hosted policy checks pass and product build jobs are skipped. The PR is mergeable, and I found no blocking issue.
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!9972
No description provided.