Skip to content

Commit 097f2fd

Browse files
committed
musl: add musl_time64 feature
This feature is enabled with independently from musl_v1_2_3 to support time64. Defining this feature makes this roughly equivalent to upstream commit bminor/musl@f12bd8e.
1 parent ec44bd2 commit 097f2fd

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

build.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const ALLOWED_CFGS: &[&str] = &[
2424
// Corresponds to `__USE_TIME_BITS64` in UAPI
2525
"linux_time_bits64",
2626
"musl_v1_2_3",
27+
"musl32_time64",
2728
];
2829

2930
// Extra values to allow for check-cfg.
@@ -44,6 +45,8 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[
4445
),
4546
];
4647

48+
const MUSL_TIME64_ARCHS: &[&str] = &["arm", "mips", "powerpc", "x86"];
49+
4750
fn main() {
4851
// Avoid unnecessary re-building.
4952
println!("cargo:rerun-if-changed=build.rs");
@@ -90,10 +93,16 @@ fn main() {
9093

9194
let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
9295
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3");
96+
let musl32_time64 = env::var("RUST_LIBC_UNSTABLE_MUSL_TIME64").is_ok();
97+
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_TIME64");
9398
// loongarch64 and ohos have already updated
94-
if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" {
95-
// FIXME(musl): enable time64 api as well
99+
if ((musl_v1_2_3 || target_os == "loongarch64") && target_env == "musl") || target_env == "ohos"
100+
{
96101
set_cfg("musl_v1_2_3");
102+
if musl32_time64 && MUSL_TIME64_ARCHS.contains(&target_arch.as_str()) {
103+
set_cfg("musl32_time64");
104+
set_cfg("linux_time_bits64");
105+
}
97106
}
98107
let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok();
99108
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64");

libc-test/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3689,14 +3689,22 @@ fn test_linux(target: &str) {
36893689
let loongarch64 = target.contains("loongarch64");
36903690
let wasm32 = target.contains("wasm32");
36913691
let uclibc = target.contains("uclibc");
3692+
let mips64 = target.contains("mips64");
3693+
let mips32 = target.contains("mips") && !mips64;
36923694

36933695
let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
3696+
let musl32_time64 = env::var("RUST_LIBC_UNSTABLE_MUSL_TIME64").is_ok();
36943697
let old_musl = musl && !musl_v1_2_3;
36953698

36963699
let mut cfg = ctest_cfg();
3697-
if musl_v1_2_3 {
3700+
if (musl_v1_2_3 || loongarch64) && musl {
36983701
cfg.cfg("musl_v1_2_3", None);
3702+
if musl32_time64 && (arm || ppc || x86_32 || mips32) {
3703+
cfg.cfg("musl32_time64", None);
3704+
cfg.cfg("linux_time_bits64", None);
3705+
}
36993706
}
3707+
37003708
cfg.define("_GNU_SOURCE", None);
37013709
// This macro re-defines fscanf,scanf,sscanf to link to the symbols that are
37023710
// deprecated since glibc >= 2.29. This allows Rust binaries to link against

0 commit comments

Comments
 (0)