Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make statx available for all Linux targets #2713

Closed
wants to merge 1 commit into from

Conversation

alyssais
Copy link

@alyssais alyssais commented Mar 6, 2022

I think all this should be available on all Linux targets now, but I'm not very familiar with uClibc, so I'm not sure about it.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon.

Please see the contribution instructions for more information.

@alyssais
Copy link
Author

alyssais commented Mar 6, 2022

Oh, is there no musl/uClibc CI?

@Amanieu
Copy link
Member

Amanieu commented Mar 7, 2022

We do have it but it is only run by bors, not the normal CI for PRs.

@bors r+

@bors
Copy link
Contributor

bors commented Mar 7, 2022

📌 Commit d37715d has been approved by Amanieu

bors added a commit that referenced this pull request Mar 8, 2022
Make statx available for all Linux targets

I _think_ all this should be available on all Linux targets now, but I'm not very familiar with uClibc, so I'm not sure about it.
@bors
Copy link
Contributor

bors commented Mar 8, 2022

⌛ Testing commit d37715d with merge 32413d6...

@bors
Copy link
Contributor

bors commented Mar 8, 2022

💔 Test failed - checks-actions

@Amanieu
Copy link
Member

Amanieu commented Mar 11, 2022

You need to change libc-test/build.rs to include the statx header file in the C tests.

@JohnTitor
Copy link
Member

Ping @alyssais, could you address the above comment?

@bors
Copy link
Contributor

bors commented May 31, 2022

☔ The latest upstream changes (presumably #2808) made this pull request unmergeable. Please resolve the merge conflicts.

Comment on lines 3493 to 3500
pub fn statx(
dirfd: ::c_int,
pathname: *const c_char,
flags: ::c_int,
mask: ::c_uint,
statxbuf: *mut statx,
) -> ::c_int;

Copy link

Choose a reason for hiding this comment

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

AFIAK the current version of musl (1.2.3) doesn't implement a wrapper forSYS_statx.
But, I think it's worth leaving the rest (struct statx, constant, etc) available for all linux target

Copy link
Author

Choose a reason for hiding this comment

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

My mistake, you're correct.

@germag
Copy link

germag commented Jun 7, 2022

I'm quite interested in this PR

@alyssais
Copy link
Author

I've rebased the PR and updated it to drop the statx function, which as @germag pointed out, I was wrong about being present on Musl. Hopefully this also avoids the need to add a header to build.rs, although I'm not sure.

@alyssais
Copy link
Author

Thinking about it some more, is it right to expose even the structs if Musl doesn't? I thought it did, but it turns out the struct statx in Musl is internal-only, so to use it in a C program one would have to import <linux/stat.h>. What if Musl came up with its own statx API that used different structs?

@germag
Copy link

germag commented Jun 30, 2022

Thinking about it some more, is it right to expose even the structs if Musl doesn't? I thought it did, but it turns out the struct statx in Musl is internal-only, so to use it in a C program one would have to import <linux/stat.h>. What if Musl came up with its own statx API that used different structs?

if that were to happen, which I don't think it would, they would be incompatible with both the glibc and linux, since the statx struct is defined in the kernel headers.

@germag
Copy link

germag commented Sep 6, 2022

sorry for stepping in, are there any additional problems with this PR?

@JohnTitor
Copy link
Member

You need to change libc-test/build.rs to include the statx header file in the C tests.

The diff doesn't include the change mentioned above, have you tested that libc-test passes?

@bors
Copy link
Contributor

bors commented Oct 9, 2022

☔ The latest upstream changes (presumably #2941) made this pull request unmergeable. Please resolve the merge conflicts.

@alyssais
Copy link
Author

alyssais commented Oct 9, 2022

Thinking about it some more, is it right to expose even the structs if Musl doesn't? I thought it did, but it turns out the struct statx in Musl is internal-only, so to use it in a C program one would have to import <linux/stat.h>. What if Musl came up with its own statx API that used different structs?

if that were to happen, which I don't think it would, they would be incompatible with both the glibc and linux, since the statx struct is defined in the kernel headers.

I followed up on this in the #musl IRC channel, and the consensus there was that there's no guarantee that kernel headers and libc headers will be compatible for the same functionality, and that the libc crate probably shouldn't expose interfaces that come straight from the kernel but are not exposed by libc.

If libc does this in other places, then maybe it's okay, but I'd really like to hear the thoughts of a libc crate maintainer on this specific issue before I go further with this, since I'm not confident it's the way to go.

@workingjubilee
Copy link
Member

Mmm. I don't think we should be exposing this for all Linux targets. Mister Musl is correct, here. For instance, there's AT_{ElfAuxval} constants that are exposed by musl and glibc on a target-neutral basis, but that are not defined in a target-neutral way by the kernel. Those libcs have made their own commitments, effectively, on how to make that work going forward, in the (admittedly unlikely) event the kernel introduces a new definition which clashes. I believe it's okay for us to "round up" a bit for certain definitions, but the lack of support from a notable and widely-used libc makes me hesitate. Fixing a struct definition can be easier than fixing a function definition, but it is definitely still annoying to do and liable to be highly breaking.

@JohnTitor
Copy link
Member

Triage: The arguments above make some sense to me. Let's close this PR for now and continue the discussion if someone wants to support it strongly. Thanks @alyssais for the PR anyway!

@JohnTitor JohnTitor closed this Apr 19, 2023
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.

7 participants