Skip to content

Conversation

@heiher
Copy link
Contributor

@heiher heiher commented Jan 27, 2026

Description

Some musl targets use out-of-line timespec fields in struct stat. This property is independent of the musl_v1_2_3 switch.

Add a new musl_stat_timespec cfg and use it to control the presence of inline time fields in musl struct stat definitions, avoiding incorrect API assumptions based on musl version alone.

Fixes #4939

Sources

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

Some musl targets use out-of-line timespec fields in struct stat.
This property is independent of the `musl_v1_2_3` switch.

Add a new `musl_stat_timespec` cfg and use it to control the presence
of inline time fields in musl struct stat definitions, avoiding
incorrect API assumptions based on musl version alone.
Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

The key idea sounds good to me, @tgross35 any thoughts on this? I haven't catched up the time64 change deeply and would like to hear your views.

@tgross35
Copy link
Contributor

Thanks for the fix, sorry that this broke.

Quite honestly I'm feeling like we should just delete the timespec fields and leave st_atime/st_atime_nsec (et. al.) with a comment explaining why we don't exactly match musl source, i.e. more or less revert 55fa65b. Musl allows using the st_atime names via macros https://github.com/kraj/musl/blob/ff441c9ddfefbb94e5881ddd5112b24a944dc36c/include/sys/stat.h#L32C18-L34 so we'd just have a mismatch on the _nsec fields which I think is fine. I'm assuming musl keeps _nsec a bit more hidden since they're not part of posix https://pubs.opengroup.org/onlinepubs/009695299/basedefs/sys/stat.h.html.

That's also nicer for our users who won't need to do a different config for musl and glibc.

Cc @xbjfk for your thoughts as you authored the commit in question.

@tgross35 tgross35 self-assigned this Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loongarch64-linux-musl broken after libc v0.2.179

4 participants