build(agc): keep the Linux-only parts of three AGC tests off macOS #11437

Merged
imellag merged 1 commit from upstream-pr/11437 into main 2026-11-15 02:23:25 +00:00
imellag commented 2026-10-26 13:18:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-26T13:18:36Z.


What

Three AGC tests don't compile on macOS on current main:

tests/SharedWrites.cpp:62:23: error: use of undeclared identifier 'RUSAGE_THREAD'
tests/HostImportSparseDmaBuf.cpp:231:66: error: use of undeclared identifier 'MFD_CLOEXEC'
tests/execution/SparseDmaBufImport.cpp:123:61: error: use of undeclared identifier 'MFD_CLOEXEC'

Their Linux-only parts are guarded with #ifndef _WIN32, so macOS compiles them too. This change guards them with #ifdef __linux__ instead:

  • HostImportSparseDmaBuf.cpp and execution/SparseDmaBufImport.cpp test udmabuf imports. On Windows they already print skipped, udmabuf imports are Linux only and return the skip code; on macOS they now do the same.

  • In SharedWrites.cpp:

    • the per-thread fault count of the benchmark modes (RUSAGE_THREAD, which macOS lacks). Windows already leaves it at 0;
    • the leak check that counts mappings in /proc/self/maps;
    • the block that writes through GuestArenaWriteSharedBacking. DirectMemory.cpp registers that writer only on Linux, so on macOS it returns false by design and the test fails with shared writer rejected direct backing.

    The partial sceKernelMunmap block stays on macOS, where it passes.

On Linux and Windows the compiled code doesn't change: the unifdef views of the three files with -D__linux__ -U_WIN32 and with -U__linux__ -D_WIN32 equal main's.

Tested

Current head 182c89266a, rebased onto main 98ddd9c179. #12168 merged in the meantime and changed SparseDmaBufImport.cpp's skip to main(int argc, char** argv) with SkipCode; this PR keeps that and only changes its guard to #ifndef __linux__. Nothing else changed.

Apple M4 Pro, macOS 27.2, Apple clang 21, x86-64 Release under Rosetta 2 (-DCMAKE_OSX_ARCHITECTURES=x86_64, Ninja, BUILD_TESTING=ON), MoltenVK 1.4.2 from Vulkan SDK 1.4.363.0.

main does not build the AGC driver and its tests on macOS yet, so this ran on a support branch, not main: fork branch support/macos-boot-1030 (6747733e89) = main 98ddd9c179 + only the open macOS PRs #11447 #11554 #10552 #7631 #7804 #4630 and #13220 (the duplicate write_watch test registration that stops main's CMake on macOS), plus one local line that reads environ through _NSGetEnviron() in HostReportSources.cpp (main doesn't compile it on macOS; no open PR covers it yet). The conflicts of #11554, #10552, #7631, #7804 and #4630 with main are resolved in the merge commits. Change: support/macos-boot-1030-pr11437 (f8fe1be811) = that branch + this PR's commit.

  • Build: on the support branch the three objects fail as above; with this commit the three test executables build and link.
  • Run: with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer, ctest -R '^(agc_shared_write|agc_shared_write_partial_collect|agc_host_import_sparse|agc_driver_sparse_dma_buf_import)$' -V, 3 runs:
    • agc_shared_write and agc_shared_write_partial_collect pass;
    • agc_host_import_sparse and agc_driver_sparse_dma_buf_import are skipped with skipped, udmabuf imports are Linux only;
    • the loader lists VK_LAYER_KHRONOS_validation as enabled by VK_INSTANCE_LAYERS, there is no was not found but was requested by env var VK_INSTANCE_LAYERS, and no VUID- line.

Logs attached.

Previous head 2e0a9091cc (main 035ac96edd with the macOS PRs of that day, macOS 27.0.1): the same results. Without #10898, which has merged since, agc_shared_write built but failed with invalid write was accepted.

Not built on Linux or Windows; the unifdef comparison above shows that their code is unchanged.

check_conventions.py --base upstream/main passes. pr_overlap.py reports no conflicting lines. Of the pull requests it couldn't compare:

  • #4449 adds checks inside the Linux part of HostImportSparseDmaBuf.cpp, which this PR doesn't change;
  • #5021 (draft) changes the same blocks of SharedWrites.cpp as part of its whole port: it also moves the /proc/self/maps count and the shared backing writer block to __linux__, but keeps the fault count on macOS with RUSAGE_SELF and leaves the partial unmap block off macOS. Proposed order, asked on #5021: this PR first; #5021 then takes main's guards when it rebases and keeps its RUSAGE_SELF fault count on top if it still wants it.

Checklist

  • Based on current main; no other open PR implements the same functions (except #5021, see the end of Tested)
  • 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: Apple M4 Pro, MoltenVK 1.4.2, macOS 27.2
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5018097507 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11437). Originally posted by [imellag](https://github.com/imellag) on 2026-10-26T13:18:36Z. --- ### What Three AGC tests don't compile on macOS on current `main`: ``` tests/SharedWrites.cpp:62:23: error: use of undeclared identifier 'RUSAGE_THREAD' tests/HostImportSparseDmaBuf.cpp:231:66: error: use of undeclared identifier 'MFD_CLOEXEC' tests/execution/SparseDmaBufImport.cpp:123:61: error: use of undeclared identifier 'MFD_CLOEXEC' ``` Their Linux-only parts are guarded with `#ifndef _WIN32`, so macOS compiles them too. This change guards them with `#ifdef __linux__` instead: - `HostImportSparseDmaBuf.cpp` and `execution/SparseDmaBufImport.cpp` test udmabuf imports. On Windows they already print `skipped, udmabuf imports are Linux only` and return the skip code; on macOS they now do the same. - In `SharedWrites.cpp`: - the per-thread fault count of the benchmark modes (`RUSAGE_THREAD`, which macOS lacks). Windows already leaves it at 0; - the leak check that counts mappings in `/proc/self/maps`; - the block that writes through `GuestArenaWriteSharedBacking`. `DirectMemory.cpp` registers that writer only on Linux, so on macOS it returns false by design and the test fails with `shared writer rejected direct backing`. The partial `sceKernelMunmap` block stays on macOS, where it passes. On Linux and Windows the compiled code doesn't change: the `unifdef` views of the three files with `-D__linux__ -U_WIN32` and with `-U__linux__ -D_WIN32` equal `main`'s. ### Tested **Current head `182c89266a`, rebased onto `main` `98ddd9c179`.** #12168 merged in the meantime and changed `SparseDmaBufImport.cpp`'s skip to `main(int argc, char** argv)` with `SkipCode`; this PR keeps that and only changes its guard to `#ifndef __linux__`. Nothing else changed. Apple M4 Pro, macOS 27.2, Apple clang 21, x86-64 Release under Rosetta 2 (`-DCMAKE_OSX_ARCHITECTURES=x86_64`, Ninja, `BUILD_TESTING=ON`), MoltenVK 1.4.2 from Vulkan SDK 1.4.363.0. `main` does not build the AGC driver and its tests on macOS yet, so this ran on a support branch, not `main`: fork branch [`support/macos-boot-1030`](https://github.com/imellag/AnyPS5/commits/support/macos-boot-1030) (`6747733e89`) = `main` `98ddd9c179` + only the open macOS PRs #11447 #11554 #10552 #7631 #7804 #4630 and #13220 (the duplicate `write_watch` test registration that stops `main`'s CMake on macOS), plus one local line that reads `environ` through `_NSGetEnviron()` in `HostReportSources.cpp` (`main` doesn't compile it on macOS; no open PR covers it yet). The conflicts of #11554, #10552, #7631, #7804 and #4630 with `main` are resolved in the merge commits. Change: [`support/macos-boot-1030-pr11437`](https://github.com/imellag/AnyPS5/commits/support/macos-boot-1030-pr11437) (`f8fe1be811`) = that branch + this PR's commit. - **Build:** on the support branch the three objects fail as above; with this commit the three test executables build and link. - **Run:** with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `VK_LOADER_DEBUG=layer`, `ctest -R '^(agc_shared_write|agc_shared_write_partial_collect|agc_host_import_sparse|agc_driver_sparse_dma_buf_import)$' -V`, 3 runs: - `agc_shared_write` and `agc_shared_write_partial_collect` pass; - `agc_host_import_sparse` and `agc_driver_sparse_dma_buf_import` are skipped with `skipped, udmabuf imports are Linux only`; - the loader lists `VK_LAYER_KHRONOS_validation` as enabled by `VK_INSTANCE_LAYERS`, there is no `was not found but was requested by env var VK_INSTANCE_LAYERS`, and no `VUID-` line. Logs attached. **Previous head `2e0a9091cc`** (`main` `035ac96edd` with the macOS PRs of that day, macOS 27.0.1): the same results. Without #10898, which has merged since, `agc_shared_write` built but failed with `invalid write was accepted`. Not built on Linux or Windows; the `unifdef` comparison above shows that their code is unchanged. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` reports no conflicting lines. Of the pull requests it couldn't compare: - #4449 adds checks inside the Linux part of `HostImportSparseDmaBuf.cpp`, which this PR doesn't change; - #5021 (draft) changes the same blocks of `SharedWrites.cpp` as part of its whole port: it also moves the `/proc/self/maps` count and the shared backing writer block to `__linux__`, but keeps the fault count on macOS with `RUSAGE_SELF` and leaves the partial unmap block off macOS. Proposed order, asked on #5021: this PR first; #5021 then takes `main`'s guards when it rebases and keeps its `RUSAGE_SELF` fault count on top if it still wants it. ### 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 (except #5021, see the end of Tested) - [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: Apple M4 Pro, MoltenVK 1.4.2, macOS 27.2 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-26 13:45:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T13:45:30Z.

Review: CHANGES_REQUESTED


I rechecked the updated head 2e0a9091ccb247d2465d3292dee2de44e225d92 against current main. The three touched files have not changed on main since the reported base, and tools/check_conventions.py --base upstream/main --head upstream/pr-11437 plus git diff --check upstream/main...upstream/pr-11437 pass. The updated macOS build/run report is useful; I have not independently run that macOS suite.

There is one repository-rule overlap to resolve before approval. Open #7201 changes the same HostImportSparseDmaBuf.cpp and SparseDmaBufImport.cpp platform guards to skip those Linux-only cases on macOS, and carries a broader macOS-specific implementation in the same SharedWrites.cpp regions this PR now excludes from macOS. The open draft #5021 also carries related SharedWrites.cpp edits. If this PR is intended as the immediate standalone fix, please clarify the merge order and coordinate the overlapping hunks so the same macOS test handling is not duplicated or regressed when those branches are integrated. I am requesting changes for that overlap only; I found no separate defect in the guards themselves.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5652929202 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11437#pullrequestreview-5652929202). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T13:45:30Z. **Review:** CHANGES_REQUESTED --- I rechecked the updated head `2e0a9091ccb247d2465d3292dee2de44e225d92` against current `main`. The three touched files have not changed on main since the reported base, and `tools/check_conventions.py --base upstream/main --head upstream/pr-11437` plus `git diff --check upstream/main...upstream/pr-11437` pass. The updated macOS build/run report is useful; I have not independently run that macOS suite. There is one repository-rule overlap to resolve before approval. Open #7201 changes the same `HostImportSparseDmaBuf.cpp` and `SparseDmaBufImport.cpp` platform guards to skip those Linux-only cases on macOS, and carries a broader macOS-specific implementation in the same `SharedWrites.cpp` regions this PR now excludes from macOS. The open draft #5021 also carries related `SharedWrites.cpp` edits. If this PR is intended as the immediate standalone fix, please clarify the merge order and coordinate the overlapping hunks so the same macOS test handling is not duplicated or regressed when those branches are integrated. I am requesting changes for that overlap only; I found no separate defect in the guards themselves.
MarcZX10 commented 2026-11-14 07:37:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T07:37:34Z.

Review: APPROVED


Reviewed — looks good

The reviewed change updates the three tests’ platform guards to keep Linux-only code off macOS; the source inspected supports the stated skip behavior for the two DMA-BUF tests and limits the /proc leak check and RUSAGE_THREAD fault count to Linux.

What I ran

No build or tests were run. I read the prepared review description, commit list, manifest, diff, README, and each changed file’s added lines and relevant surrounding code at head 182c89266a40bf584a7f9a1dd7ba8fe03674cc7e, using repo_read.py.

Results

Check Result Note
Changed-line review passed All three changed files inspected
Build and tests not run Author reports macOS support-branch results
Linux and Windows behavior not run Author reports unifdef comparisons

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds and runtime behavior were not independently verified. I did not inspect the remainder of the changed files beyond the added lines and relevant surrounding code. files.json was not available as a review document; the manifest lists all three changed files as included, and the review folder lists no excluded changed files.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5902750749 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11437#pullrequestreview-5902750749). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T07:37:34Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change updates the three tests’ platform guards to keep Linux-only code off macOS; the source inspected supports the stated skip behavior for the two DMA-BUF tests and limits the `/proc` leak check and `RUSAGE_THREAD` fault count to Linux. ## What I ran No build or tests were run. I read the prepared review description, commit list, manifest, diff, README, and each changed file’s added lines and relevant surrounding code at head `182c89266a40bf584a7f9a1dd7ba8fe03674cc7e`, using `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Changed-line review | passed | All three changed files inspected | | Build and tests | not run | Author reports macOS support-branch results | | Linux and Windows behavior | not run | Author reports `unifdef` comparisons | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Builds and runtime behavior were not independently verified. I did not inspect the remainder of the changed files beyond the added lines and relevant surrounding code. `files.json` was not available as a review document; the manifest lists all three changed files as included, and the review folder lists no excluded changed files. ## To get this to a good state Nothing is required.
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!11437
No description provided.