refactor(libs): add full export headers for libs #10706

Merged
boykopovar merged 19 commits from upstream-pr/10706 into main 2026-10-24 22:44:04 +00:00
boykopovar commented 2026-10-24 18:34:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-10-24T18:34:04Z.


What

Added umbrella headers for 368 libraries and canonical declarations for exported functions (suitable for writing homebrew apps compatible with our libs, which means they are also compatible with PS5 libraries). Removed duplicate declarations and types from sources and tests. Added the Python public_headers test and the corresponding CONTRIBUTING rule.

Tested

Windows: new public_headers passed for 368 libraries and 12,168 exports. Checked declaration uniqueness, umbrella coverage and standalone header compilation.

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
  • 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; header and declaration changes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4998054578 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10706). Originally posted by [boykopovar](https://github.com/boykopovar) on 2026-10-24T18:34:04Z. --- ### What Added umbrella headers for 368 libraries and canonical declarations for exported functions (suitable for writing homebrew apps compatible with our libs, which means they are also compatible with PS5 libraries). Removed duplicate declarations and types from sources and tests. Added the Python `public_headers` test and the corresponding CONTRIBUTING rule. ### Tested Windows: new `public_headers` passed for 368 libraries and 12,168 exports. Checked declaration uniqueness, umbrella coverage and standalone header compilation. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a; header and declaration changes
MarcZX10 commented 2026-10-24 18:39:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T18:39:59Z.

Review: CHANGES_REQUESTED


Reviewed head fed4f8c59d335f3e145ccfc3ab4eb3cecbc56ec7 against current main (0ea0f25e1bfbf63e90bc28a3ca1bc4cd2a3972f6). The current Conventions check fails on a concrete duplicate export: sceMsgDialogGetResult is implemented/exported in both libSceMsgDialog/Export.cpp and libSceMsgDialog.native/Export.cpp. I reproduced that exact finding with the repository checker. Please resolve the duplicate according to the checker guidance (remove the duplicate export, or use APS5_DUMMY_FUN if no implementation remains). The branch also does not merge cleanly with current main: merge-tree reports conflicts in core/libs/prx/libSceAudioOut/tests/AudioOut2DeviceState.cpp, core/libs/prx/libc/src/Math.cpp, and core/libs/tests/GuestLocale.cpp; please rebase/resolve those and rerun conventions. git diff --check passes. Hosted intake and labels pass; both recent hosted Conventions runs fail on the duplicate. The full build/test jobs have not run, so I have not treated the Windows header test described in the PR as hosted validation.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639456022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10706#pullrequestreview-5639456022). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T18:39:59Z. **Review:** CHANGES_REQUESTED --- Reviewed head `fed4f8c59d335f3e145ccfc3ab4eb3cecbc56ec7` against current `main` (`0ea0f25e1bfbf63e90bc28a3ca1bc4cd2a3972f6`). The current Conventions check fails on a concrete duplicate export: `sceMsgDialogGetResult` is implemented/exported in both `libSceMsgDialog/Export.cpp` and `libSceMsgDialog.native/Export.cpp`. I reproduced that exact finding with the repository checker. Please resolve the duplicate according to the checker guidance (remove the duplicate export, or use `APS5_DUMMY_FUN` if no implementation remains). The branch also does not merge cleanly with current main: merge-tree reports conflicts in `core/libs/prx/libSceAudioOut/tests/AudioOut2DeviceState.cpp`, `core/libs/prx/libc/src/Math.cpp`, and `core/libs/tests/GuestLocale.cpp`; please rebase/resolve those and rerun conventions. `git diff --check` passes. Hosted intake and labels pass; both recent hosted Conventions runs fail on the duplicate. The full build/test jobs have not run, so I have not treated the Windows header test described in the PR as hosted validation.
MarcZX10 commented 2026-10-24 19:07:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T19:07:07Z.

Review: COMMENTED


Follow-up on updated head c346adce8874ed8cefe10bdab8c599890dd2c1bf: the duplicate sceMsgDialogGetResult is now removed and the conventions check passes. The merge state is still DIRTY only in AudioOut2DeviceState.cpp; I checked the new AudioOut2.hpp/AudioOut.hpp in this branch and they contain the two declarations (sceAudioOut2Initialize and sceAudioOutInit) added on main, so resolving the conflict by keeping the canonical-header include should preserve those APIs. Please rebase/resolve that final conflict and rerun the header test on the updated head. One signature coordination remains: this branch keeps sceCompanionUtilGetEvent() parameterless because the native body does not reveal an argument, while open #10705 declares void* from a PS4-derived prototype. Please align that canonical declaration with the maintainer-selected source before merge, or document an explicit decision to retain the conservative signature.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639548180 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10706#pullrequestreview-5639548180). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T19:07:07Z. **Review:** COMMENTED --- Follow-up on updated head c346adce8874ed8cefe10bdab8c599890dd2c1bf: the duplicate `sceMsgDialogGetResult` is now removed and the conventions check passes. The merge state is still DIRTY only in `AudioOut2DeviceState.cpp`; I checked the new `AudioOut2.hpp`/`AudioOut.hpp` in this branch and they contain the two declarations (`sceAudioOut2Initialize` and `sceAudioOutInit`) added on main, so resolving the conflict by keeping the canonical-header include should preserve those APIs. Please rebase/resolve that final conflict and rerun the header test on the updated head. One signature coordination remains: this branch keeps `sceCompanionUtilGetEvent()` parameterless because the native body does not reveal an argument, while open #10705 declares `void*` from a PS4-derived prototype. Please align that canonical declaration with the maintainer-selected source before merge, or document an explicit decision to retain the conservative signature.
imellag commented 2026-10-24 19:40:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-24T19:40:39Z.

Review: COMMENTED


Built against macOS and Linux, since the PR was tested on Windows only. I compiled every .cpp under core/libs with -fsyntax-only, once on this branch and once on its base c035bd5b70, with the same flags each time. The counts below are files that compile on the base and fail on the branch. I measured on fed4f8c59d, so the counts are from that head. I then re-checked each point on the rebased head f57552b4aa: all of them still apply except item 3 under Linux, which that head fixes.

Linux: GCC 14 (gcc:14 image, x86-64)

22 files that compile on the base fail on this branch. Seven of them are libc and libkernel sources, so those two libraries no longer build on Linux:

  1. sigreturn. libkernel/include/Api.hpp:169 declares int APS5_VABI sigreturn();, which conflicts with glibc's int sigreturn(struct sigcontext*) in <signal.h>. Before, it was declared only in libkernel/Unimplemented.cpp. This breaks Pthread/src/Thread.cpp, System/src/Exception.cpp, System/src/Signals.cpp and 13 tests (GuestSignals, GuestItimer, GuestKill, GuestSslTransport, ...).
  2. ElfTypes.hpp. libc/include/Api.hpp and libkernel/include/Api.hpp include specifics/linux/ElfTypes.hpp unconditionally. On Linux, the files that also include the real <elf.h> and <link.h> now see conflicting declarations (typedef struct Elf64_Phdr, a redefinition of dl_phdr_info). This breaks Module/src/ModuleInfo.cpp, System/src/Rtld.cpp and Time/Time.cpp.
  3. strerror_r_nid_postfix (fixed in f57552b4aa, which declares it in libc/include/Api.hpp:202). libc/src/Syslog.cpp:54 lost its local declaration of the function. The function is now declared only in WindowsFormatting.hpp, which Syslog.cpp includes under _WIN32, so outside Windows it is undeclared.
  4. Tests that Windows doesn't build:
    • GuestFopenErrors.cpp (if(UNIX)) passes a void* where fopen_s_nid_postfix now takes FileStream*.
    • SharedWrites.cpp:250 converts a void* to uint64_t.
    • GuestAmprThreads.cpp:496, in the #ifndef _WIN32 block, uses type->name as a field of what is now a std::type_info*.

macOS: Apple clang 21.0.0, libc++, x86-64 (macOS 27.0.1)

292 files that compile on the base fail on this branch.

288 of them come from one block, libc/include/Api.hpp:1094-1101 (1095-1102 on f57552b4aa, still unguarded). It declares the libstdc++-specific exports (_ZNSt13__future_base12_Result_baseD2Ev with std::__future_base::_Result_base*, exception_ptr::_M_addref and the others with std::exception_ptr*). On main these exist only under #ifndef _LIBCPP_VERSION in ExceptionPointer.cpp. Its libc++ branch defines the same symbols with a GuestExceptionPointer*, because the guest's exception_ptr layout is not libc++'s.

With that block wrapped in #ifndef _LIBCPP_VERSION, 287 of the 292 compile again. The other five are:

  • Syslog.cpp, GuestFopenErrors.cpp and GuestAmprThreads.cpp: the same errors as on Linux.
  • GuestGenericCategory.cpp:64: a reinterpret_cast from const void* to a function pointer, which clang rejects as casting away qualifiers.
  • libSceVideoOut/tests/OutputModePolicy.cpp:19: it now needs #include <initializer_list>, which libc++ doesn't pull in transitively.

public_headers on macOS

The audit part passes: 368 libraries, 689 headers and 12168 exports with unique declarations and full umbrella coverage. The standalone header compilation fails on 19 headers, for three reasons:

  • The Api.hpp block above.
  • -Werror turns clang's -Wreturn-type-c-linkage into errors for 13 extern "C" declarations that return C++ types: the six std::filesystem::path and std::vector ones in General.hpp (already on main), five Hmd2::SizeAlign ones in Hmd2.hpp, one in Equeue.hpp and _ZSt17current_exceptionv_nid_postfix in Api.hpp. GCC has no such warning, so this would also fail on Linux with clang.
  • The test passes only CMAKE_CXX_COMPILER to --compiler. On an Apple Silicon Mac that compiler targets arm64 unless given -arch x86_64 (CMAKE_OSX_ARCHITECTURES in the build), so WindowsFormatting.hpp:354-355 also fails its static_asserts there.

Method: the macOS run uses each file's command from a -DCMAKE_OSX_ARCHITECTURES=x86_64 build. The Linux run uses g++ -std=gnu++20 -fsyntax-only with the project's include paths, without the build's generated headers or definitions. The same flags on the base are the control: 1881 of 2073 files compile there and 1859 on this branch, and no file fails on the base and compiles on this branch. I can re-run both on a new head.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639668840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10706#pullrequestreview-5639668840). Originally posted by [imellag](https://github.com/imellag) on 2026-10-24T19:40:39Z. **Review:** COMMENTED --- Built against macOS and Linux, since the PR was tested on Windows only. I compiled every `.cpp` under `core/libs` with `-fsyntax-only`, once on this branch and once on its base `c035bd5b70`, with the same flags each time. The counts below are files that compile on the base and fail on the branch. I measured on `fed4f8c59d`, so the counts are from that head. I then re-checked each point on the rebased head `f57552b4aa`: all of them still apply except item 3 under Linux, which that head fixes. ### Linux: GCC 14 (`gcc:14` image, x86-64) 22 files that compile on the base fail on this branch. Seven of them are `libc` and `libkernel` sources, so those two libraries no longer build on Linux: 1. **`sigreturn`.** `libkernel/include/Api.hpp:169` declares `int APS5_VABI sigreturn();`, which conflicts with glibc's `int sigreturn(struct sigcontext*)` in `<signal.h>`. Before, it was declared only in `libkernel/Unimplemented.cpp`. This breaks `Pthread/src/Thread.cpp`, `System/src/Exception.cpp`, `System/src/Signals.cpp` and 13 tests (`GuestSignals`, `GuestItimer`, `GuestKill`, `GuestSslTransport`, ...). 2. **`ElfTypes.hpp`.** `libc/include/Api.hpp` and `libkernel/include/Api.hpp` include `specifics/linux/ElfTypes.hpp` unconditionally. On Linux, the files that also include the real `<elf.h>` and `<link.h>` now see conflicting declarations (`typedef struct Elf64_Phdr`, a redefinition of `dl_phdr_info`). This breaks `Module/src/ModuleInfo.cpp`, `System/src/Rtld.cpp` and `Time/Time.cpp`. 3. **`strerror_r_nid_postfix`** (fixed in `f57552b4aa`, which declares it in `libc/include/Api.hpp:202`). `libc/src/Syslog.cpp:54` lost its local declaration of the function. The function is now declared only in `WindowsFormatting.hpp`, which `Syslog.cpp` includes under `_WIN32`, so outside Windows it is undeclared. 4. **Tests that Windows doesn't build:** - `GuestFopenErrors.cpp` (`if(UNIX)`) passes a `void*` where `fopen_s_nid_postfix` now takes `FileStream*`. - `SharedWrites.cpp:250` converts a `void*` to `uint64_t`. - `GuestAmprThreads.cpp:496`, in the `#ifndef _WIN32` block, uses `type->name` as a field of what is now a `std::type_info*`. ### macOS: Apple clang 21.0.0, libc++, x86-64 (macOS 27.0.1) 292 files that compile on the base fail on this branch. **288 of them** come from one block, `libc/include/Api.hpp:1094-1101` (`1095-1102` on `f57552b4aa`, still unguarded). It declares the libstdc++-specific exports (`_ZNSt13__future_base12_Result_baseD2Ev` with `std::__future_base::_Result_base*`, `exception_ptr::_M_addref` and the others with `std::exception_ptr*`). On `main` these exist only under `#ifndef _LIBCPP_VERSION` in `ExceptionPointer.cpp`. Its libc++ branch defines the same symbols with a `GuestExceptionPointer*`, because the guest's `exception_ptr` layout is not libc++'s. With that block wrapped in `#ifndef _LIBCPP_VERSION`, 287 of the 292 compile again. The other five are: - `Syslog.cpp`, `GuestFopenErrors.cpp` and `GuestAmprThreads.cpp`: the same errors as on Linux. - `GuestGenericCategory.cpp:64`: a `reinterpret_cast` from `const void*` to a function pointer, which clang rejects as casting away qualifiers. - `libSceVideoOut/tests/OutputModePolicy.cpp:19`: it now needs `#include <initializer_list>`, which libc++ doesn't pull in transitively. ### `public_headers` on macOS The audit part passes: 368 libraries, 689 headers and 12168 exports with unique declarations and full umbrella coverage. The standalone header compilation fails on 19 headers, for three reasons: - The `Api.hpp` block above. - `-Werror` turns clang's `-Wreturn-type-c-linkage` into errors for 13 `extern "C"` declarations that return C++ types: the six `std::filesystem::path` and `std::vector` ones in `General.hpp` (already on `main`), five `Hmd2::SizeAlign` ones in `Hmd2.hpp`, one in `Equeue.hpp` and `_ZSt17current_exceptionv_nid_postfix` in `Api.hpp`. GCC has no such warning, so this would also fail on Linux with clang. - The test passes only `CMAKE_CXX_COMPILER` to `--compiler`. On an Apple Silicon Mac that compiler targets arm64 unless given `-arch x86_64` (`CMAKE_OSX_ARCHITECTURES` in the build), so `WindowsFormatting.hpp:354-355` also fails its `static_assert`s there. Method: the macOS run uses each file's command from a `-DCMAKE_OSX_ARCHITECTURES=x86_64` build. The Linux run uses `g++ -std=gnu++20 -fsyntax-only` with the project's include paths, without the build's generated headers or definitions. The same flags on the base are the control: 1881 of 2073 files compile there and 1859 on this branch, and no file fails on the base and compiles on this branch. I can re-run both on a new head. 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!10706
No description provided.