feat(libScePosixForWebKit): export pthread_setname_np #8080

Merged
Nixitov merged 3 commits from upstream-pr/8080 into main 2026-10-25 07:11:30 +00:00
Nixitov commented 2026-10-19 20:25:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-19T20:25:31Z.


What

Exports pthread_setname_np (cB4rMoKU4UI) from libScePosixForWebKit. The module already had pthread_getname_np through libkernel, but no setter in its export set, so a title importing the setter from this module fails to load.

The name is stored in libkernel's thread object under its nameLock, so pthread_getname_np returns what was set (set/get consistency), and the error values follow libkernel's pthread_rename_np: EINVAL (22) for a null thread or name, ENAMETOOLONG (63) from 32 bytes on, 0 otherwise, with the name read back truncated to 31 bytes. The Windows thread description and job affinity that scePthreadRename applies are not duplicated here because those helpers are private to libkernel; that and the unverified console error numbers are recorded in the library's technical debt.

Tested

New guest_posix_thread_name test: sets and reads names back through the pair, covering the empty name, the 31-byte maximum, the 32-byte ENAMETOOLONG case and null arguments. It passes on Windows (MinGW-w64 GCC 15.2, Release); check_conventions.py --base origin/main passes.

PPSA98512 (FFTARecomp), relinked against main 3d4da7ad0:

  • Before: FAIL: unresolved ELF import cB4rMoKU4UI from libScePosixForWebKit.prx (GetLastError: 127), exits at load.
  • With this PR: loads and runs the full 12 s with no unresolved import.

Checklist

  • Based on current main; no other open PR implements the same function
  • 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: PPSA98512 #9758
  • GPUs tested: n/a (POSIX thread naming; no AGC, shader recompiler or VideoOut change)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4926944484 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8080). Originally posted by [Nixitov](https://github.com/Nixitov) on 2026-10-19T20:25:31Z. --- ### What Exports `pthread_setname_np` (`cB4rMoKU4UI`) from `libScePosixForWebKit`. The module already had `pthread_getname_np` through libkernel, but no setter in its export set, so a title importing the setter from this module fails to load. The name is stored in libkernel's thread object under its `nameLock`, so `pthread_getname_np` returns what was set (set/get consistency), and the error values follow libkernel's `pthread_rename_np`: `EINVAL` (22) for a null thread or name, `ENAMETOOLONG` (63) from 32 bytes on, `0` otherwise, with the name read back truncated to 31 bytes. The Windows thread description and job affinity that `scePthreadRename` applies are not duplicated here because those helpers are private to libkernel; that and the unverified console error numbers are recorded in the library's technical debt. ### Tested New `guest_posix_thread_name` test: sets and reads names back through the pair, covering the empty name, the 31-byte maximum, the 32-byte `ENAMETOOLONG` case and null arguments. It passes on Windows (MinGW-w64 GCC 15.2, Release); `check_conventions.py --base origin/main` passes. PPSA98512 (FFTARecomp), relinked against `main` `3d4da7ad0`: - Before: `FAIL: unresolved ELF import cB4rMoKU4UI from libScePosixForWebKit.prx` (`GetLastError: 127`), exits at load. - With this PR: loads and runs the full 12 s with no unresolved import. ### Checklist - [x] Based on current `main`; no other open PR implements the same function - [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: PPSA98512 #9758 - [x] GPUs tested: n/a (POSIX thread naming; no AGC, shader recompiler or VideoOut change) - [x] AI-assisted: yes
babyhuey commented 2026-10-20 03:54:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-20T03:54:23Z.


Linux run of this head (42d6112f0), since the description covers Windows only. Merged onto main 525e299fc (clean merge). Ubuntu 24.04 container, GCC 13, Release, BUILD_TESTING=ON.

  • guest_posix_thread_name passes 5 of 5 (--repeat until-fail:5).
  • FFTARecomp (PPSA98512), headless with SDL's offscreen driver: on main it stops at undefined symbol: cB4rMoKU4UI (pthread_setname_np). With this PR it loads and stops at the DisplayWindow Vulkan check, as titles do in a headless run.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6282988343 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8080#issuecomment-6282988343). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-20T03:54:23Z. --- Linux run of this head (42d6112f0), since the description covers Windows only. Merged onto `main` `525e299fc` (clean merge). Ubuntu 24.04 container, GCC 13, Release, `BUILD_TESTING=ON`. - `guest_posix_thread_name` passes 5 of 5 (`--repeat until-fail:5`). - FFTARecomp (PPSA98512), headless with SDL's offscreen driver: on `main` it stops at `undefined symbol: cB4rMoKU4UI (pthread_setname_np)`. With this PR it loads and stops at the `DisplayWindow` Vulkan check, as titles do in a headless run.
dantdmdarealguy commented 2026-10-21 02:11:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-21T02:11:44Z.


Independent Windows check of head 42d6112f00 against its merge base 3d4da7ad01, built one after the other in the same build directory, plus current main 3b5a24c0d. Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON.

FFTARecomp (PPSA98512) ps5-v1.0.0, catalog zip, sha256 380a34d5…e2d429d8 matching the catalog record. eboot.bin and sce_module/libc.prx unwrapped with tools/unwrap_self.py, relinked with relinker --windows --registry, package as app0, a fresh run directory per build. 60 s runs, no input.

  • Base: exits after 3.2 s with 0xC0000139:
    FAIL: unresolved ELF import cB4rMoKU4UI from libScePosixForWebKit.prx
    GetLastError: 127 - The specified procedure could not be found.
    
  • Current main 3b5a24c0d: the same stop after 3.0 s.
  • Head: still running at 60 s on the title's own "ROM NEEDED" screen (no ROM was supplied), 59.40 to 59.95 FPS in the window title. Exits 0 on WM_CLOSE. The log has no exception, terminate or not implemented line.
  • main 3b5a24c0d with this PR merged (together with #8083, #8119 + #8113 and #8255, which touch other libraries): the same, 59.95 FPS at 57 s, exit 0.

Tests

  • guest_posix_thread_name passes 3 of 3 (--repeat until-fail:3) on the head, and on main + this PR. patched_libraries passes on both.
  • Negative control: the head's test against the base's libScePosixForWebKit/Export.cpp doesn't link (undefined reference to 'pthread_setname_np_nid_postfix').
  • The incremental head build has no warnings. tools/check_conventions.py --base 3d4da7ad01 passes, and the branch merges into current main 3b5a24c0d without conflicts.

Not checked: whether FFTARecomp calls pthread_setname_np before its ROM check. The log doesn't name threads, so this run only shows the import resolving.

FFTARecomp on the head at 57 s, ROM NEEDED screen

The head's ROM NEEDED screen at 57 s. The base made no window.

Verdict: works on Windows. The load stop is gone on the merge base and on current main, the title runs to its ROM prompt, and the new test fails without the change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306287768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8080#issuecomment-6306287768). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-21T02:11:44Z. --- Independent Windows check of head `42d6112f00` against its merge base `3d4da7ad01`, built one after the other in the same build directory, plus current `main` `3b5a24c0d`. Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Ninja, Release, `BUILD_TESTING=ON`. **FFTARecomp (PPSA98512) ps5-v1.0.0**, catalog zip, sha256 `380a34d5…e2d429d8` matching the catalog record. `eboot.bin` and `sce_module/libc.prx` unwrapped with `tools/unwrap_self.py`, relinked with `relinker --windows --registry`, package as `app0`, a fresh run directory per build. 60 s runs, no input. - Base: exits after 3.2 s with `0xC0000139`: ``` FAIL: unresolved ELF import cB4rMoKU4UI from libScePosixForWebKit.prx GetLastError: 127 - The specified procedure could not be found. ``` - Current `main` `3b5a24c0d`: the same stop after 3.0 s. - Head: still running at 60 s on the title's own "ROM NEEDED" screen (no ROM was supplied), 59.40 to 59.95 FPS in the window title. Exits 0 on WM_CLOSE. The log has no exception, `terminate` or `not implemented` line. - `main` `3b5a24c0d` with this PR merged (together with #8083, #8119 + #8113 and #8255, which touch other libraries): the same, 59.95 FPS at 57 s, exit 0. **Tests** - `guest_posix_thread_name` passes 3 of 3 (`--repeat until-fail:3`) on the head, and on `main` + this PR. `patched_libraries` passes on both. - Negative control: the head's test against the base's `libScePosixForWebKit/Export.cpp` doesn't link (`undefined reference to 'pthread_setname_np_nid_postfix'`). - The incremental head build has no warnings. `tools/check_conventions.py --base 3d4da7ad01` passes, and the branch merges into current `main` `3b5a24c0d` without conflicts. Not checked: whether FFTARecomp calls `pthread_setname_np` before its ROM check. The log doesn't name threads, so this run only shows the import resolving. ![FFTARecomp on the head at 57 s, ROM NEEDED screen](https://raw.githubusercontent.com/dantdmdarealguy/AnyPS5/pr-assets/reviews/8080-fft-head-57s.png) The head's ROM NEEDED screen at 57 s. The base made no window. Verdict: works on Windows. The load stop is gone on the merge base and on current `main`, the title runs to its ROM prompt, and the new test fails without the change.
rooklz commented 2026-10-22 13:00:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-22T13:00:53Z.


A title that needs this, for the #5239 intake rule: PPSA98512 (FFTARecomp, the Final Fantasy Tactics Advance recompilation in the homebrew catalog, ps5-v1.0.0) imports cB4rMoKU4UI from libScePosixForWebKit with one call site, and on main a6dcea9279 the loader stops on it before anything runs:

./app.elf: symbol lookup error: ./app.elf: undefined symbol: cB4rMoKU4UI

With the export present (I had written the same forward locally before finding this PR, so I'm not opening it) the title starts, creates its Vulkan device, logs no cartridge found in /data/FFTARecomp: waiting for one and records its first draws. Bring-up thread with the details: #9758. Feel free to add Unblocks: PPSA98512 #9758.

One thought on the body: libkernel's pthread_rename_np already returns those errno values and keeps the Windows thread description, so forwarding to it (return pthread_rename_np_nid_postfix(thread, name);) gives the same results without the private helpers you mention.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341382572 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8080#issuecomment-6341382572). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-22T13:00:53Z. --- A title that needs this, for the #5239 intake rule: PPSA98512 (FFTARecomp, the Final Fantasy Tactics Advance recompilation in the homebrew catalog, `ps5-v1.0.0`) imports `cB4rMoKU4UI` from `libScePosixForWebKit` with one call site, and on `main` `a6dcea9279` the loader stops on it before anything runs: ``` ./app.elf: symbol lookup error: ./app.elf: undefined symbol: cB4rMoKU4UI ``` With the export present (I had written the same forward locally before finding this PR, so I'm not opening it) the title starts, creates its Vulkan device, logs `no cartridge found in /data/FFTARecomp: waiting for one` and records its first draws. Bring-up thread with the details: #9758. Feel free to add `Unblocks: PPSA98512 #9758`. One thought on the body: libkernel's `pthread_rename_np` already returns those `errno` values and keeps the Windows thread description, so forwarding to it (`return pthread_rename_np_nid_postfix(thread, name);`) gives the same results without the private helpers you mention.
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!8080
No description provided.