Skip to content

feat: add support for 32 bit time_t in Windows#5010

Open
dybucc wants to merge 1 commit intorust-lang:mainfrom
dybucc:main
Open

feat: add support for 32 bit time_t in Windows#5010
dybucc wants to merge 1 commit intorust-lang:mainfrom
dybucc:main

Conversation

@dybucc
Copy link

@dybucc dybucc commented Mar 11, 2026

Description

This PR adds support symmetric to that offered in some Unix platforms for using 32-bit time_t in Windows. This PR also removes some of the skip() functions used with ctest in Windows, as it renames some symbols to properly reflect whether they are 32-bit or 64-bit compliant, and adds deprecation notices to functions that are not supported by Microsoft anymore (as per their security guidelines.)

There's a few functions with secure variants (suffixed with _s) that are altogether missing and yet do appear in the Windows CRT docs, but that's work for another PR.

In the CI scripts, there seemed to be a slight inconsistency between what the environment variable ARCH, and the environment variable ARCH_BITS were meant to be checked for, so that also got tweaked.

An issue for the deprecation notices hasn't yet been opened, but if the PR seems viable, it can be readily opened before merging.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

@rustbot
Copy link
Collaborator

rustbot commented Mar 11, 2026

Some changes occurred in a solarish module

cc @jclulow, @pfmooney

Some changes occurred in an OpenBSD module

cc @semarie

Some changes occurred in a NetBSD-like module

cc @semarie

Some changes occurred in an Android module

cc @maurer

@rustbot rustbot added A-CI Area: CI-related items ctest Issues relating to the ctest crate S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Mar 11, 2026
@tgross35
Copy link
Contributor

What is the point of this? Per @ChrisDenton, _USE_32BIT_TIME_T has been deprecated a long time ago #gsoc > Idea: modernize the libc crate @ 💬.

All other changes resulted from running ./ci/style.py, so they're not really part of the PR.

The vast majority of this PR is reformatting, I suspect your local rustfmt isn't picking up .rustfmt.toml for some reason. If there really was that amount of reformatting to do, it should be a separate PR anyway rather than mixed in with other API changes.

@dybucc
Copy link
Author

dybucc commented Mar 14, 2026

What is the point of this? Per @ChrisDenton, _USE_32BIT_TIME_T has been deprecated a long time ago #gsoc > Idea: modernize the libc crate @ 💬.

All other changes resulted from running ./ci/style.py, so they're not really part of the PR.

The vast majority of this PR is reformatting, I suspect your local rustfmt isn't picking up .rustfmt.toml for some reason. If there really was that amount of reformatting to do, it should be a separate PR anyway rather than mixed in with other API changes.

Just ammended the commit without the formatting changes. Adding support for _USE_32BIT_TIME_T was to be a tad bit more compliant with the Microsoft CRT docs, and how they seem to have routines specific to both time64_t, time32_t, and time_t, the latter depending on whether the above feature test macro is defined.

The reason why the PR was opened was because some uses of the ctest's skip_* methods in test_windows under libc-test got removed without affecting test success. This may or may not have been due to the changes in this PR.

Should the PR be altogether closed, or should the changes to add support for _USE_32BIT_TIME_T be the only ones removed?

@rustbot
Copy link
Collaborator

rustbot commented Mar 14, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35
Copy link
Contributor

Are you referring to this?

libc/libc-test/build.rs

Lines 784 to 785 in 82b7480

// FIXME(windows): these don't exist:
"time64_t" => "__time64_t".to_string().into(),

If so, the fix here is to deprecate the alias on Windows so we can remove it in 1.0. We don't have any reason to try to support the legacy behavior.

@dybucc
Copy link
Author

dybucc commented Mar 14, 2026

No, the PR only changes types that relied on time_t, or time_t itself, as those trusted the feature test macro to be defined for correct size and alignment (e.g. timespec.) Types like time64_t, which are renamed anyway into the documented Microsoft CRT types aren't touched, but could be readily deprecated.

Still, what's the point of deprecating the time64_t alias for __time64_t if that's, in principle, not using the legacy 32-bit time_t?

EDIT: Sorry, took a while to realize you mean to deprecate time64_t in favor of a single, 64-bit, time_t. It can be done, but not just yet (working on a different PR.)

This commit adds support symmetric to that offered in Linux for using
32-bit `time_t` in Windows. This PR also removes some of the `skip()`
functions in Windows, as it renames some symbols to properly reflect
whether they are 32-bit or 64-bit compliant, and adds deprecation
notices to functions that were are not supported by Microsoft anymore
(as per their security guidelines.)

There's a few functions that are altogether missing and yet do appear in
the Windows CRT docs, but that's work for another PR.
@tgross35
Copy link
Contributor

The bigger picture is that time64_t types (along with off64_t, functions like open64, etc) are a bit of a bandaid that doesn't need to exist if you have a need to mix different sizes of time_t. In libc 1.0 we're going to be deprecating or dropping support for 32-bit time_t wherever possible, so there isn't any purpose to having the compatibility shims around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: CI-related items ctest Issues relating to the ctest crate S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants