Skip to content

date: fix wasi clock resolution and system datetime support - #13687

Merged
sylvestre merged 1 commit into
uutils:mainfrom
eduardomourar:wasi-date-fixes
Oct 7, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
eduardomourar:wasi-date-fixes

Conversation

@eduardomourar

Copy link
Copy Markdown
Contributor

date implements get_clock_resolution via libc::clock_getres (rustix's excludes WASI) and set_system_datetime for WASI, the latter reporting "not supported" since the sandbox has no wall-clock-set syscall.

@github-actions

github-actions Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)

@codspeed

codspeed Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks
⏩ 442 skipped benchmarks1


Comparing eduardomourar:wasi-date-fixes (d7401e1) with main (8cf2e4f)

Open in CodSpeed

Footnotes

  1. 442 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@eduardomourar
eduardomourar force-pushed the wasi-date-fixes branch 2 times, most recently from 088a4d0 to d2b7ca2 Compare August 11, 2026 18:20
@eduardomourar
eduardomourar force-pushed the wasi-date-fixes branch 3 times, most recently from 3527d4f to 3c980e5 Compare September 7, 2026 09:19
@sylvestre
sylvestre enabled auto-merge (rebase) September 7, 2026 09:23
auto-merge was automatically disabled September 7, 2026 15:24

Head branch was pushed to by a user without write access

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 153.09 MB (+912 KB, +0.59%)

Significant per-binary changes:
  expr     2.76 MB ->    3.65 MB  (+908 KB, +32.11%)

@eduardomourar
eduardomourar force-pushed the wasi-date-fixes branch 2 times, most recently from 715fc00 to 7cc713f Compare September 7, 2026 19:21
@eduardomourar

Copy link
Copy Markdown
Contributor Author

@sylvestre, this one is ready (now with proper testing in place).

@eduardomourar
eduardomourar force-pushed the wasi-date-fixes branch 3 times, most recently from 8801020 to 32fa6ab Compare September 22, 2026 22:42
@eduardomourar eduardomourar changed the title fix(wasi): date clock resolution and system datetime support date: fix wasi clock resolution and system datetime support Sep 22, 2026
Comment thread .github/workflows/wasi.yml Outdated
Comment thread src/uu/date/src/date.rs
Comment thread src/uu/date/src/date.rs Outdated
Comment thread src/uu/date/src/date.rs Outdated
Comment thread src/uu/date/src/date.rs Outdated
Comment thread tests/by-util/test_date.rs
Comment thread tests/by-util/test_date.rs
Comment thread tests/by-util/test_sort.rs Outdated
@sylvestre

Copy link
Copy Markdown
Contributor

sorry but it needs to be rebased

Comment thread src/uu/date/src/date.rs
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks, the earlier comments are all handled. One thing is still missing: nothing runs the new SettingDateNotSupportedWasi path (src/uu/date/src/date.rs:1438). The two -s tests (test_date_set_permissions_error and test_date_set_hyphen_prefixed_values) are just ignored under wasi_runner. Could you add a small #[cfg(wasi_runner)] test in tests/by-util/test_date.rs that runs date -s "2020-01-01" and checks it fails with "setting the date is not supported by WASI"? After that it looks good to me.

@eduardomourar

Copy link
Copy Markdown
Contributor Author

As requested, added test_date_set_unsupported_on_wasi to exercise SettingDateNotSupportedWasi code path.

date implements get_clock_resolution via libc::clock_getres (rustix's
excludes WASI) and set_system_datetime for WASI, the latter reporting
"not supported" since the sandbox has no wall-clock-set syscall.
Comment thread src/uu/date/src/date.rs
let res = get_clock_resolution();

// Every supported platform reports a resolution of at least 1ns.
let nanos = res.as_second() as i128 * 1_000_000_000 + i128::from(res.subsec_nanosecond());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

res.as_nanosecond() already returns an i128, no need to compute it by hand

@sylvestre
sylvestre merged commit 229d4d0 into uutils:main Oct 7, 2026
140 of 141 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants