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
10 changes: 8 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const ALLOWED_CFGS: &[&str] = &[
"musl_redir_time64",
"vxworks_lt_25_09",
"libc_pauthtest",
// Global flag to enable one of `linux_time_bits64` or `gnu_time_bits64`.
// The musl flags are enabled by default on supported platforms.
"time64",
];

// Extra values to allow for check-cfg.
Expand Down Expand Up @@ -169,6 +172,9 @@ fn main() {
// OpenHarmony uses a fork of the musl libc
let musl = target_env == "musl" || target_env == "ohos";

// Single entry-point to enable `time64` on supported platforms.
let time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_TIME64");

// loongarch64, hexagon, ohos and pauthtest only exist with recent musl
if target_arch == "loongarch64"
|| target_arch == "hexagon"
Expand All @@ -190,7 +196,7 @@ fn main() {
}

let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64");
if target_env == "uclibc" && uclibc_use_time64 {
if target_env == "uclibc" && (uclibc_use_time64 || time64) {
set_cfg("linux_time_bits64");
}

Expand Down Expand Up @@ -230,7 +236,7 @@ fn main() {
}
};

if timebits == "64" {
if timebits == "64" || time64 {
set_cfg("linux_time_bits64");
set_cfg("gnu_file_offset_bits64");
set_cfg("gnu_time_bits64");
Expand Down
10 changes: 7 additions & 3 deletions libc-test/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ fn test_windows(t: &Target) {
}
cfg.define("_WIN32_WINNT", Some("0x8000"));

let time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_TIME64");
let win_gnu_x86_time64 = match env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS") {
Ok(v) if v == "64" => true,
Ok(v) if v == "32" => false,
Expand All @@ -736,7 +737,7 @@ fn test_windows(t: &Target) {
// Needed for the Windows `time_t` test.
println!("cargo::rustc-check-cfg=cfg(gnu_time_bits64)");

if x86_32 && gnu && win_gnu_x86_time64 {
if x86_32 && gnu && (win_gnu_x86_time64 || time64) {
cfg.cfg("gnu_time_bits64", None);
println!("cargo::rustc-cfg=gnu_time_bits64");
}
Expand Down Expand Up @@ -3830,6 +3831,7 @@ fn config_gnu_bits(t: &Target, cfg: &mut ctest::TestGenerator) {
if t.gnu() && t.linux() && !t.x32() && !t.riscv32() && t.pointer_width == P32 {
let defaultbits = "32";
let mut tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS");
let time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_TIME64");

// FIXME: remove these fallbacks in a few releases
if let Ok(old_tb_env) = env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
Expand Down Expand Up @@ -3858,7 +3860,7 @@ fn config_gnu_bits(t: &Target, cfg: &mut ctest::TestGenerator) {
}
};

if timebits == "64" {
if timebits == "64" || time64 {
cfg.define("_TIME_BITS", Some("64"));
cfg.define("_FILE_OFFSET_BITS", Some("64"));
cfg.cfg("linux_time_bits64", None);
Expand Down Expand Up @@ -3923,6 +3925,8 @@ fn test_linux(t: &Target) {
None => panic!("failed to detect kernel version for Linux target {t:?}",),
};

let time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_TIME64");

let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2");
if musl_v1_2 {
assert!(musl);
Expand All @@ -3949,7 +3953,7 @@ fn test_linux(t: &Target) {
}

let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64");
if uclibc && uclibc_use_time64 {
if uclibc && (uclibc_use_time64 || time64) {
cfg.cfg("linux_time_bits64", None);
}
cfg.define("_GNU_SOURCE", None)
Expand Down