Skip to content

Enable statx on all Linux targets and short-circuit it for musl - #159540

Open
Gelbpunkt wants to merge 2 commits into
rust-lang:mainfrom
Gelbpunkt:statx-musl
Open

Gelbpunkt wants to merge 2 commits into
rust-lang:mainfrom
Gelbpunkt:statx-musl

Conversation

@Gelbpunkt

@Gelbpunkt Gelbpunkt commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

This supersedes #154981. cc @strophy and sorry for taking a while to get around to this.


The first patch is the original PR with the commit message slightly adjusted, which makes use of the statx runtime detection on all Linux targets.

Since we want to unconditionally use statx on musl targets (because we know statx is available on our supported musl versions), we can call it through libc::statx. Making use of that requires telling the libc crate that we are on a musl version recent enough for it, which I decided to do in bootstrap. If there's a better place to set the environment variable, let me know, but this is the most straightforward way I could come up with.

With that in place, we can then wire up a short circuit to libc::statx for musl targets and skip the detection logic that all other Linux targets use.

On my aarch64-unknown-linux-musl machine, ./x.py test library/std still passes with these changes.

r? @tgross35 since I presume you have opinions on how I'm holding libc here

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 19, 2026
@rustbot

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

tgross35 is currently at their maximum review capacity.
They may take a while to respond.

@rustbot

This comment has been minimized.

@Gelbpunkt Gelbpunkt changed the title Statx musl Enable statx on all Linux targets and short-circuit it for musl Jul 19, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread src/bootstrap/src/core/builder/cargo.rs Outdated
@tgross35

Copy link
Copy Markdown
Member

@rustbot author

I think the thing to do here is un-gate statx in libc and avoid the complications here; if most users are using the bundled musl then there aren't any concerns there.

It would be good to set the libc_unstable_musl_v1_2_3 cfg but that should be a try build in r-l/r first then, once that works, update libc to set it if rustc-dep-of-std is enabled.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2026
@rustbot

rustbot commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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

@Darksonn

Darksonn commented Sep 3, 2026

Copy link
Copy Markdown
Member

libc PR: rust-lang/libc#5447

@strophy

strophy commented Sep 16, 2026

Copy link
Copy Markdown

We're seeing multiple build failures in Alpine Linux due to a recent libc release breaking rustix: https://gitlab.alpinelinux.org/alpine/aports/-/work_items/18444

bytecodealliance/rustix#1675

I think some coordination is required between rustix, libc and rust, but it's opaque to me which order the dominoes need to fall for everything to work again.

@tgross35

Copy link
Copy Markdown
Member

Is Alpine using unreleased libc? I'm not sure where an error would be coming from otherwise. I'm loosely holding off the libc release on that rustix issue but can't do so indefinitely, bytecodealliance/rustix#1496 has been around for a year...

Anyway that doesn't seem related to rust using statx, which is the PR here.

@xtqqczze

Copy link
Copy Markdown
Contributor

bytecodealliance/rustix#1496 has been around for a year...

I think that issue might be fixed in rustix v1.1.5.

@rust-bors

This comment has been minimized.

@tgross35

tgross35 commented Oct 2, 2026

Copy link
Copy Markdown
Member

There is now a new libc release out, which has statx on all musl targets. I don't have time to do the bump but if somebody wants to then do it in a separate PR and check the Apple iOS/watchOS/visionOS targets since there were some notable changes there.

@Gelbpunkt

Copy link
Copy Markdown
Contributor Author

I'll try to get around to opening a PR for updating libc to 0.2.190 to move this forward on the weekend

@tgross35

tgross35 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

std now has a libc that has statx for all musl arches

@asder8215

Copy link
Copy Markdown
Contributor

Just popping in here to say I appreciate you all for pushing statx on all musl arches. Was waiting for that change to be made to get #156269 across the line.

I'll update my PR to reflect that Metadata::from_statx is supported on Linux platforms (instead of it previously being supported on Linux platforms with a target env of gnu), but I'll likely wait for this PR to be merged since it changes cfg_has_statx to match on Linux unconditionally.

strophy and others added 2 commits October 20, 2026 10:06
Since statx is currently invoked through the syscall directly anyways,
it makes no sense to gate it to glibc targets, since none of this is
glibc specific at the moment. As long as the kernel is recent enough, it
supports statx.
On musl targets, we can assume that musl has support for statx and falls
back to fstatat internally, so there's no need to do detection and
caching of statx in std.
@rustbot

rustbot commented Oct 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.

This branch has not been deployed

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants