Skip to content

Commit 44e0187

Browse files
committed
chore: wip
1 parent bcbf9eb commit 44e0187

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const ALLOWED_CFGS: &[&str] = &[
3535
// Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64
3636
"musl_redir_time64",
3737
"vxworks_lt_25_09",
38+
// Exists for Windows x86 GNU to use a 64-bit wide `time_t` instead of the
39+
// incorrect 32-bit wide `time_t` that we have on stable.
40+
"windows_gnu_time64",
3841
];
3942

4043
// Extra values to allow for check-cfg.
@@ -131,6 +134,14 @@ fn main() {
131134
}
132135
}
133136

137+
if target_arch == "x86"
138+
&& target_os == "windows"
139+
&& target_env == "gnu"
140+
&& env_flag("CARGO_CFG_LIBC_UNSTABLE_WINDOWS_GNU_TIME64")
141+
{
142+
set_cfg("windows_gnu_time64");
143+
}
144+
134145
let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok();
135146
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64");
136147
if linux_time_bits64 {

ci/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ if [ "$env" = "gnu" ] && [ "$bits" = "32" ]; then
5454
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd -- $test_flags
5555
# shellcheck disable=SC2086
5656
RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd -- $test_flags
57+
RUSTFLAGS="$RUSTFLAGS libc_unstable_windows_gnu_time64=1" $cmd -- $test_flags
5758
fi

ci/verify-build.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,12 @@ def run(
242242
args: Sequence[str | Path],
243243
*,
244244
env: Optional[dict[str, str]] = None,
245+
extra_rustflags: Optional[str] = None,
245246
check: bool = True,
246247
) -> sp.CompletedProcess:
248+
if extra_rustflags is not None:
249+
env["RUSTFLAGS"] = env.get("RUSTFLAGS", "") + " " + extra_rustflags
250+
247251
xtrace(args, env=env)
248252
return sp.run(args, env=env, check=check)
249253

@@ -396,6 +400,9 @@ def test_target(cfg: Cfg, target: Target) -> TargetResult:
396400
run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS": "64"})
397401
# Equivalent of _TIME_BITS=64
398402
run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_TIME_BITS": "64"})
403+
# For Windows x86 GNU to test out a backwards-incompatible 64-bit wide
404+
# `time_t`
405+
run(cmd, env=env, extra_rustflags="libc_unstable_windows_gnu_time64")
399406

400407
if "musl" in target_env:
401408
# Check with breaking changes from musl, including 64-bit time_t on 32-bit

src/windows/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ pub type clock_t = i32;
1818

1919
pub type errno_t = c_int;
2020

21-
pub type time_t = i64;
21+
cfg_if! {
22+
if #[cfg(all(target_arch = "x86", target_env = "gnu", not(windows_gnu_time64)))] {
23+
pub type time_t = i32;
24+
} else {
25+
pub type time_t = i64;
26+
}
27+
}
2228

2329
pub type off_t = i32;
2430
pub type dev_t = u32;

0 commit comments

Comments
 (0)