Skip to content

uclibc fix kernel constant tests + docker ci build fixes - #5261

Open
skrap wants to merge 5 commits into
rust-lang:mainfrom
skrap:bugfix/uclibc-docker-ci-build-fixes
Open

uclibc fix kernel constant tests + docker ci build fixes#5261
skrap wants to merge 5 commits into
rust-lang:mainfrom
skrap:bugfix/uclibc-docker-ci-build-fixes

Conversation

@skrap

@skrap skrap commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Today's uClibc builds in CI cannot test many recently-added linux kernel features, as the prebuilt bootlin toolchains they rely on are built against kernel 5.15.

This changes the ci/install-uclibc.sh script to use a toolchain provided via an environment variable. This allows projects and developers who want to run the uclibc tests to build based on kernel 7.0 headers, and use that toolchain for running the libc build and test in CI.

Best way to test is via:

UCLIBC_TOOLCHAIN_URL=https://github.com/skrap/libc-downstream-ci/releases/download/v0.1-toolchain/arm-buildroot-linux-uclibcgnueabihf_sdk-buildroot.tar.gz  \
LIBC_CI_ZBUILD_STD=1 \
TEST_UCLIBC_TIME64=1 \
RUSTUP_TOOLCHAIN=nightly \
./ci/run-docker.sh armv7-unknown-linux-uclibceabihf

NOTE: the toolchain URL provided above is from my github account and shouldn't be directly included in the source, as I'm sure I would get dinged for bandwidth usage. It's my expectation that developers would build their own or ask nicely to use mine in a responsible way.

Abandoned task: building a toolchain

My first attempt at this PR included building a toolchain from source via buildroot, but that process takes longer than the github action timeout (which seems to be 20 minutes) so I abandoned that approach.

Results

With this change, it's now possible for me to build the libc in a fork of the libc-downstream-ci example posted by @tgross35. See here for example.

Sources

N/A

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot rustbot added A-CI Area: CI-related items ctest Issues relating to the ctest crate labels Jul 7, 2026
@skrap
skrap force-pushed the bugfix/uclibc-docker-ci-build-fixes branch 3 times, most recently from 47c0db9 to 5aa06a0 Compare July 7, 2026 22:24
@skrap skrap changed the title Bugfix/uclibc docker ci build fixes uclibc fix kernel constant tests + docker ci build fixes Jul 8, 2026
@rustbot

This comment has been minimized.

@skrap
skrap force-pushed the bugfix/uclibc-docker-ci-build-fixes branch 3 times, most recently from 662559d to 2454ca6 Compare July 31, 2026 01:21
@skrap
skrap marked this pull request as ready for review July 31, 2026 01:23
@skrap

skrap commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot review

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is involved in preparing the SDK that gets downloaded? I think the current setup is fine enough, but if it's not too bad then I feel like the docker container may as well just build it. Or build it as part of run-docker.sh and copy it into the container to make caching easier.

View changes since this review

Comment thread ci/run-docker.sh Outdated
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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"uclibc: move to configurable external prebuilt toolchain": maybe just export RUSTFLAGS="${RUSTFLAGS:-}" at the top of run() so we only need that in one place

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"uclibc: move to configurable external prebuilt toolchain": missing trailing \n

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

@tgross35

tgross35 commented Aug 2, 2026

Copy link
Copy Markdown
Member

I also think it would be fine to link to your GH URL since libc's frequent CI won't be needing it. But for that, ideally the script should be checked into your repo somewhere (or build+release via GHA?) and the sha could be checked here so it's easy to reproduce.

@tgross35

tgross35 commented Aug 3, 2026

Copy link
Copy Markdown
Member

Also no problem of course but just a heads up, looks like the email you used here isn't linked to your GH account (e.g. https://github.com/rust-lang/libc/commit/3156347e405a3dcb48f1b639ed420681ea897745.patch).

@tgross35

tgross35 commented Aug 4, 2026

Copy link
Copy Markdown
Member

@rustbot author

@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

This comment has been minimized.

@skrap

skrap commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

What is involved in preparing the SDK that gets downloaded? I think the current setup is fine enough, but if it's not too bad then I feel like the docker container may as well just build it. Or build it as part of run-docker.sh and copy it into the container to make caching easier.

Unfortunately it's impractical, as it takes longer than the maximum builder lifetime allowed by github. My first attempt at this patchset did exactly as you asked, and it failed to work for exactly that reason: it would time out while preparing the docker image. So, I moved to a prebuilt toolchain.

@tgross35

Copy link
Copy Markdown
Member

Well that's surprising, does it need to build the whole kernel? I feel like I've even done that within a half hour GHA run.

Anyway if you can add a build script or instructions to your repo for reproduction and add a checksum, I still think it would be fine directly link your repo.

@skrap
skrap force-pushed the bugfix/uclibc-docker-ci-build-fixes branch from 2454ca6 to 4f47b89 Compare August 19, 2026 14:49
@rustbot

This comment has been minimized.

@skrap

skrap commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Well that's surprising, does it need to build the whole kernel? I feel like I've even done that within a half hour GHA run.

Anyway if you can add a build script or instructions to your repo for reproduction and add a checksum, I still think it would be fine directly link your repo.

Nah, the kernel isn't so bad. The costly part is building the rest of the cross toolchain, which includes (IIRC) 3 copies of GCC - one initial bootstrap GCC, one for host, and one for target. GCC is a beast. (But building rust itself is 10x longer!)

@rustbot review

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things then LGTM.

Nah, the kernel isn't so bad. The costly part is building the rest of the cross toolchain, which includes (IIRC) 3 copies of GCC - one initial bootstrap GCC, one for host, and one for target. GCC is a beast. (But building rust itself is 10x longer!)

Ah that is not a fun build... I guess the toolchain can't be built with Clang's cross compilation?

View changes since this review

Comment on lines -17 to +20
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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document this so people know where to look for a toolchain? Just a link to this PR and/or your repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

@@ -1,22 +1,23 @@
FROM ubuntu:23.10
FROM ubuntu:25.04

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just the latest supported? (For my knowledge, no need to change to 26.04 either way)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no I was just copying from other Dockerfiles, but I see that you've since updated the base image on many to be 26.04. I'll follow suit.

Comment thread libc-test/build/main.rs Outdated
Comment on lines +4608 to +4610
// TODO: once uclibc catches up with the kernel headers, remove.
// See https://github.com/rust-lang/libc/issues/1896
"IPPROTO_MAX" => return true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a rust-lang convention that TODO is for comments to be resolved before merge, FIXME for comments to be merged (I know there are a few exceptions here)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

@skrap

skrap commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Ah that is not a fun build... I guess the toolchain can't be built with Clang's cross compilation?

That's not possible out of the box, no, and I want to stick with stock buildroot here.

@skrap
skrap force-pushed the bugfix/uclibc-docker-ci-build-fixes branch from 4f47b89 to 828343d Compare August 20, 2026 13:57
@rustbot

rustbot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@skrap

skrap commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: CI-related items ctest Issues relating to the ctest crate O-arm O-linux O-linux-like O-unix S-waiting-on-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants