fix(agc): build the frame recorder and the resident heap mirror test on macOS #10540
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10540"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by maximilianfv on 2026-10-24T09:05:05Z.
What
Two macOS build errors in libSceAgcDriver on current
main:Execution/src/FrameRecorder.cpp(added in #8740) readsenvironincaptureEnvironment(), but macOS headers do not declare it:error: use of undeclared identifier 'environ'. This declaresextern char** environ;in the existing non-Windows branch after#include <unistd.h>, asPerformanceTrace.cppalready does.tests/execution/ResidentHeapMirror.cpp(the mapping line came in with #7647) passesMAP_FIXED_NOREPLACEwhen the heap is placed at an address, and that flag exists only on Linux:error: use of undeclared identifier 'MAP_FIXED_NOREPLACE'. This keeps the flag on Linux. On macOS, wheremmaptreats a non-null address only as a hint, a heap placed at an address is allocated withmach_vm_allocateandVM_FLAGS_FIXED, which maps exactly there or fails withKERN_NO_SPACEwithout replacing an existing mapping, asMAP_FIXED_NOREPLACEdoes (a standalone probe: an occupied range givesKERN_NO_SPACEand leaves the address unchanged; a freed range is mapped at exactly that address, writable, andmunmapreleases it). The existingRequire(raw != MAP_FAILED && (at == nullptr || raw == at), ...)stays.Prior art: #8658 by iamthehimansh (closed, split into smaller PRs such as #10419) made the same test change on macOS in commit
771424ae22(2026-10-23). It definedMAP_FIXED_NOREPLACEas0under__APPLE__, which has the same effect on macOS as this change. That PR covers only the test, notenvironinFrameRecorder.cpp, and it uses a macro instead of a__linux__guard. None of the PRs it was split into carries that change. No earlier PR declaresenvironinFrameRecorder.cpp, which #8740 added after the whole-port PRs.Tested
Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2, Vulkan through MoltenVK from the LunarG Vulkan SDK 1.4.363 (KosmicKrisp in that SDK is arm64-only).
mainalone does not build on macOS, so this was tested in a tree made of mugurc's macOS series (ci/macos-series-2, 27e968974) merged withmainat1e20650e84, plus the macOS build parts of #10419 (StandardExceptions.cpp,FileStream.hpp).ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -R 'agc_driver_resident_heap_mirror|agc_recorder|agc_resident_present' -V: 8 of 9 pass (agc_recorder_device_selection,agc_recorder_read_list,agc_recorder_deferred_failure_report,agc_recorder_completion_labels,agc_recorder_cmask,agc_recorder_cube,agc_recorder_kept_bytes,agc_resident_present). The log has nowas not found but was requested by env var VK_INSTANCE_LAYERSline. The only validation errors are 6VUID-VkDeviceCreateInfo-pProperties-04451: the validation layer flagsvkCreateDevicewithoutVK_KHR_portability_subseton MoltenVK. This change does not touch device creation. A validation comparison againstmainis not possible because the tree without this change does not build.agc_driver_resident_heap_mirrornow builds and runs and passes the mapping check, then fails later atResidentHeapMirror.cpp:218:first dispatch: the heap mirrors of two 8192 KiB heaps hold 16384 KiB of device memory; the guest and the GPU wrote 192 KiB of them. The log also showshost import budget: 0 MiB live of 0 MiB (APS5_HOST_IMPORT_MIB); 1 imports (8 MiB) refused so far, 0 of them remembered. That is a separate macOS gap, and this PR does not fix it. No open PR covers it: #8380 edits the same test and the heap mirror code but does not touch the mapping line. Closed #8658 handled it on the test side, running only the copied-mirror checks on devices without sparse residency (commit83463c6f6e).:218before it reached theat != nullptrplacement path (ReusedAddressTests), so that path is not exercised on macOS by this run; themach_vm_allocateplacement itself was checked with the probe above.MAP_FIXED_NOREPLACE, and the Windows code is unchanged.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:54:23Z.
Review: DISMISSED
The non-Linux
mmappath now passesatwithplacement = 0, but the constructor still requiresraw == at. On macOS,mmapdocuments a non-nulladdras a hint and explicitly allows the returned address to differ;ReusedAddressTestsrelies on exact reuse. If the hint is not honored, this new path fails at theRequireinstead of building a stable test. Since the PR report says the macOS run stops inResidentTestsbefore reachingReusedAddressTests, that address-reuse path has not been exercised there. Please make it deterministic with a safe exact-address strategy available on the platform, or skip only that subtest when exact no-replace placement is unavailable (and make sure any unexpected successful mapping is unmapped before throwing). Apple mmap reference: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/mmap.2.html}