fix(libc): honor guest TZ in time conversions #6916
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6916"
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 MarcZX10 on 2026-10-16T18:14:06Z.
What
Applies the guest process's
TZvalue to host-backedtzset,localtime,mktimeandstrftimeconversions, so guestsetenv,putenvandunsetenvchanges are honored. Time zone updates and conversions are serialized, each outer conversion uses one guestTZsnapshot, and implicit changes refresh the exportedtznamepointers.Carries Hussein Kadhim's three implementation commits with his original commit authorship preserved. Adds a regression for the implicit
setenv("TZ")path and moves the timezone debt note todocs/dev/debt/libc.md.Closes #6910.
Tested
guest_time_conversionandguest_mktimepass (2/2).guest_rtc_testsbuilds; its runtime stops at the host CPU feature guard before assertions on this Xeon E5-1620 v2.c5a2f3631: Ubuntu, macOS and Windows relinker jobs pass; register-context jobs pass on Ubuntu/macOS Intel and write-watch jobs pass on macOS. Full Linux/Windows application builds were skipped by workflow filters.guest_time_conversion, retaining the original host-side regionsetenv; an added temporary assertion confirmed expected offsets for all four regions. No production or test changes from #6686 are included here.git diff --checkpass locally against currentmain(93e54cedd).Independent Linux validation reported by Dextroid17 on exact head
0416fb91c: CachyOS 7.2.9, i9-11900K, GCC 16.2.1, withTZunset (host zone America/Toronto).guest_time_conversionandguest_mktimeboth passed in 3/3 runs; the revert control failedguest_time_conversionin 3/3 withLocal epoch conversion failed; the merged build also passed with five host TZ settings. This is historical validation against main47a266cf9; Windows/macOS runtime and other revert-arm time zones were not tested.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 repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T18:44:48Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libc/src/Time.cppdocs/dev/debt/libc.mdcore/libs/tests/GuestMktime.cppcore/libs/tests/GuestTimeConversion.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Time.cppcore/libs/prx/libc/src/Time.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Environment.cppdocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-17T14:35:09Z.
Native Linux run of this head.
Setup: head
0416fb91c(merge-base withmain93e54cedd),BUILD_TESTING=ON, Ninja, CachyOS (kernel 7.2.9), i9-11900K, GCC 16.2.1, host time zoneAmerica/Toronto(TZunset underenv -i). Tests ran underenv -iwith onlyHOMEandPATHset. Each arm ran 3 times. Command:ctest -R '^guest_time_conversion$|^guest_mktime$'.General.hpp,Environment.cppandTime.cppundercore/libs/prx/libcas on93e54ceddand the PR's tests kept,guest_time_conversionaborts 3 of 3 withLocal epoch conversion failed.guest_mktimepasses.mainat47a266cf9: the branch is 573 commits behind but merges cleanly, and 2 of 2 pass in each of the 3 runs.tools/check_conventions.pypasses.guest_time_conversion_testsalso passes with hostTZset toUTC,Asia/Tokyo,Pacific/Kiritimati,America/Los_AngelesandEurope/Athens. The revert arm was run only underAmerica/Toronto, where the guestUTC-2and the host offset differ.Not checked: Windows, macOS, PS5 hardware, and the revert arm under other host time zones.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T18:13:18Z.
Thanks for running the Linux tests with
TZunset and sweeping the merged build across five host time zones. The exact-head pass and revert control give useful evidence for theTZsnapshot path, and I added those results to the PR description with their47a266cf9base and platform limits recorded.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T00:12:04Z.
Rebased this PR onto current upstream main and resolved the documentation conflict while preserving the unrelated main debt entry. The original Hussein Kadhim commits remain authored by Hussein; MarcZX100 is the committer for the rebase. The new head is mergeable and hosted eligibility, conventions, report, relinker (Ubuntu/Windows/macOS x86-64 and macOS under Rosetta), ASan relinker, register-context and write-watch jobs all pass. Broad Linux/Windows builds are skipped by the workflow path filter. Local conventions, diff check, and C++20 syntax checks for the changed time sources passed; no full local runtime test was run.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T14:10:09Z.
Rebased onto current
main: #6686'sCheckRegionZonesset the hostTZdirectly, which no longer matches the guest-TZmodel here, so I switched it (and the finalEST5EDTtzname check) tosetenv_nid_postfix. No production code changed.Checked the zone lock/snapshot logic, the tzname refresh, the Windows
UTC0mapping and the debt entry against the diff; the guest-TZ tests and the revert control reported by @Dextroid17 cover the Linux behaviour; merged.