diff --git a/build.rs b/build.rs index b9a8305918518..87a55e6c98d14 100644 --- a/build.rs +++ b/build.rs @@ -35,6 +35,9 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 "musl_redir_time64", "vxworks_lt_25_09", + // Exists for Windows x86 GNU to use a 64-bit wide `time_t` instead of the + // incorrect 32-bit wide `time_t` that we have on stable. + "windows_gnu_time64", ]; // Extra values to allow for check-cfg. @@ -131,6 +134,14 @@ fn main() { } } + if target_arch == "x86" + && target_os == "windows" + && target_env == "gnu" + && env_flag("CARGO_CFG_LIBC_UNSTABLE_WINDOWS_GNU_TIME64") + { + set_cfg("windows_gnu_time64"); + } + let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); if linux_time_bits64 { diff --git a/ci/run.sh b/ci/run.sh index 96e5750945df4..2a0ed5b8b533c 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -54,4 +54,5 @@ if [ "$env" = "gnu" ] && [ "$bits" = "32" ]; then RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd -- $test_flags # shellcheck disable=SC2086 RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd -- $test_flags + RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_windows_gnu_time64=\"1\"" $cmd -- $test_flags fi diff --git a/ci/verify-build.py b/ci/verify-build.py index 831c1cdb3d3ec..817ecc8a26933 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -242,8 +242,12 @@ def run( args: Sequence[str | Path], *, env: Optional[dict[str, str]] = None, + extra_rustflags: Optional[str] = None, check: bool = True, ) -> sp.CompletedProcess: + if extra_rustflags is not None: + env["RUSTFLAGS"] = env.get("RUSTFLAGS", "") + " " + extra_rustflags + xtrace(args, env=env) return sp.run(args, env=env, check=check) @@ -396,6 +400,9 @@ def test_target(cfg: Cfg, target: Target) -> TargetResult: run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS": "64"}) # Equivalent of _TIME_BITS=64 run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_TIME_BITS": "64"}) + # For Windows x86 GNU to test out a backwards-incompatible 64-bit wide + # `time_t` + run(cmd, env=env, extra_rustflags="--cfg=libc_unstable_windows_gnu_time64=\"1\"") if "musl" in target_env: # Check with breaking changes from musl, including 64-bit time_t on 32-bit diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 2cfd1977d2799..866ed90d62629 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -19,7 +19,7 @@ pub type clock_t = i32; pub type errno_t = c_int; cfg_if! { - if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { + if #[cfg(all(target_arch = "x86", target_env = "gnu", not(windows_gnu_time64)))] { pub type time_t = i32; } else { pub type time_t = i64; @@ -34,6 +34,12 @@ extern_ty! { pub enum timezone {} } +#[deprecated( + since = "1.0.0", + note = "This time-related value, among others, is part of the shift \ + towards using a single, 64-bit-sized `time_t`. See #PENDING for \ + discussion." +)] pub type time64_t = i64; pub type SOCKET = crate::uintptr_t;