feat(libc): export tzname #5009

Merged
p3n1cillin merged 1 commit from upstream-pr/5009 into main 2026-10-14 01:27:27 +00:00
p3n1cillin commented 2026-10-13 08:03:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T08:03:44Z.


What

ES-DE, the second frontend in RetroArch (PPSA99169, /app0/es-de/es-de.bin), imports tzname from libSceLibcInternal, which nothing exports. Its relinked executable stops at load:

FAIL: unresolved ELF import BAYjQubSZT8 from libSceLibcInternal.prx

(BAYjQubSZT8 is tzname in the aerolib NID list; tools/import_audit.py reports it as the only absent import of es-de.bin.)

The only code in es-de.bin that reads it (0xF13ADB–0xF13C0C) is ICU's uprv_tzname: two localtime_r probes, the tm_isdst > 0 checks, then tzname[0] and tzname[1] passed to remapShortTimeZone, and tzname[n] returned when that finds nothing. ICU falls back to it when detecting the default time zone.

tzname is now a char*[2] data export of libc, next to tzset, which ES-DE also imports from libSceLibcInternal and which already resolves there. It points at the host's zone names (_tzname on Windows, tzname on Linux). It is filled when the library loads, after the existing Linux TZ setup, and refreshed by tzset, because glibc can move its strings when the zone changes. tm_zone and %Z already come from the same host names. The Windows full names without TZ, the empty or repeated daylight name of a zone without daylight-saving time, and the unknown console values are recorded in docs/dev/debt/libc.md.

Tested

  • guest_time_conversion (all 83 libc tests pass on Windows): after tzset with TZ=UTC-5, tzname[0] is UTC and tzname[1] is set; with TZ=EST5EDT, they are EST and EDT. Without the export the test does not link. glibc gives the same names for both strings (checked in Ubuntu/WSL with a C program); the full Linux build was not run locally.
  • RetroArch PPSA99169 v1.0.0-beta.1 on Windows 11 (MinGW GCC 15.2.0), with es-de.bin converted and started through #4786: before, the load fails as above. After, ES-DE starts and its own log records start: arguments for ES-DE 1. It creates its Vulkan device and swapchain and then stops in the AGC translator (last provoking vertex with explicit per-vertex triangle-strip interpolation is unsupported).
  • python tools/check_conventions.py --base origin/main passes.

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 (reaching ES-DE in RetroArch needs #4786)
  • Unblocks: ES-DE in RetroArch (PPSA99169)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4840246376 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5009). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T08:03:44Z. --- ### What ES-DE, the second frontend in RetroArch (PPSA99169, `/app0/es-de/es-de.bin`), imports `tzname` from `libSceLibcInternal`, which nothing exports. Its relinked executable stops at load: ``` FAIL: unresolved ELF import BAYjQubSZT8 from libSceLibcInternal.prx ``` (`BAYjQubSZT8` is `tzname` in the aerolib NID list; `tools/import_audit.py` reports it as the only absent import of `es-de.bin`.) The only code in `es-de.bin` that reads it (0xF13ADB–0xF13C0C) is ICU's [`uprv_tzname`](https://github.com/unicode-org/icu/blob/457157a92aa053e632cc7fcfd0e12f8a943b2d11/icu4c/source/common/putil.cpp#L1244-L1264): two `localtime_r` probes, the `tm_isdst > 0` checks, then `tzname[0]` and `tzname[1]` passed to `remapShortTimeZone`, and `tzname[n]` returned when that finds nothing. ICU falls back to it when detecting the default time zone. `tzname` is now a `char*[2]` data export of `libc`, next to `tzset`, which ES-DE also imports from `libSceLibcInternal` and which already resolves there. It points at the host's zone names (`_tzname` on Windows, `tzname` on Linux). It is filled when the library loads, after the existing Linux `TZ` setup, and refreshed by `tzset`, because glibc can move its strings when the zone changes. `tm_zone` and `%Z` already come from the same host names. The Windows full names without `TZ`, the empty or repeated daylight name of a zone without daylight-saving time, and the unknown console values are recorded in `docs/dev/debt/libc.md`. ### Tested - `guest_time_conversion` (all 83 libc tests pass on Windows): after `tzset` with `TZ=UTC-5`, `tzname[0]` is `UTC` and `tzname[1]` is set; with `TZ=EST5EDT`, they are `EST` and `EDT`. Without the export the test does not link. glibc gives the same names for both strings (checked in Ubuntu/WSL with a C program); the full Linux build was not run locally. - RetroArch PPSA99169 v1.0.0-beta.1 on Windows 11 (MinGW GCC 15.2.0), with `es-de.bin` converted and started through #4786: before, the load fails as above. After, ES-DE starts and its own log records `start: arguments for ES-DE 1`. It creates its Vulkan device and swapchain and then stops in the AGC translator (`last provoking vertex with explicit per-vertex triangle-strip interpolation is unsupported`). - `python tools/check_conventions.py --base origin/main` passes. ### 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 (reaching ES-DE in RetroArch needs #4786) - [x] Unblocks: ES-DE in RetroArch (PPSA99169) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
p3n1cillin commented 2026-10-13 09:07:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T09:07:48Z.


Follow-up Linux validation of this change on current main 4bb2c7f3947440d513b1dbd12143ec55b250495a: cleanly cherry-picked PR head 8d6b8df72c9c059d63a805791b9363a85651cc4c into an isolated local branch, alongside the independent Windows pipe-selection change from #5013. Exact integration head: 2e3b9eb35c775e1d429f6c42144a701a632859ae.

Ubuntu 26.04.1 / WSL2, GCC 15.2.0, Ninja Release, bundled dependencies, BUILD_TESTING=ON. Built the real libc and libkernel libraries and all their Linux-registered test targets. All 187 scoped tests passed (66 libc, 121 libkernel), no skips or failures, 3.73 s. guest_time_conversion passed in 0.11 s, checking zone changes and both EST/EDT names through the actual new data export.

Removing this change from Time.cpp while keeping the new test caused the test link to fail with undefined references to tzname_nid_postfix. Restored the exact source bytes, rebuilt the real library and test, and confirmed guest_time_conversion passed again. Conventions and whitespace checks passed on the integration branch.

This was a scoped library build and native Linux test run, not a full Linux application build or a Linux ES-DE run. No further game run was performed. AI-assisted validation with Codex; Claude's original implementation remains unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142177148 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5009#issuecomment-6142177148). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T09:07:48Z. --- Follow-up Linux validation of this change on current `main` `4bb2c7f3947440d513b1dbd12143ec55b250495a`: cleanly cherry-picked PR head `8d6b8df72c9c059d63a805791b9363a85651cc4c` into an isolated local branch, alongside the independent Windows pipe-selection change from #5013. Exact integration head: `2e3b9eb35c775e1d429f6c42144a701a632859ae`. Ubuntu 26.04.1 / WSL2, GCC 15.2.0, Ninja Release, bundled dependencies, `BUILD_TESTING=ON`. Built the real libc and libkernel libraries and all their Linux-registered test targets. All 187 scoped tests passed (66 libc, 121 libkernel), no skips or failures, 3.73 s. `guest_time_conversion` passed in 0.11 s, checking zone changes and both `EST`/`EDT` names through the actual new data export. Removing this change from `Time.cpp` while keeping the new test caused the test link to fail with undefined references to `tzname_nid_postfix`. Restored the exact source bytes, rebuilt the real library and test, and confirmed `guest_time_conversion` passed again. Conventions and whitespace checks passed on the integration branch. This was a scoped library build and native Linux test run, not a full Linux application build or a Linux ES-DE run. No further game run was performed. AI-assisted validation with Codex; Claude's original implementation remains unchanged.
xXPBSXx commented 2026-10-13 09:08:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T09:08:49Z.


Windows test of this PR.

Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, BUILD_TESTING=ON, -j2, libusb-cmake from a local checkout. Built from main ad653c9bc with this PR and #5004 merged together; the merge had no conflict.

Result: guest_time_conversion (1 of 1) passes.

Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142194275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5009#issuecomment-6142194275). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T09:08:49Z. --- Windows test of this PR. Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `BUILD_TESTING=ON`, `-j2`, `libusb-cmake` from a local checkout. Built from `main` `ad653c9bc` with this PR and #5004 merged together; the merge had no conflict. Result: guest_time_conversion (1 of 1) passes. Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested. AI-assisted (Claude Code).
p3n1cillin commented 2026-10-13 11:34:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T11:34:36Z.


Rebased onto main 5d50886ee, where Time.cpp changed with the FreeBSD 11 strftime rewrite (d0df62bd1). The change is the same: the HostZoneNames helper now sits after formatGuestTime. All 87 libc tests pass on Windows, including guest_time_conversion; conventions pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144626545 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5009#issuecomment-6144626545). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T11:34:36Z. --- Rebased onto `main` `5d50886ee`, where `Time.cpp` changed with the FreeBSD 11 `strftime` rewrite (d0df62bd1). The change is the same: the `HostZoneNames` helper now sits after `formatGuestTime`. All 87 libc tests pass on Windows, including `guest_time_conversion`; conventions pass.
github-actions[bot] commented 2026-10-13 11:36:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T11:36:53Z.


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
#4681 docs/dev/debt/libc.md L58
#5434 docs/dev/debt/libc.md L58
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144664398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5009#issuecomment-6144664398). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T11:36:53Z. --- <!-- 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 | |---|---|---|---| | #4681 | `docs/dev/debt/libc.md` [L58](https://github.com/boykopovar/AnyPS5/blob/2e7ab67e8dc484013e0d55f93988875f9bf76567/docs/dev/debt/libc.md#L58) | | | | #5434 | `docs/dev/debt/libc.md` [L58](https://github.com/boykopovar/AnyPS5/blob/2e7ab67e8dc484013e0d55f93988875f9bf76567/docs/dev/debt/libc.md#L58) | | |
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!5009
No description provided.