Conversation
.github/workflows/ci.yaml
Outdated
| # FIXME: It currently causes segfaults. | ||
| #- target: i686-pc-windows-gnu | ||
| # env: { ARCH_BITS: 32, ARCH: i686 } | ||
| - target: i686-pc-windows-gnu | ||
| os: windows-2025 |
There was a problem hiding this comment.
Would you mind splitting whatever is needed to fix this to a separate PR? That would be great to have independent of deprecation.
Think that includes this portion of the file, the shell script, and src/windows/gnu/mod.rs.
| pub type time_t = i64; | ||
| } | ||
| } | ||
| pub type time_t = i64; |
There was a problem hiding this comment.
Have you run any tests before and after this change for whether things work? I'm wondering about this group of functions where it seems like we're already linking the time64 version in some cases
Lines 393 to 413 in ff0e616
To test this you could use the libc from main and pass a pointer to a [time_t; 2] to the time function, both initialized to 0x1234abcd or whatever. If only one of them gets overwritten with the current time, there isn't a bug and things are working despite the link name. If one gets the current time and the other gets zeroed, then we have a bug.
This PR would fix it but we can't backport because of the breakage, so we'll need configure the link_name attributes behind not(x86+gnu).
(I realize that's rather confusing, let me know if anything needs clarification)
There was a problem hiding this comment.
Regarding the first question on tests, I have run the existing libc test suite
both before and after the changes, though admittedly I did not run it prior to
making the changes to src/windows/mod.rs, but without skipping time_t in
build.rs.
I'm not sure what do you mean when you say those routines may be faulty in the
current main worktree. From what I could gather of the Windows CRT docs (e.g.
[1], as all routines explain things similarly in this respect,) there
shouldn't be any issues, considering the non-suffixed variants are just wrappers
for the suffixed, 64-bit variants. So linking the 64-bit symbol with a type that
is also 64-bits wide now should be fine. Still, I understand there may be some
concerns with GNU on Windows, as in those cases, the expected time_t (prior to
this PR) was 32-bits wide, so that could be an issue.
Either way, I'll get back in a few hours once I actually run your test.
There was a problem hiding this comment.
There may be a bug in the current main worktree. Running on Windows x86 GNU,
with a two-element array of 32-bit time_t, a 64-bit store is being performed
on the pointer's pointee that gets passed to one of these 64-bit-linked routines
(tested it out with time() in libc, which links by default on all
targets/environments to _time64()) as one of the elements is zeroed after the
call.
I would personally say the bug is not in linking these routines by default to
their 64-bit variants, but rather in the fact that we assume a 32-bit time_t
on Windows GNU x86. By default, Rust's libc behaves correctly under MSVC, as
time_t is always 64-bit wide unless USE_32BIT_TIME_T is defined, no matter
the target triple, and in libc we opted out of adding support for that feature
test macro. On the other hand, when running under mingw with GNU in x86, we
always define time_t to be 32-bit wide. This, according to [1] and [2], is
incorrect, as behavior in mingw is exactly like that in MSVC when it comes to
bit-width; Namely, define USE_32BIT_TIME_T if you want 32-bit time_t and
non-suffixed variants to default to their 32-bit variants, otherwise, it's
64-bit time_t all the way through.
Running the test with the changes in this PR solves the issues, simply because
there's no 32-bit time_t exposed on Rust's libc under Windows anymore.
There was a problem hiding this comment.
Would you be able to add that test to libc-test/tests?
84d1dfb to
c8dac1e
Compare
This comment has been minimized.
This comment has been minimized.
c8dac1e to
a2d5294
Compare
This comment has been minimized.
This comment has been minimized.
|
Just updated the PR description and removed the stable nomination, as there's @rustbot label -stable-nominated |
a2d5294 to
0d82329
Compare
This comment has been minimized.
This comment has been minimized.
0d82329 to
d779c91
Compare
|
Error: Label A-CI can only be set by Rust team members Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
The current behavior is broken so we do need a fix on stable. Could you put up a PR gating the People also need a way to experiment on stable, so I think we need to make this backportable by putting the changes behind a cfg. We're moving away from environment variables, the new way of setting cfg via |
d779c91 to
668ed88
Compare
|
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. |
|
According to the default behavior in both MSVC and GNU on Windows, whether we If anything, I'd say the fix should be to have the routine be linked to the The fix on stable may be to just expose a 32-bit But I could be misunderstanding what you mean by "putting the changes behind a |
Until [rust-lang#5032], whenever `libc` was running under Windows x86 with GNU, the default bit-width of `time_t` values was 32-bits. This doesn't quite align with the defaults in MSVC and `mingw`, but that's been addressed in that PR. This PR is a quick patch for stable, as the changes in [rust-lang#5032] are not backwards-compatible. It separates the routines that under Windows use `time_t` values and changes their link-time symbols to the 32-bit variants exposed in both MSVC and `mingw`, for the affected target platform/environment. [rust-lang#5032]: rust-lang#5032
Until [rust-lang#5032], whenever `libc` was running under Windows x86 with GNU, the default bit-width of `time_t` values was 32-bits. This doesn't quite align with the defaults in MSVC and `mingw`, but that's been addressed in that PR. This PR is a quick patch for stable, as the changes in [rust-lang#5032] are not backwards-compatible. It separates the routines that under Windows use `time_t` values and changes their link-time symbols to the 32-bit variants exposed in both MSVC and `mingw`, for the affected target platform/environment. It also adds a test, akin to the one in [rust-lang#5032], that should ensure the correct bit-widths are in use for both the types and the linked routine symbols. [rust-lang#5032]: rust-lang#5032
Until [rust-lang#5032], whenever `libc` was running under Windows x86 with GNU, the default bit-width of `time_t` values was 32-bits. This doesn't quite align with the defaults in MSVC and `mingw`, but that's been addressed in that PR. This PR is a quick patch for stable, as the changes in [rust-lang#5032] are not backwards-compatible. It separates the routines that under Windows use `time_t` values and changes their link-time symbols to the 32-bit variants exposed in both MSVC and `mingw`, for the affected target platform/environment. It also adds a test, akin to the one in [rust-lang#5032], that should ensure the correct bit-widths are in use for both the types and the linked routine symbols. [rust-lang#5032]: rust-lang#5032
|
Alternatively, and judging by the documentation on some of the MSVC CRT docs Just opened #5059 with this fix. |
Until rust-lang#5032, whenever `libc` was running under Windows x86 with GNU, the default bit-width of `time_t` values was 32-bits. This doesn't quite align with the defaults in MSVC and `mingw`, but that's been addressed in that PR. This PR is a quick patch for stable, as the changes in rust-lang#5032 are not backwards-compatible. It separates the routines that under Windows use `time_t` values and changes their link-time symbols to the 32-bit variants exposed in both MSVC and `mingw`, for the affected target platform/environment. It also adds a test, akin to the one in rust-lang#5032, that should ensure the correct bit-widths are in use for both the types and the linked routine symbols.
Until rust-lang#5032, whenever `libc` was running under Windows x86 with GNU, the default bit-width of `time_t` values was 32-bits. This doesn't quite align with the defaults in MSVC and `mingw`, but that's been addressed in that PR. This PR is a quick patch for stable, as the changes in rust-lang#5032 are not backwards-compatible. It separates the routines that under Windows use `time_t` values and changes their link-time symbols to the 32-bit variants exposed in both MSVC and `mingw`, for the affected target platform/environment. It also adds a test, akin to the one in rust-lang#5032, that should ensure the correct bit-widths are in use for both the types and the linked routine symbols.
Functionality related to Windows `time64_t` has been deprecated in favor of a single, 64-bit wide `time_t`. This has also required some work into getting rid of the conditional compilation uses of `time_t` on GNU target environments, and tweaking the `max_align_t` type. The `FIXME` comment on the tier 1 platform support for Windows with GNU has also been removed as no segfaults were observed.
668ed88 to
bcbf9eb
Compare
Description
Functionality related to the Windows
time64_thas been deprecated in favor ofa single, 64-bit wide
time_t. This has also required some work into gettingrid of the conditional compilation uses of
time_ton GNU target environments,and tweaking the
max_align_ttype. But that was separated onto a different PRin #5050.
The
FIXMEcomment on the tier 1 platform support for Windows with GNU has alsobeen removed as no segfaults were observed.
There's not yet an issue open specifically for deprecation of non-64-bit wide
time and offset-related values, so the linked issue in the deprecation notice
for
time64_tis still pending.Sources
time_tvalues is handledunder Windows GNU.
https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/crt/time.h#L54-L57
https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/crt/time.h#L235-L250
Checklist
libc-test/semverhave been updated*LASTor*MAXare included (see#3131)
cd libc-test && cargo test --target mytarget);especially relevant for platforms that may not be checked in CI