fix(libc): declare the __sub_kind values on libc++abi hosts #26739
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26739"
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 Romannachwievor on 2026-11-24T18:24:57Z.
What
libc no longer compiles on macOS since #10416. The RTTI cast callbacks it added to
core/libs/prx/libc/src/exception/Runtime.cppuse the__class_type_info::__sub_kindenumerators (__not_contained,__contained_ambig,__contained_virtual_mask,__contained_public_mask,__contained_public). libstdc++ declares them incxxabi.h. libc++abi does not, and the declaration this repo supplies for it incore/libs/prx/libc/include/specifics/itanium/CxxAbi.hpp(the#ifdef _LIBCPPABI_VERSIONbranch) only had__unknown:This adds the missing enumerators with the values libstdc++ uses. I checked them against GCC 15.2
cxxabi.h:__virtual_mask1,__public_mask2 and__hwm_bit2 give__contained_mask4,__contained_private4 and__contained_public6. Only the libc++abi branch changes, so Linux and Windows, which use libstdc++, compile the same code as before. Emscripten also defines_LIBCPPABI_VERSIONand gets the same enumerators.main CI has no macOS job, which is probably why this went unnoticed.
tools/pr_overlap.py --branchfound no overlap with the 2482 open pull requests.--names UpcastTypeInfoResult DynamicCastTypeInfofound them implemented onmainonly.Tested
Apple M1, macOS 26.5, x86_64 build under Rosetta, AppleClang.
libconmainat17220db6a3fails with the error above. With this change it builds.ctest --test-dir build -R '^guest_dynamic_cast$': passed in 3 of 3 runs.core/libs/tests/GuestDynamicCast.cppcompares the callback results against the literal path values 1, 2, 4, 6 and 7, so each enumerator Runtime.cpp uses is checked by value.main(6d85fbf66b):libcbuilds andguest_dynamic_castpasses 3 of 3.__contained_public = 4,guest_dynamic_castfails.__cxa_*, RTTI and JSON test executables: 157 of 160 pass with this change. A main build from before #10416 (adacf0bd83) on the same machine also passes 157 of 160, with the same three failures (guest_libc_internal_exception_virtuals,guest_libcxx_exception_pointer,guest_throw_bad_array_new_length).Not run: Linux, Windows, Emscripten.
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)Imported from boykopovar/AnyPS5. Originally posted by kripotker on 2026-11-24T18:51:20Z.
Review: APPROVED
Review: fix(libc): declare the __sub_kind values on libc++abi hosts
Approve. The values match libstdc++, and giving libc++abi hosts the same values is the right choice.
What I checked
libsupc++/cxxabi.h. There,__virtual_mask = 0x1,__public_mask = 0x2and__hwm_bit = 2, which gives:__not_contained1;__contained_ambig2;__contained_virtual_mask1;__contained_public_mask2;__contained_mask=1 << 2= 4;__contained_private4;__contained_public6.Runtime.cppdefines its own__upcast_resultand__dyncast_result, andUpcastTypeInfoResult/DynamicCastTypeInfowrite the values into them for the guest. So the guest sees the samepart2dst,whole2dst,whole2srcanddst2srcvalues whether the host uses libstdc++ or libc++abi. libc++abi's own internal constants don't matter here.#ifdef _LIBCPPABI_VERSIONbranch ofCxxAbi.hppchanges, so libstdc++ hosts (Linux, Windows) compile the same code as before.What I ran
All conventions checks passed.(Windows 11, PR head6d85fbf66b.)Not checked
I have no macOS or Emscripten host here, so I didn't compile the libc++abi branch myself.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T14:21:44Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
6d85fbf66b6d14d32b788cb4b8e5ee122df1c05a. Readdescription.md,commits.md,manifest.json,diff.patch, and the complete changed header. No tests or builds were run during this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No programmatic checks were run. The author's reported macOS build and test results were not independently verified.
files.jsonwas unavailable through the provided reader, so excluded files were not confirmed; the manifest lists one changed file and it was read in full.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Quimera996 on 2026-11-25T21:16:29Z.
Review: COMMENTED
Tested on a second Mac.
Setup: Apple M5, macOS 27.2.1, Apple clang 21.0.0 (Xcode 27.2), x86-64 Release under Rosetta 2. Head
6d85fbf66bapplied onmainff5b409ddawithgit apply, which is clean. The control is thatmainwithout it.mainninja libcexception/Runtime.cpp:no member named '__contained_virtual_mask' in '__cxxabiv1::__class_type_info'and the same for the other enumeratorsguest_dynamic_castninja -k 0)libcurl.prx(#17425),GuestLibcxxRegexError.cppandPipelinedFlushReadOrder.cppValues. I compared them with
libstdc++-v3/libsupc++/cxxabi.hat thereleases/gcc-15.2.0tag:__virtual_mask0x1,__public_mask0x2 and__hwm_bit2 give 0, 1, 2, 1, 2, 4, 4 and 6, as declared here.Wrong values. I changed one value at a time and rebuilt
libcand the test.guest_dynamic_castaborts with each of__not_contained = 3,__contained_ambig = 3,__contained_virtual_mask = 0,__contained_public_mask = 4and__contained_public = 4, and passes again (3 of 3) with the PR's values back. Those are the five new enumeratorsRuntime.cppuses. Nothing uses__contained_maskor__contained_private, so no test covers those two.Full suite.
ctest --parallel 8 --timeout 120withSDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy, 6635 tests: 5009 passed, 1573 skipped, 18 failed, and 35 did not run because their executables are behind the three targets above.exception,unwind,cxa,rtti,dynamic_cast,typeinfo,type_info,throw,catchorterminatein their name, 176 pass. Three of the four that fail are the ones the description lists. The fourth isguest_exception_pointer, which #25087 added tomainafter this head was made. It aborts atcurrent_exception inside catch returned wrong pointer, in a block that throws and catches in the test itself and has no cast.agc_unit_flags_allocation_failure_populated,agc_write_tracking,file_streams,guest_audio_propagation,guest_kernel_sys,guest_kernel_sys_execve,guest_math,guest_math_exact,guest_poll,guest_sce_net,guest_socket_options,guest_socket_port_zero,guest_udpandrun_report. I have no control run for them, becausemaindoes not build here without this PR. The new enumerators are used only inRuntime.cpp.#27201, opened a day later, declares the same eight values.
No title was run. Linux and Windows were not built.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:36:24Z.
Review: COMMENTED
Compiled the exact header with Clang 19 and libc++abi and with GCC and libstdc++. Both compile-time probes verified all eight enum values.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.