Skip to content

fix(macos): build guest RTTI and the AGC runtime - #29204

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
brajankw:fix/macos-guest-libc-rtti
Dec 6, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
brajankw:fix/macos-guest-libc-rtti

Conversation

@brajankw

@brajankw brajankw commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

What

The full macOS build stops in guest libc: exception/Exports.cpp fails with no member named '__contained_virtual_mask' in '__cxxabiv1::__class_type_info'. On macOS the libc++ ABI shim in CxxAbi.hpp defined only __unknown of the RTTI path kinds. This adds the remaining __sub_kind values and the VMI flags with their Itanium/GCC ABI encodings, which the guest exception runtime uses. The shim is used only with _LIBCPPABI_VERSION, so Linux and MinGW builds still take these definitions from libstdc++'s <cxxabi.h>.

With libc fixed, AGC then failed to compile under AppleClang at a std::min call in CompareMapped (GuestMemory.cpp, from #24031). It mixes std::size_t with an expression that contains the std::uint64_t address. Those are unsigned long and unsigned long long on macOS, so template deduction fails. The call now names std::size_t. The result on the 64-bit targets is unchanged.

The macOS CI jobs build only the relinker and standalone targets, so they don't hit either error.

Part of #28913.

Tested

macOS 27.2.1, Apple M6, Xcode 26.6 (macOS 26.5 SDK). x86-64 Release build running under Rosetta 2.
On main 1310d78, the libc target fails with the error above.
With this change, guest libc, the kernel and AGC build and link. Four focused AGC runtime tests pass on MoltenVK with the AGENTS.md validation environment: the loader inserts the layer and there are 0 VUID- lines. On top of this change, the pipeline warm tool's --dry-run runs against a recorded journal with 0 VUID- lines.
A main-side GPU comparison is not possible on macOS, because main does not link there.
python3 tools/check_conventions.py 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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 M6 through MoltenVK, macOS 27.2.1
  • AI-assisted: yes

Created with GPT-6.2 Sol in Codex.

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency in memory comparisons at page boundaries on Linux and Apple platforms.
    • Expanded C++ runtime type relationship handling to cover additional containment and visibility states, improving compatibility with code that relies on these runtime definitions.

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: AGC page-boundary calculation

Layer / File(s) Summary
Specify the std::min template argument
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
The CompareMapped page-boundary calculation now specifies std::size_t as the template argument. The expression and comparison behavior are unchanged.

Itanium ABI containment values

Layer / File(s) Summary
Add containment enum values
core/libs/prx/libc/include/specifics/itanium/CxxAbi.hpp
__class_type_info::__sub_kind now defines non-containment and ambiguous-containment values, virtual and public masks, a combined mask, and derived private and public values. __unknown remains zero.

Possibly related PRs

  • boykopovar/AnyPS5#27739: This PR changes the same std::min call in CompareMapped to address the same AppleClang type-deduction error.

Suggested reviewers: mugurc, chitters2004, boykopovar

Change: Bug fix

Merge Risk: Minimal · up to 97aab

This change fixes macOS build failures with minimal behavioral impact. The type is pinned without changing the calculation, and the added ABI enum values match the existing consumers. No merge-blocking risk is identified.

Security architecture risk: Minimal · up to 97aab

The patch fixes two macOS build failures without changing how AGC checks guest memory or how guest libc classifies RTTI paths on builds that already worked.

Security review details

Trust Boundaries and Controls

  • observed — On the Linux and macOS path, CompareMapped still reads through GuestCopyInUnsynced_nid_no_patch. If the chunk read fails, it retries in page-bounded runs and stops at the first non-equal result. The explicit std::size_t argument does not change the range requested on the affected 64-bit targets or bypass the copy-failure gate.

Dependencies

  • observed — Runtime.cpp uses the named containment values. TypeInfo.cpp uses its own numeric constants for the encodings it consumes; those constants agree with the shim at the reviewed head.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 70d3bcf3-1900-4da0-9d60-e5b88dcf9819
Commits

Reviewing files that changed from the base of the PR and between ae2eb20 and 97aab63.

Files selected for processing: 2

  • core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
  • core/libs/prx/libc/include/specifics/itanium/CxxAbi.hpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@github-actions github-actions Bot added libc agc libSceAgc* labels Dec 5, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

The inspected changes show no concrete blocking defect; caller context and the reported macOS build and tests could not be independently verified.

What I ran

Reviewed head 97aab63ba9444a6c5399b9bfbfd82e54018ebcef using the prepared diff and included file text. Attempted to use repo_read.py for pinned source context, but it could not append its read log in the read-only run directory. No build or tests were run.

Results

Check Result Note
Changed hunks passed Both changed files inspected
Build and tests not run Results in the description are author-reported
Pinned caller context not run Reader could not log its call

Negative control

Not run; no non-compiling negative control was available for these changes.

Findings

Blocking

None identified in the inspected hunks.

Non-blocking

None.

Sources

Not verified

  • Read core/libs/prx/libc/include/specifics/itanium/CxxAbi.hpp and the changed CompareMapped range in core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp; the rest of GuestMemory.cpp was not read. Both files were included in the review folder; files.json lists no excluded files.
  • Call sites and behavior beyond the inspected hunks were not verified because repo_read.py could not write its read log.
  • The macOS build, AGC runtime tests, pipeline warm dry-run, and conventions check described by the author were not run by this review.

To get this to a good state

Nothing is required. The macOS build and runtime results in the description remain author-reported.

@github-actions

github-actions Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 27521 core/libs/prx/libc/include/specifics/itanium/CxxAbi.hpp L18
PR 27782 core/libs/prx/libc/include/specifics/itanium/CxxAbi.hpp L18

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 12568 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 12792 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 14473 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 16372 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 16879 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 22029 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 22062 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 22434 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 24060 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28264 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28470 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28808 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp

@Romannachwievor

Copy link
Copy Markdown
Contributor

Checked on an Apple M1, macOS 26.5, Apple clang 21.0.0, x86_64 target under Rosetta (CMAKE_OSX_ARCHITECTURES=x86_64), Release, Ninja.

On main 86bcb83b55 the build stops in libc. Compiling GuestMemory.cpp on its own with the flags from compile_commands.json then fails at the min call, the only error in that file:

core/libs/prx/libc/src/exception/Runtime.cpp:296:91: error: no member named '__contained_virtual_mask' in '__cxxabiv1::__class_type_info'
GuestMemory.cpp:4430:20: error: no matching function for call to 'min'

With the PR head 97aab63ba9 merged locally into that main, libc, libSceAgcDriver and libcurl build with rc 0. I built only those three targets, not the full suite. agc_compare_hook_tests and agc_mapped_copy_tests compile GuestMemory.cpp directly and pass 14/14 in ctest.

The changed std::min line is covered. A temporary counter showed the page-wise fallback loop containing it runs in agc_mapped_copy_compare-reset (1x) and agc_mapped_copy_compare-prefix (3x). Mutating the line to std::min<std::size_t>(end, end) makes agc_mapped_copy_compare-prefix fail.

The same std::min change was also in #27739, which was closed on 2026-12-04. The min line came in with #24031.

@ycbuzi

ycbuzi commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Tested 97aab63ba9 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 3 tests failed out of 7938; 99% tests passed, 2 tests failed out of 7938. 2 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7938; 99% tests passed, 1 tests failed out of 7938. 1 of the failing tests fail on main too. run

Not covered: GPU. This pull request changes GPU code, and the GitHub-hosted runners above have no GPU, so the Vulkan and GPU tests fail there on main and on this pull request alike. This result says nothing about the changed GPU paths; they still need a run on a real GPU.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@oneandonlydean
oneandonlydean merged commit 267d8ef into boykopovar:main Dec 6, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* libc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants