Commit c6b30ef
fix: Avoid POSIX localtime_r in Scala Native log formatter on Windows (#519)
## Summary
- MSVC's CRT does not export POSIX `localtime_r`, so downstream Scala
Native consumers of `uni-core` that build for Windows hit a linker
error (`unresolved external symbol localtime_r`). wvlet caught this
while producing `wvlet.dll` on `windows-2022`:
https://github.com/wvlet/wvlet/actions/runs/25133797459/job/73666762135
- Gate the existing `localtime_r` + `strftime` path on
`scala.scalanative.meta.LinktimeInfo.isWindows`, and fall back to a
pure-Scala UTC formatter on Windows (Howard Hinnant's civil-from-days
algorithm). `LinktimeInfo.isWindows` is a link-time constant, so
POSIX targets keep their existing behavior unchanged via DCE.
- The Windows path drops the system timezone offset (emits `Z`), which
matches what the Scala.js path already does (`Date.toISOString()`).
## Test plan
- [x] `coreNative/test` passes locally on macOS (`./sbt uniNative/test`
— 1330 passed)
- [x] `scalafmtCheckAll`
- [ ] Verified end-to-end by bumping `UNI_VERSION` in
[`wvlet/wvlet`](https://github.com/wvlet/wvlet/blob/main/build.sbt)
after this lands and is published, and re-running the
`Build native on Windows (x64)` job that originally caught it.
## Follow-up
Add a `windows-latest` Scala Native job to `uni`'s `test.yml` so this
class of regression is caught at the source rather than by downstream
projects.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ab38e07 commit c6b30ef
1 file changed
Lines changed: 67 additions & 7 deletions
Lines changed: 67 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
27 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
28 | 46 | | |
29 | 47 | | |
30 | 48 | | |
| |||
48 | 66 | | |
49 | 67 | | |
50 | 68 | | |
51 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
52 | 115 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 116 | + | |
57 | 117 | | |
58 | 118 | | |
0 commit comments