feat(libc): expose libc++ base streambuf locale hook and RTTI #28657

Open
mihai1859 wants to merge 1 commit from upstream-pr/28657 into main
mihai1859 commented 2026-12-02 15:37:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihai1859 on 2026-12-02T15:37:42Z.


What

Expose the narrow libc++ base stream buffer’s locale-change hook and its class type information. The PS5 Payload SDK v0.42 leaves the base hook empty. The exported RTTI uses the SDK’s two-pointer layout and points to the Itanium class-type vtable.

Tested

  • Windows, guest_libc_static_imports passed. It checks that calling the base hook preserves the stream and locale, and that the RTTI has the expected type name and class-type vtable.
  • Compared against the PS5 Payload SDK v0.42 routine and its RTTI relocations.
  • The packaged Windows library satisfies both formerly missing Azahar imports. Startup stops at 151 remaining imports (130 functions and 21 data symbols).
  • Manually inspected the shared files for seven older branches that the overlap tool could not compare against main. Their changes cover separate exports.

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: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • New Features
    • Added libc++ support for basic_streambuf<char> locale handling and type information, improving compatibility with software that uses these stream-buffer features.
  • Tests
    • Added checks for stream-buffer locale behavior and type metadata.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5609717011 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28657). Originally posted by [mihai1859](https://github.com/mihai1859) on 2026-12-02T15:37:42Z. --- ### What Expose the narrow libc++ base stream buffer’s locale-change hook and its class type information. The PS5 Payload SDK v0.42 leaves the base hook empty. The exported RTTI uses the SDK’s two-pointer layout and points to the Itanium class-type vtable. ### 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. --> - Windows, `guest_libc_static_imports` passed. It checks that calling the base hook preserves the stream and locale, and that the RTTI has the expected type name and class-type vtable. - Compared against the PS5 Payload SDK v0.42 routine and its RTTI relocations. - The packaged Windows library satisfies both formerly missing Azahar imports. Startup stops at 151 remaining imports (130 functions and 21 data symbols). - Manually inspected the shared files for seven older branches that the overlap tool could not compare against main. Their changes cover separate exports. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added libc++ support for `basic_streambuf<char>` locale handling and type information, improving compatibility with software that uses these stream-buffer features. * **Tests** * Added checks for stream-buffer locale behavior and type metadata. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-12-02 15:42:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T15:42:32Z.

Review: APPROVED


Reviewed — looks good

The change exposes the requested libc++ streambuf locale hook and class RTTI, and the inspected code supports the stated ABI behavior.

What I ran

Inspected the prepared description, commits, manifest, diff, and relevant ranges from all six included changed files at head c82f99e02ccd985aea3ad4a67a0c712c0aa88b91. No tests or build checks were run.

rg -n 'ClassTypeVtable|_ZTVN10__cxxabiv117__class_type_infoE|basic_streambuf|TestLibcxxStreambufMetadata|struct ClassTypeRecord' files/...
sed -n '1,55p' files/core/libs/prx/libc/src/exception/StandardExceptions.cpp
sed -n '970,1010p' files/core/libs/prx/libc/src/exception/StandardExceptions.cpp
sed -n '155,190p' files/core/libs/prx/libc/src/exception/TypeInfo.cpp
sed -n '185,216p' files/core/libs/tests/GuestLibcStaticImports.cpp

Results

Check Result Note
Prepared diff and changed code passed All six changed files were included and inspected
Tests and build not run No independent execution
Pinned reader not run Its log write was rejected by the read-only run folder

Negative control

Not run; no source mutation or test execution was performed.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The author-reported Windows test, firmware provider behavior, and full title execution were not independently verified. files.json lists no excluded files. The reviewed files were core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/src/LibcxxLocaleFacet.cpp, core/libs/prx/libc/src/exception/StandardExceptions.cpp, core/libs/prx/libc/src/exception/TypeInfo.cpp, core/libs/tests/GuestLibcStaticImports.cpp, and docs/dev/debt/changes/feat-libc-streambuf-metadata.md.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6154121078 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28657#pullrequestreview-6154121078). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-12-02T15:42:32Z. **Review:** APPROVED --- # Reviewed — looks good The change exposes the requested libc++ streambuf locale hook and class RTTI, and the inspected code supports the stated ABI behavior. ## What I ran Inspected the prepared description, commits, manifest, diff, and relevant ranges from all six included changed files at head `c82f99e02ccd985aea3ad4a67a0c712c0aa88b91`. No tests or build checks were run. ```text rg -n 'ClassTypeVtable|_ZTVN10__cxxabiv117__class_type_infoE|basic_streambuf|TestLibcxxStreambufMetadata|struct ClassTypeRecord' files/... sed -n '1,55p' files/core/libs/prx/libc/src/exception/StandardExceptions.cpp sed -n '970,1010p' files/core/libs/prx/libc/src/exception/StandardExceptions.cpp sed -n '155,190p' files/core/libs/prx/libc/src/exception/TypeInfo.cpp sed -n '185,216p' files/core/libs/tests/GuestLibcStaticImports.cpp ``` ## Results | Check | Result | Note | |---|---|---| | Prepared diff and changed code | passed | All six changed files were included and inspected | | Tests and build | not run | No independent execution | | Pinned reader | not run | Its log write was rejected by the read-only run folder | ## Negative control Not run; no source mutation or test execution was performed. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [Locale hook implementation](https://github.com/boykopovar/AnyPS5/blob/c82f99e02ccd985aea3ad4a67a0c712c0aa88b91/core/libs/prx/libc/src/LibcxxLocaleFacet.cpp) - [Streambuf RTTI record](https://github.com/boykopovar/AnyPS5/blob/c82f99e02ccd985aea3ad4a67a0c712c0aa88b91/core/libs/prx/libc/src/exception/TypeInfo.cpp) - [Static import test](https://github.com/boykopovar/AnyPS5/blob/c82f99e02ccd985aea3ad4a67a0c712c0aa88b91/core/libs/tests/GuestLibcStaticImports.cpp) ## Not verified The author-reported Windows test, firmware provider behavior, and full title execution were not independently verified. `files.json` lists no excluded files. The reviewed files were `core/libs/prx/libc/include/Api.hpp`, `core/libs/prx/libc/src/LibcxxLocaleFacet.cpp`, `core/libs/prx/libc/src/exception/StandardExceptions.cpp`, `core/libs/prx/libc/src/exception/TypeInfo.cpp`, `core/libs/tests/GuestLibcStaticImports.cpp`, and `docs/dev/debt/changes/feat-libc-streambuf-metadata.md`. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 01:04:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T01:04:24Z.

Review: COMMENTED


I built and linked the production locale-facet, type-info, and exception sources from c82f99e0 with GCC 14.2 on Linux and ran a standalone driver against both new exports. The locale hook left the stream buffer and supplied locale unchanged. The exported RTTI had the expected mangled name and its vtable address point led to the Itanium __class_type_info metatype. The driver linked the repository's runtime implementations for these checks.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6161897588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28657#pullrequestreview-6161897588). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T01:04:24Z. **Review:** COMMENTED --- I built and linked the production locale-facet, type-info, and exception sources from `c82f99e0` with GCC 14.2 on Linux and ran a standalone driver against both new exports. The locale hook left the stream buffer and supplied locale unchanged. The exported RTTI had the expected mangled name and its vtable address point led to the Itanium `__class_type_info` metatype. The driver linked the repository's runtime implementations for these checks. AI-assisted: yes.
Plyxen commented 2026-12-03 07:34:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T07:34:58Z.

Review: APPROVED


I read the diff at c82f99e02c. Merged into main at 35e34b1a7f0 together with other open PRs (so not an isolated build), Release, on Windows 11 (GCC 15.2) and Ubuntu 24.04 under WSL2 (GCC 13.3).

  • guest_libc_static_imports: passes on both.
  • The other guest_libcxx_* tests of that tree pass too (39 on Linux).
  • No control: the test needs exports that main does not have.

Not checked: a title.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6165444267 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28657#pullrequestreview-6165444267). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T07:34:58Z. **Review:** APPROVED --- I read the diff at `c82f99e02c`. Merged into `main` at `35e34b1a7f0` together with other open PRs (so not an isolated build), Release, on Windows 11 (GCC 15.2) and Ubuntu 24.04 under WSL2 (GCC 13.3). - `guest_libc_static_imports`: passes on both. - The other `guest_libcxx_*` tests of that tree pass too (39 on Linux). - No control: the test needs exports that `main` does not have. Not checked: a title. AI-assisted: yes (Claude Code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/28657:upstream-pr/28657'
git switch 'upstream-pr/28657'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/28657'
git switch 'upstream-pr/28657'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/28657'
git switch 'upstream-pr/28657'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/28657'
git switch 'main'
git merge --squash 'upstream-pr/28657'
git switch 'main'
git merge --ff-only 'upstream-pr/28657'
git switch 'main'
git merge 'upstream-pr/28657'
git push origin 'main'
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!28657
No description provided.