feat(libc): implement 16-bit wide string concatenation #4122

Closed
MiniRML wants to merge 2 commits from upstream-pr/4122 into main
MiniRML commented 2026-10-11 23:46:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MiniRML on 2026-10-11T23:46:38Z.


What

Provide the missing wcscat/wcsncat exports using the existing 16-bit guest wchar ABI. Concatenation copies code units unchanged, returns the original destination, and wcsncat appends a terminator even when its count limits the source.

These exports (wcscat, wcsncat) are named in the pinned symbol database used by AnyPS5's tools/nid_names.py. They are absent from the base implementation. The complete changed-file scan of 370 open PRs found no other added implementation of these exports. Related functions are kept together in one topic.

Sources and compatibility

The guest ABI follows the existing libc implementation: 16-bit wide code units, 64-bit long/intmax types, and x87 extended precision in 16-byte storage where used. PS5 hardware validation was not performed. Math exports that delegate to host libm do not establish bit-for-bit agreement with the console's libm; their tested behavior and that limitation are stated here.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, CMake 4.3.1, Ninja, Release, BUILD_TESTING=ON. Tested commit 8f0eced3e0b4f7f3cddca1e14f35c4494a23112d, based on upstream bab7b3285221495463a4a2494dc410cf137b4a92.

  • cmake --build build --target libc guest_libc_wide_concatenation_tests -j 8 passed.
  • ctest --test-dir build -R '^guest_libc_wide_concatenation$' --output-on-failure --no-tests=error passed (one behavioral regression test, multiple assertions).
  • Base conventions checker and whitespace checks passed.
  • The real NID patcher was run on a temporary copy of the built libc module; all new symbol hashes were verified in its PE export table, and the temporary module was removed.
  • Merge simulation found no newly introduced build-registration conflict with the existing open PRs that edit this CMake file, and no conflicts with the other validated topics in this batch.
  • Initial validation found a Windows build error on base bab7b3285 (HostPoll undeclared). Upstream fixed it in merged #4021; the follow-up combined full build below passed.
  • The full CTest suite and Linux runtime tests were not run. Existing Defender-blocked relinker tests were not rerun; Defender remained enabled.

Checklist

  • Based on main; no other open PR implements the same functions
  • One topic per PR
  • No code comments added
  • No silent stubs added
  • No investigation notes, logs, images or extra repository copies added
  • No third-party code added
  • General behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Codex)

Follow-up combined validation

Updated this branch to upstream bca7a29d259299aaa8972c94d12694232bb3bb08 without changing this topic's tested libc or regression source files. Current PR head: 013f1b8fc23e37e2c3f4da6e058505758d7b0aa9; independent tested head: 8f0eced3e0b4f7f3cddca1e14f35c4494a23112d.

All 19 independent topics were then merged together on that upstream base in validation commit f1721a1c6caebf3a95bdf312d06dbf2de7f938c0 (saved in the fork under validation/libc-library-batch-2026-10-11):

  • cmake --build build --target all libs -j 8 passed on Windows 11.
  • All 19 new behavioral CTest tests passed together with four workers.
  • All 37 new NIDs were verified in the actual combined patched libc export table.
  • Every sibling branch merged cleanly in the combined checkout; the independent topic sources remain unchanged.

The earlier full-suite investigation remains paused. Linux runtime and PS5 hardware validation were not performed.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4823293551 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4122). Originally posted by [MiniRML](https://github.com/MiniRML) on 2026-10-11T23:46:38Z. --- ### What Provide the missing wcscat/wcsncat exports using the existing 16-bit guest wchar ABI. Concatenation copies code units unchanged, returns the original destination, and wcsncat appends a terminator even when its count limits the source. These exports (wcscat, wcsncat) are named in the pinned symbol database used by AnyPS5's `tools/nid_names.py`. They are absent from the base implementation. The complete changed-file scan of 370 open PRs found no other added implementation of these exports. Related functions are kept together in one topic. ### Sources and compatibility - [Reference](https://github.com/freebsd/freebsd-src/blob/releng/11.0/lib/libc/string/wcscat.c) - [Reference](https://github.com/freebsd/freebsd-src/blob/releng/11.0/lib/libc/string/wcsncat.c) The guest ABI follows the existing libc implementation: 16-bit wide code units, 64-bit long/intmax types, and x87 extended precision in 16-byte storage where used. PS5 hardware validation was not performed. Math exports that delegate to host libm do not establish bit-for-bit agreement with the console's libm; their tested behavior and that limitation are stated here. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, CMake 4.3.1, Ninja, Release, `BUILD_TESTING=ON`. Tested commit `8f0eced3e0b4f7f3cddca1e14f35c4494a23112d`, based on upstream `bab7b3285221495463a4a2494dc410cf137b4a92`. - `cmake --build build --target libc guest_libc_wide_concatenation_tests -j 8` passed. - `ctest --test-dir build -R '^guest_libc_wide_concatenation$' --output-on-failure --no-tests=error` passed (one behavioral regression test, multiple assertions). - Base conventions checker and whitespace checks passed. - The real NID patcher was run on a temporary copy of the built libc module; all new symbol hashes were verified in its PE export table, and the temporary module was removed. - Merge simulation found no newly introduced build-registration conflict with the existing open PRs that edit this CMake file, and no conflicts with the other validated topics in this batch. - Initial validation found a Windows build error on base bab7b3285 (`HostPoll` undeclared). Upstream fixed it in merged #4021; the follow-up combined full build below passed. - The full CTest suite and Linux runtime tests were not run. Existing Defender-blocked relinker tests were not rerun; Defender remained enabled. ### Checklist - [x] Based on main; no other open PR implements the same functions - [x] One topic per PR - [x] No code comments added - [x] No silent stubs added - [x] No investigation notes, logs, images or extra repository copies added - [x] No third-party code added - [x] General behavior, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Codex) ### Follow-up combined validation Updated this branch to upstream `bca7a29d259299aaa8972c94d12694232bb3bb08` without changing this topic's tested libc or regression source files. Current PR head: `013f1b8fc23e37e2c3f4da6e058505758d7b0aa9`; independent tested head: `8f0eced3e0b4f7f3cddca1e14f35c4494a23112d`. All 19 independent topics were then merged together on that upstream base in validation commit `f1721a1c6caebf3a95bdf312d06dbf2de7f938c0` (saved in the fork under `validation/libc-library-batch-2026-10-11`): - `cmake --build build --target all libs -j 8` passed on Windows 11. - All 19 new behavioral CTest tests passed together with four workers. - All 37 new NIDs were verified in the actual combined patched libc export table. - Every sibling branch merged cleanly in the combined checkout; the independent topic sources remain unchanged. The earlier full-suite investigation remains paused. Linux runtime and PS5 hardware validation were not performed.
github-actions[bot] commented 2026-10-11 23:47:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T23:47:02Z.


Progress report (bca7a29 → 013f1b8)

📈 System libraries: 86.48% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libc wcscat_nid_postfix
libc wcsncat_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115258072 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4122#issuecomment-6115258072). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T23:47:02Z. --- <!-- progress-report --> ### Progress report (bca7a29 → 013f1b8) 📈 **System libraries**: 86.48% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `wcscat_nid_postfix` | | libc | `wcsncat_nid_postfix` | </details>
github-actions[bot] commented 2026-10-12 05:25:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T05:25:19Z.


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
#4277 core/libs/prx/libc/CMakeLists.txt L80
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6118298167 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4122#issuecomment-6118298167). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T05:25:19Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #4277 | `core/libs/prx/libc/CMakeLists.txt` [L80](https://github.com/boykopovar/AnyPS5/blob/8c4a295ffb7bc471a5bcee2287fd38e499d003a2/core/libs/prx/libc/CMakeLists.txt#L80) | | |
oneandonlydean commented 2026-10-12 08:26:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:26:07Z.


Closing: no title is shown to reach wcscat or wcsncat on main; they come from the symbol database, and library functions go in when a title stops at them. Reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120549029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4122#issuecomment-6120549029). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T08:26:07Z. --- Closing: no title is shown to reach `wcscat` or `wcsncat` on main; they come from the symbol database, and library functions go in when a title stops at them. Reopen with the title ID and the log line.

Pull request closed

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!4122
No description provided.