Skip to content

Commit 035ac29

Browse files
author
Jonah Petri
committed
try to convert to cfg var for uclibc time64
1 parent 8c12988 commit 035ac29

7 files changed

Lines changed: 38 additions & 18 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ jobs:
225225
- target: x86_64-unknown-linux-musl
226226
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
227227
artifact-tag: new-musl
228+
- target: armv7-unknown-linux-uclibceabihf
229+
- target: armv7-unknown-linux-uclibceabihf
230+
env: { TEST_UCLIBC_TIIME64: 1 }
228231
# FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually.
229232
# - target: x86_64-unknown-redox
230233

build.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[
5454
/// Musl architectures that set `#define _REDIR_TIME64 1`.
5555
const MUSL_REDIR_TIME64_ARCHES: &[&str] = &["arm", "hexagon", "mips", "powerpc", "x86"];
5656

57-
/// uclibc architectures that set `#define __UCLIBC_USE_TIME64__`,
58-
/// see UCLIBC_USE_TIME64 in uclibc-ng source: extra/Configs/Config.in
59-
const UCLIBC_TIME64_ARCHES: &[&str] = &["arm", "mips"];
60-
6157
fn main() {
6258
// Avoid unnecessary re-building.
6359
println!("cargo:rerun-if-changed=build.rs");
@@ -127,11 +123,8 @@ fn main() {
127123
}
128124
}
129125

130-
let uclibc_use_time64 = env_flag("RUST_LIBC_UCLIBC_USE_TIME64");
131-
println!("cargo:rerun-if-env-changed=RUST_LIBC_UCLIBC_USE_TIME64");
132-
if target_env == "uclibc"
133-
&& uclibc_use_time64
134-
&& UCLIBC_TIME64_ARCHES.contains(&target_arch.as_str())
126+
let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64");
127+
if target_env == "uclibc"&& uclibc_use_time64
135128
{
136129
set_cfg("linux_time_bits64");
137130
}

ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \
1414
qemu-user \
1515
xz-utils
1616

17-
RUN mkdir /toolchain
18-
19-
RUN curl --retry 5 -L https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--bleeding-edge-2024.05-1.tar.xz | \
20-
tar xjf - -C /toolchain --strip-components=1
21-
RUN /toolchain/relocate-sdk.sh
17+
ARG TEST_UCLIBC_TIIME64
18+
COPY install-uclibc.sh /
19+
RUN /install-uclibc.sh "$TEST_UCLIBC_TIIME64"
2220

2321
ENV PATH=$PATH:/rust/bin:/toolchain/bin \
2422
STAGING_DIR=/toolchain/armv7-buildroot-linux-uclibceabihf/sysroot \

ci/install-uclibc.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/bash
2+
#
3+
# Installs the appropriate uclibc toolchain into /toolchain
4+
5+
set -eux
6+
7+
time64="$1"
8+
9+
if [ "${time64:-0}" != "0" ]; then
10+
version='bleeding-edge-2025.08-1'
11+
else
12+
version='bleeding-edge-2024.05-1' # last version with 32-bit time_t
13+
fi
14+
15+
mkdir /toolchain
16+
17+
curl --retry 5 -L "https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--${version}.tar.xz" | \
18+
tar xjf - -C /toolchain --strip-components=1
19+
20+
/toolchain/relocate-sdk.sh

ci/run-docker.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ run() {
4444
fi
4545
fi
4646

47+
if [[ "$run_target" = *"uclibc"* ]]; then
48+
if [ -n "${TEST_UCLIBC_TIIME64:-}" ]; then
49+
build_args+=("--build-arg=TEST_UCLIBC_TIIME64=1")
50+
export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_uclibc_time64"
51+
fi
52+
fi
53+
4754
# use -f so we can use ci/ as build context
4855
docker build "${build_args[@]}"
4956

libc-test/build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,11 +3731,10 @@ fn test_linux(target: &str) {
37313731
cfg.cfg("linux_time_bits64", None);
37323732
}
37333733
}
3734-
let uclibc_use_time64 = env::var("RUST_LIBC_UCLIBC_USE_TIME64")
3734+
let uclibc_use_time64 = env::var("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64")
37353735
.map(|val| val != "0")
37363736
.unwrap_or(false);
3737-
if uclibc && uclibc_use_time64 && (arm || mips) {
3738-
// see UCLIBC_TIME64_ARCHES in libc/build.rs
3737+
if uclibc && uclibc_use_time64 {
37393738
cfg.cfg("linux_time_bits64", None);
37403739
}
37413740
cfg.define("_GNU_SOURCE", None)

src/unix/linux_like/linux/uclibc/arm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::prelude::*;
44
pub type wchar_t = c_uint;
55

66
cfg_if! {
7-
// See RUST_LIBC_UCLIBC_USE_TIME64 env var if your uclibc has 64-bit time
7+
// Set cfg(libc_unstable_uclibc_time64) in rustflags if your uclibc has 64-bit time
88
if #[cfg(linux_time_bits64)] {
99
pub type time_t = c_longlong;
1010
pub type suseconds_t = c_longlong;

0 commit comments

Comments
 (0)