-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Port cargo's libc usage to rustix. #10309
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
Conversation
This factors out several `unsafe` blocks, and replaces several instances of manual error handling with `Result`s. And it replaces several places that previously manipulated raw file descriptors to use the I/O safety owning and borrowing types and traits instead. This also eliminates the need for a special case for musl, allowing cargo to behave the same way on glibc and musl systems.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
Just curious. Why rustix can serve both glibc and musl but libc cannot? I'd like to learn the magic in behind 🧙🏾 |
In this case it's just that libc on musl doesn't provide a definition for Linux's |
`fds` here is an array with an explicit `nfds` count of how many elements are active, rather than a vec, so only pass the subrange `&fds[..nfds]` to `poll`.
@sunfishcode It's awesome to see that rustix is in a state to be able to do ports like this. rustix is really exciting technology. Traditionally, though Cargo doesn't make especially exciting technology choices. ;) We would need to understand better the degree to which it's safe for us to depend on rustix right now, and I think that's going to need to be a cautious and deliberate decision in which Cargo would prefer to follow others rather than leading the charge. Meanwhile, thank you for submitting the libc change. |
Makes sense! I'll likely continue to maintain my branch, as it's a good testcase, but I'll close this PR for now. |
This factors out several
unsafe
blocks, and replaces several instances ofmanual error handling with
Result
s.And it replaces several places that previously manipulated raw file descriptors
to use the I/O safety owning and borrowing types and traits instead.
This also eliminates the need for a special case for musl, allowing cargo to
behave the same way on glibc and musl systems.