From 3156347e405a3dcb48f1b639ed420681ea897745 Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Tue, 7 Jul 2026 17:26:16 -0400 Subject: [PATCH 1/4] uclibc: move to configurable external prebuilt toolchain The previous CI script used a prebuilt toolchain from bootlin, but this was based on kernel 5.15, which did not contain many of the kernel constants being tested. --- .../Dockerfile | 21 +++++++++--------- ci/install-uclibc.sh | 22 +++++++++---------- ci/run-docker.sh | 11 +++++++++- ci/run.sh | 5 +++++ 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile index a5e685318ad0a..0c6807d5a689b 100644 --- a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile +++ b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile @@ -1,25 +1,26 @@ -FROM ubuntu:23.10 +FROM ubuntu:25.04 -# FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time -RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ - /etc/apt/sources.list && \ - apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ - file \ gcc \ libc6-dev \ - patch \ qemu-system-arm \ qemu-user \ + bzip2 \ + gzip \ + cpio \ + unzip \ + rsync \ + bc \ xz-utils -ARG TEST_UCLIBC_TIME64 +ARG UCLIBC_TOOLCHAIN_URL COPY install-uclibc.sh / -RUN /install-uclibc.sh "$TEST_UCLIBC_TIME64" +RUN /install-uclibc.sh "$UCLIBC_TOOLCHAIN_URL" ENV PATH=$PATH:/rust/bin:/toolchain/bin \ STAGING_DIR=/toolchain/armv7-buildroot-linux-uclibceabihf/sysroot \ CC_armv7_unknown_linux_uclibceabihf=arm-buildroot-linux-uclibcgnueabihf-gcc \ CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_LINKER=arm-buildroot-linux-uclibcgnueabihf-gcc \ - CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_RUNNER="qemu-arm -L /toolchain/arm-buildroot-linux-uclibcgnueabihf/sysroot/" + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_RUNNER="qemu-arm -L /toolchain/arm-buildroot-linux-uclibcgnueabihf/sysroot/" \ No newline at end of file diff --git a/ci/install-uclibc.sh b/ci/install-uclibc.sh index 131f78f2065d0..261b3b2db47e5 100755 --- a/ci/install-uclibc.sh +++ b/ci/install-uclibc.sh @@ -1,20 +1,18 @@ #!/bin/bash # -# Installs the appropriate uclibc toolchain into /toolchain +# Builds a buildroot uclibc toolchain into /buildroot/output/host/ +# +# usage: install-uclibc.sh BUILDROOT_TOOLCHAIN_URL set -eux -time64="$1" - -if [ "${time64:-0}" != "0" ]; then - version='bleeding-edge-2025.08-1' -else - version='bleeding-edge-2024.02-1' # last version with 32-bit time_t -fi +toolchain_url="$1" mkdir /toolchain - -curl --retry 5 -L "https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--${version}.tar.bz2" | -tar xjf - -C /toolchain --strip-components=1 - +curl --retry 5 -L "$toolchain_url" | tar xzf - -C /toolchain --strip-components=1 +if ! [ -f /toolchain/relocate-sdk.sh ]; then + echo "ERROR: toolchain does not contain relocate-sdk.sh, expecting a buildroot SDK." + exit 1 +fi /toolchain/relocate-sdk.sh + diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 4a3d814c06f21..c81335bfdf9e5 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -50,8 +50,17 @@ run() { if [ -n "${TEST_UCLIBC_TIME64:-}" ]; then build_args+=("--build-arg=TEST_UCLIBC_TIME64=1") - export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_uclibc_time64" + export RUSTFLAGS="${RUSTFLAGS:-} --cfg=libc_unstable_uclibc_time64" fi + if [[ "$run_target" = *-linux-uclibc* ]]; then + if [ "${UCLIBC_TOOLCHAIN_URL:-}" ]; then + build_args+=("--build-arg=UCLIBC_TOOLCHAIN_URL=$UCLIBC_TOOLCHAIN_URL") + else + echo "Expected a URL to a UCLIBC toolchain in \$UCLIBC_TOOLCHAIN_URL" + exit 1 + fi + fi + # use -f so we can use ci/ as build context docker build "${build_args[@]}" diff --git a/ci/run.sh b/ci/run.sh index c7638d4c989b3..1d5a401f9514b 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -38,6 +38,11 @@ case "$target" in powerpc64le*musl) cmd="$cmd --exclude ctest --exclude ctest-test --exclude ctest-next" ;; esac +if [ "${LIBC_CI_ZBUILD_STD:-}" ]; then + # ctest test infrastructure has no support for -Zbuild-std + cmd="$cmd --exclude ctest --exclude ctest-test" +fi + env="$(rustc --print cfg --target "$target" | sed -n 's/target_env="\(.*\)"/\1/p')" bits="$(rustc --print cfg --target "$target" | sed -n 's/target_pointer_width="\(.*\)"/\1/p')" From b59d54143d1ca9ef6e55b291b650b7bf75d42f9b Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Tue, 7 Jul 2026 17:27:03 -0400 Subject: [PATCH 2/4] uclibc: time64 support in shmid_ds --- src/unix/linux_like/linux/uclibc/arm/mod.rs | 3 +++ src/unix/linux_like/linux/uclibc/mod.rs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 9d255b7388fcd..f8870d3267294 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -227,10 +227,13 @@ s! { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused1: Padding, pub shm_dtime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused2: Padding, pub shm_ctime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 6c3d8013f9173..8f67530187d97 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -133,6 +133,17 @@ s! { pub tcpi_rcv_space: u32, pub tcpi_total_retrans: u32, } + + pub struct mbstate_t { + __mask: crate::wchar_t, + __wc: crate::wchar_t, + } + + pub struct fpos64_t { + __pos: off64_t, + __mbstate: crate::mbstate_t, + __mblen_pending: c_int, + } } impl siginfo_t { From 48a5e20f40def09f363b4ebbaf48dc3aa1026407 Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Tue, 7 Jul 2026 17:34:44 -0400 Subject: [PATCH 3/4] uclibc: un-suppress tests for kernel constants from 5.16+ --- libc-test/build.rs | 117 --------------------------------------------- 1 file changed, 117 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 61b71b8475826..4ed92b3b46d7b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4651,123 +4651,6 @@ fn test_linux(target: &str) { if uclibc { match name { - // The canonical uClibc toolchain, bootlin bleeding-edge-2024.02-1, - // uses linux 5.15, so several constants are not available. - - // requires linux 5.16 - "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" - | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" - | "PR_SCHED_CORE_SCOPE_THREAD" - | "NF_NETDEV_EGRESS" - | "SO_RESERVE_MEM" => return true, - - // TLS_CIPHER_SM4_[GC]CM requires linux 5.16 - "TLS_CIPHER_SM4_CCM_IV_SIZE" - | "TLS_CIPHER_SM4_CCM_KEY_SIZE" - | "TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE" - | "TLS_CIPHER_SM4_CCM_SALT_SIZE" - | "TLS_CIPHER_SM4_CCM_TAG_SIZE" - | "TLS_CIPHER_SM4_CCM" - | "TLS_CIPHER_SM4_GCM_IV_SIZE" - | "TLS_CIPHER_SM4_GCM_KEY_SIZE" - | "TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE" - | "TLS_CIPHER_SM4_GCM_SALT_SIZE" - | "TLS_CIPHER_SM4_GCM_TAG_SIZE" - | "TLS_CIPHER_SM4_GCM" => return true, - - // requires linux 5.17 - "PR_SET_VMA_ANON_NAME" - | "PR_SET_VMA" - | "RTNLGRP_MCTP_IFADDR" => return true, - - // requires linux 5.18 - "RTNLGRP_STATS" - | "RTNLGRP_TUNNEL" - | "TLS_TX_ZEROCOPY_RO" - | "MADV_DONTNEED_LOCKED" - | "NFQA_PRIORITY" - | "SO_TXREHASH" => return true, - - // requires linux 5.19 - "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" - | "NLM_F_BULK" - | "SO_RCVMARK" - | "TLS_INFO_ZC_RO_TX" => return true, - - // CAN_* consts requiring linux 6.0 - "CAN_BUS_OFF_THRESHOLD" - | "CAN_CTRLMODE_TDC_AUTO" - | "CAN_CTRLMODE_TDC_MANUAL" - | "CAN_ERR_CNT" - | "CAN_ERROR_PASSIVE_THRESHOLD" - | "CAN_ERROR_WARNING_THRESHOLD" => return true, - - // requires linux 6.0 - "IFF_NO_CARRIER" - | "TLS_INFO_RX_NO_PAD" - | "TLS_RX_EXPECT_NO_PAD" => return true, - - // CAN_* consts requiring linux 6.1 - "CAN_RAW_XL_FRAMES" - | "CANXL_HDR_SIZE" - | "CANXL_MAX_DLC_MASK" - | "CANXL_MAX_DLC" - | "CANXL_MAX_DLEN" - | "CANXL_MAX_MTU" - | "CANXL_MIN_DLC" - | "CANXL_MIN_DLEN" - | "CANXL_MIN_MTU" - | "CANXL_MTU" - | "CANXL_PRIO_BITS" - | "CANXL_PRIO_MASK" - | "CANXL_SEC" - | "CANXL_XLF" => return true, - - // TLS_CIPHER_ARIA_GCM_* requires linux 6.1 - "TLS_CIPHER_ARIA_GCM_128_IV_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_KEY_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_SALT_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_TAG_SIZE" - | "TLS_CIPHER_ARIA_GCM_128" - | "TLS_CIPHER_ARIA_GCM_256_IV_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_KEY_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_SALT_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_TAG_SIZE" - | "TLS_CIPHER_ARIA_GCM_256" => return true, - - // requires linux 6.2 - "ALG_SET_KEY_BY_KEY_SERIAL" - | "PACKET_FANOUT_FLAG_IGNORE_OUTGOING" - | "SOF_TIMESTAMPING_OPT_ID_TCP" - | "TUN_F_USO4" - | "TUN_F_USO6" => return true, - - // FAN_* consts require kernel 6.3 - "FAN_INFO" - | "FAN_RESPONSE_INFO_AUDIT_RULE" - | "FAN_RESPONSE_INFO_NONE" => return true, - - // requires linux 6.3 - "MFD_EXEC" - | "MFD_NOEXEC_SEAL" - | "PR_GET_MDWE" - | "PR_SET_MDWE" => return true, - - // requires linux 6.4 - "PACKET_VNET_HDR_SZ" => return true, - "PR_GET_MEMORY_MERGE" => return true, - "PR_SET_MEMORY_MERGE" => return true, - - // requires linux 6.5 - "SO_PASSPIDFD" - | "SO_PEERPIDFD" => return true, - - // requires linux 6.6 - "PR_MDWE_NO_INHERIT" - | "PR_MDWE_REFUSE_EXEC_GAIN" => return true, - // defined as a synonym for EM_ARC_COMPACT in gnu but not uclibc "EM_ARC_A5" => return true, From 2454ca6c590f68e6ec4240caedc1c2a31cd10f6b Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Thu, 30 Jul 2026 13:31:28 -0400 Subject: [PATCH 4/4] uclibc: fix build failures accumulated via recent commits. --- src/unix/linux_like/linux/mod.rs | 2 +- src/unix/linux_like/linux_l4re_shared.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 678c816ab924b..02c4e13245b44 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1012,7 +1012,7 @@ s! { } cfg_if! { - if #[cfg(not(target_env = "gnu"))] { + if #[cfg(not(any(target_env = "gnu", target_env = "uclibc")))] { extern_ty! { pub type fpos64_t; // FIXME(linux): fill this out with a struct } diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 0674269182e74..de082a1966924 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -793,7 +793,6 @@ pub const EM_M32R: u16 = 88; pub const EM_MN10300: u16 = 89; pub const EM_MN10200: u16 = 90; pub const EM_PJ: u16 = 91; -#[cfg(not(target_env = "uclibc"))] pub const EM_OPENRISC: u16 = 92; #[cfg(target_env = "uclibc")] pub const EM_OR1K: u16 = 92; @@ -874,7 +873,6 @@ pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value // wherever it is defined. pub const AT_SYSINFO_EHDR: c_ulong = 33; -#[cfg(not(target_env = "uclibc"))] pub const AT_MINSIGSTKSZ: c_ulong = 51; pub const GLOB_ERR: c_int = 1 << 0;