Skip to content

Enable statx on supported musl versions#154981

Open
strophy wants to merge 1 commit intorust-lang:mainfrom
strophy:musl-statx
Open

Enable statx on supported musl versions#154981
strophy wants to merge 1 commit intorust-lang:mainfrom
strophy:musl-statx

Conversation

@strophy
Copy link
Copy Markdown

@strophy strophy commented Apr 8, 2026

Rust has feature-gated fs statx calls to gnu libc only. This feature was added to musl libc in the 1.2.5 release, which was in turn included in Rust 1.93.0, see #142682

There is a stale feature gate that is still blocking access to statx calls, even though this is now available in musl libc through the libc crate v0.2.175+, see rust-lang/libc#3976

This PR enables the feature. Note that this will likely cause build breakages anywhere rustix is used, and the issue has already popped up in the rustix repo bytecodealliance/rustix#1496 for archs that never supported musl <1.2.5

This is my first PR here and I need some help coordinating between all these moving parts. @Gankra could you help maybe? Thanks!

More refs:
#67774
vectordotdev/vector#23813
https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/98199

r? @Gankra

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 8, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 8, 2026

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, jhpratt

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 8, 2026

Failed to set assignee to Gankra: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rust-log-analyzer

This comment has been minimized.

@strophy strophy changed the title Enable statx on musl versions that support it Enable statx on supported musl versions Apr 8, 2026
println!("cargo:rustc-check-cfg=cfg(musl_v1_2_3)");
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3");
if target_env == "musl" {
let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok()
Copy link
Copy Markdown
Member

@Darksonn Darksonn Apr 8, 2026

Choose a reason for hiding this comment

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

View changes since the review

Where is this environment variable set?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry, this variable is from the rust libc repo ci - I was setting it in Alpine Linux where I developed this patch, since I think both packages get built there, so I used the same logic. Should we set it unconditionally here? I'm unclear how to handle the upgrade, since I think a simultaneous change is needed in the vendored rustix version to prevent broken builds.

@tgross35 @neuschaefer @heiher can probably help clarify the issue better than me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aren't we already using a recent musl in std? I don't think we should need this kind of cfg if we link a known version.

The env is going away in favor of a cfg in libc anyway.

Comment on lines +190 to +192
// musl 1.2.5+: statx is a proper libc symbol, no weak linking needed.
#[cfg(all(target_env = "musl", musl_v1_2_3))]
unsafe fn statx(
Copy link
Copy Markdown
Member

@Darksonn Darksonn Apr 8, 2026

Choose a reason for hiding this comment

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

View changes since the review

Could weak linking be kept to avoid conditional compilation on musl version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I think we could keep that to avoid this condition since the upgrade to musl 1.2.5 has already taken place

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

6 participants