fix(libc): build the libc++ codecvt<char> test with clang #27827

Merged
magnub merged 1 commit from upstream-pr/27827 into main 2026-12-03 14:30:44 +00:00
magnub commented 2026-11-27 14:29:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by magnub on 2026-11-27T14:29:50Z.


What

GuestLibcxxCodecvtChar.cpp (from 19a1c07a71) cast codecvtRecord.vtable[5] and guestType.vtable[5], both const void*, straight to the Upcast function pointer type. GCC accepts that; clang rejects it ("reinterpret_cast from 'const void *' to 'Upcast' ... casts away qualifiers"), so guest_libcxx_codecvt_char_tests does not build on macOS. Both casts now go through const_cast<void*>, as the merged #27320 did for GuestLibcxxRegexError.cpp. Test-only change.

Tested

macOS 27.0.1 (26A434) on an Apple M1 Pro, Apple clang 21.0.0, x86_64 Release build under Rosetta 2. Build: main 2b6c1b0445 plus #17425, #11049, #26739 and #25331, which the macOS build needs:

  • main: guest_libcxx_codecvt_char_tests fails to build with the error above, at lines 149 and 150.
  • this PR: it builds, and guest_libcxx_codecvt_char passes 3/3.

tools/check_conventions.py --base origin/main passes. Log attached.

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 (Claude Code)

🤖 Generated with Claude Code

https://claude.ai/code/session_012LL9hfx4BY6MbUCYMduDAQ

Summary by CodeRabbit

  • Tests
    • Updated internal codecvt casting checks. These changes are limited to test coverage and do not alter application behavior or affect end-user functionality. No user-facing features or behavior changes are included in this update.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5528305579 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27827). Originally posted by [magnub](https://github.com/magnub) on 2026-11-27T14:29:50Z. --- ### What `GuestLibcxxCodecvtChar.cpp` (from 19a1c07a71b) cast `codecvtRecord.vtable[5]` and `guestType.vtable[5]`, both `const void*`, straight to the `Upcast` function pointer type. GCC accepts that; clang rejects it ("reinterpret_cast from 'const void *' to 'Upcast' ... casts away qualifiers"), so `guest_libcxx_codecvt_char_tests` does not build on macOS. Both casts now go through `const_cast<void*>`, as the merged #27320 did for `GuestLibcxxRegexError.cpp`. Test-only change. ### Tested macOS 27.0.1 (26A434) on an Apple M1 Pro, Apple clang 21.0.0, x86_64 Release build under Rosetta 2. Build: `main` `2b6c1b0445` plus #17425, #11049, #26739 and #25331, which the macOS build needs: - main: `guest_libcxx_codecvt_char_tests` fails to build with the error above, at lines 149 and 150. - this PR: it builds, and `guest_libcxx_codecvt_char` passes 3/3. `tools/check_conventions.py --base origin/main` passes. Log attached. ### Checklist - [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 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 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: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012LL9hfx4BY6MbUCYMduDAQ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Tests** * Updated internal codecvt casting checks. These changes are limited to test coverage and do not alter application behavior or affect end-user functionality. No user-facing features or behavior changes are included in this update. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-27 14:41:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T14:41:38Z.

Review: APPROVED


Reviewed — looks good

The change fixes the two const-qualification casts in the codecvt test; the changed lines are consistent with the described clang build issue.

What I ran

Reviewed head 24b2a7b252ccf864a6c4cd573337ccf43d5dc6a2 using repo_read.py to inspect the prepared diff and the complete changed file. No build or tests were run during this review.

Results

Check Result Note
Diff and changed file passed Two casts updated
Build and tests not run Author reports macOS build and test results

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported macOS build, test run, and conventions check were not independently verified. No repository files were excluded from review; the changed file core/libs/tests/GuestLibcxxCodecvtChar.cpp was read in full. review/files.json was not available in the review folder; the reader's file listing confirmed the changed-file manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6089793558 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27827#pullrequestreview-6089793558). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T14:41:38Z. **Review:** APPROVED --- # Reviewed — looks good The change fixes the two const-qualification casts in the codecvt test; the changed lines are consistent with the described clang build issue. ## What I ran Reviewed head `24b2a7b252ccf864a6c4cd573337ccf43d5dc6a2` using `repo_read.py` to inspect the prepared diff and the complete changed file. No build or tests were run during this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed file | passed | Two casts updated | | Build and tests | not run | Author reports macOS build and test results | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author-reported macOS build, test run, and conventions check were not independently verified. No repository files were excluded from review; the changed file `core/libs/tests/GuestLibcxxCodecvtChar.cpp` was read in full. `review/files.json` was not available in the review folder; the reader's file listing confirmed the changed-file manifest. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-27 14:50:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T14:50:18Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 24b2a7b252:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libcxx_codecvt_char_tests built cleanly.
  • CTest (guest_libcxx_codecvt_char):
    1/1 Test #1622: guest_libcxx_codecvt_char ........   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified that const_cast<void*>(codecvtRecord.vtable[5]) and const_cast<void*>(guestType.vtable[5]) in CheckTypeInfo correctly remove const qualification before reinterpret_cast, resolving Clang's rejection of casting away cv-qualifiers in reinterpret_cast.
    • Confirmed that Upcast function pointer signature and invocation with arguments (codecvtType, target, &adjusted) are unaffected and type-safe.
    • Verified no memory safety, pointer bounds, or lifetime issues are introduced by the cast adjustment in GuestLibcxxCodecvtChar.cpp.
    • Verified AGENTS.md conventions compliance: no comments added, conventional commit format followed, and no unauthorized files or dependencies added.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6089903399 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27827#pullrequestreview-6089903399). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-27T14:50:18Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `24b2a7b252`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libcxx_codecvt_char_tests` built cleanly. - **CTest** (`guest_libcxx_codecvt_char`): ``` 1/1 Test #1622: guest_libcxx_codecvt_char ........ Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Code reading**: - Verified that const_cast<void*>(codecvtRecord.vtable[5]) and const_cast<void*>(guestType.vtable[5]) in CheckTypeInfo correctly remove const qualification before reinterpret_cast<Upcast>, resolving Clang's rejection of casting away cv-qualifiers in reinterpret_cast. - Confirmed that Upcast function pointer signature and invocation with arguments (codecvtType, target, &adjusted) are unaffected and type-safe. - Verified no memory safety, pointer bounds, or lifetime issues are introduced by the cast adjustment in GuestLibcxxCodecvtChar.cpp. - Verified AGENTS.md conventions compliance: no comments added, conventional commit format followed, and no unauthorized files or dependencies added. Looks Good To Me
JJenkx commented 2026-11-27 15:19:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-27T15:19:46Z.

Review: COMMENTED


Linux clang 23.1.5, x86-64, independently confirms the compiler difference. Compiling the GuestLibcxxCodecvtChar.cpp translation unit from base 2b6c1b0445 rejected both upcasts because they cast away qualifiers. The file from exact head 24b2a7b252c compiled and linked against the same locally built Linux libc.prx, which is unchanged in this PR. The resulting codecvt test executable passed 3/3 runs.

This was a focused clang build of the test translation unit against the existing GCC-built PRX. AI-assisted.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6090262923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27827#pullrequestreview-6090262923). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-27T15:19:46Z. **Review:** COMMENTED --- Linux clang 23.1.5, x86-64, independently confirms the compiler difference. Compiling the `GuestLibcxxCodecvtChar.cpp` translation unit from base `2b6c1b0445` rejected both upcasts because they cast away qualifiers. The file from exact head `24b2a7b252c` compiled and linked against the same locally built Linux `libc.prx`, which is unchanged in this PR. The resulting codecvt test executable passed 3/3 runs. This was a focused clang build of the test translation unit against the existing GCC-built PRX. AI-assisted.
ligmaSec commented 2026-12-03 08:39:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:39:32Z.

Review: COMMENTED


The Linux libc++ codecvt fixture passed with the patched test source. This focused run used GCC, so the Clang-specific compile result is the author’s evidence.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6166259791 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27827#pullrequestreview-6166259791). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T08:39:32Z. **Review:** COMMENTED --- The Linux libc++ codecvt fixture passed with the patched test source. This focused run used GCC, so the Clang-specific compile result is the author’s evidence. AI-assisted: yes.
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!27827
No description provided.