Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions ci/verify-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading