Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 64-bit time on 32-bit linux-gnu #96657

Merged
merged 4 commits into from
May 7, 2022
Merged

Use 64-bit time on 32-bit linux-gnu #96657

merged 4 commits into from
May 7, 2022

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented May 2, 2022

The standard library suffered the Year 2038 problem in two main places on targets with 32-bit time_t:

  • In std::time::SystemTime, we stored a timespec that has time_t seconds. This is now changed to directly store 64-bit seconds and nanoseconds, and on 32-bit linux-gnu we try to use __clock_gettime64 (glibc 2.34+) to get the larger timestamp.

  • In std::fs::Metadata, we store a stat64, which has 64-bit off_t but still 32-bit time_t, and unfortunately that is baked in the API by the (deprecated) MetadataExt::as_raw_stat(). However, we can use statx for 64-bit statx_timestamp to store in addition to the stat64, as we already do to support creation time, and the rest of the MetadataExt methods can return those full values. Note that some filesystems may still be limited in their actual timestamp support, but that's not something Rust can change.

There remain a few places that need timespec for system call timeouts -- I leave that to future work.

@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 2, 2022
@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 2, 2022
@cuviper
Copy link
Member Author

cuviper commented May 2, 2022

(I fear the CI fallout of changing Timespec for all unix targets, since I've only tested on linux-gnu, but we'll work through it...)

@joshtriplett
Copy link
Member

Looks reasonable to me. Let's give it a shot.

@bors r+

@bors
Copy link
Contributor

bors commented May 3, 2022

📌 Commit 044becdef8d853dc29161611b538ef3c765d3dec has been approved by joshtriplett

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 3, 2022
@bors
Copy link
Contributor

bors commented May 6, 2022

☔ The latest upstream changes (presumably #96510) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 6, 2022
@cuviper
Copy link
Member Author

cuviper commented May 6, 2022

Rebased.

@bors r=joshtriplett rollup=iffy

@bors
Copy link
Contributor

bors commented May 6, 2022

📌 Commit fec4818 has been approved by joshtriplett

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 6, 2022
@bors
Copy link
Contributor

bors commented May 6, 2022

⌛ Testing commit fec4818 with merge 4fc439f674a020d2196357d7f38d2fef75fb0a70...

@bors

This comment was marked as resolved.

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 6, 2022
@cuviper
Copy link
Member Author

cuviper commented May 6, 2022

I was missing to_timespec on macos. I moved that and most of SystemTime to common unix code.

@cuviper cuviper requested a review from joshtriplett May 6, 2022 18:48
@rust-log-analyzer

This comment was marked as resolved.

@joshtriplett
Copy link
Member

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented May 7, 2022

📌 Commit f967518 has been approved by joshtriplett

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 7, 2022
@bors
Copy link
Contributor

bors commented May 7, 2022

⌛ Testing commit f967518 with merge 24a0eec...

@bors
Copy link
Contributor

bors commented May 7, 2022

☀️ Test successful - checks-actions
Approved by: joshtriplett
Pushing 24a0eec to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 7, 2022
@bors bors merged commit 24a0eec into rust-lang:master May 7, 2022
@rustbot rustbot added this to the 1.62.0 milestone May 7, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (24a0eec): comparison url.

Summary:

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regression found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 1 0 0 0
mean2 N/A 0.2% N/A N/A N/A
max N/A 0.2% N/A N/A N/A

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@semarie
Copy link
Contributor

semarie commented May 8, 2022

it seems to me that it breaks the build on OpenBSD:

     Running `/data/semarie/build-rust/build_dir/build/bootstrap/debug/rustc --crate-name std --edition=2021 library/std/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type dylib
--crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 --cfg 'feature="addr2line"' --cfg 'feature="backtrace"' --cfg 'feature="compiler-builtins-c"' --cfg 'feature="gimli-symbolize"'
--cfg 'feature="miniz_oxide"' --cfg 'feature="object"' --cfg 'feature="panic_unwind"' --cfg 'feature="std_detect_dlsym_getauxval"' --cfg 'feature="std_detect_file_io"' -C metadata=378c766641f06cb7 -C extra-filename=-378c766641f06cb7
--out-dir /data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps --target x86_64-unknown-openbsd -L
dependency=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps -L dependency=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/release/deps --extern
addr2line=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libaddr2line-54699a61a4996e32.rlib --extern
alloc=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/liballoc-c1464684857de2fb.rlib --extern
cfg_if=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libcfg_if-911ca56735f69dbf.rlib --extern
compiler_builtins=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libcompiler_builtins-5e745fef8d64cade.rlib --extern
core=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libcore-c340d24d8e18ebf7.rlib --extern
hashbrown=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libhashbrown-24ee209395c036b6.rlib --extern
libc=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/liblibc-48a88cf05aef92e5.rlib --extern
miniz_oxide=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libminiz_oxide-eeb523364a36f721.rlib --extern
object=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libobject-6fcd64c1f2a7a79d.rlib --extern
panic_abort=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libpanic_abort-9c65896c13c96c61.rlib --extern
panic_unwind=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libpanic_unwind-1fc476adbfc951f7.rlib --extern
rustc_demangle=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/librustc_demangle-1fa31f1cfd9e0d48.rlib --extern
std_detect=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libstd_detect-e6ac865e361f7f7b.rlib --extern
unwind=/data/semarie/build-rust/build_dir/build/x86_64-unknown-openbsd/stage0-std/x86_64-unknown-openbsd/release/deps/libunwind-6af071432b46fe34.rlib --cfg=bootstrap -Csymbol-mangling-version=legacy -Zunstable-options -Zmacro-backtrace
-Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Zunstable-options -Csplit-debuginfo=off -Cprefer-dynamic '-Zcrate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/")' -Z binary-dep-depinfo --cfg
backtrace_in_libstd -L native=/usr/lib`
error: associated function is never used: `to_timespec`
   --> library/std/src/sys/unix/time.rs:129:12
    |
129 |     pub fn to_timespec(&self) -> Option<libc::timespec> {
    |            ^^^^^^^^^^^
    |
    = note: `-D dead-code` implied by `-D warnings`


Did not run successfully: exit status: 1

any idea on how to properly correct it ?

@semarie
Copy link
Contributor

semarie commented May 8, 2022

ok, the futex code for openbsd hasn't been updated. I will look at it

@RalfJung RalfJung mentioned this pull request May 9, 2022
bors added a commit to rust-lang/miri that referenced this pull request May 9, 2022
rustup

Adjusts for rust-lang/rust#96657. For now we use the fallback path in libstd.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 12, 2022
…iper

openbsd: convert futex timeout managment to Timespec usage

unbreak openbsd build after rust-lang#96657

r? cuviper

please note I made `Timespec::zero()` public to be able to use it. OpenBSD is using relative timeout for `futex(2)` and I don't find simple way to use `Timespec` this way.
@cuviper cuviper deleted the time64 branch October 15, 2022 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants