Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

sunfishcode
Copy link
Member

This factors out several unsafe blocks, and replaces several instances of
manual error handling with Results.

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.

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.
@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 @ehuss (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 20, 2022
@weihanglo
Copy link
Member

Just curious. Why rustix can serve both glibc and musl but libc cannot? I'd like to learn the magic in behind 🧙🏾

@sunfishcode
Copy link
Member Author

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 NFS_SUPER_MAGIC constant. Which arguably should be fixed in libc, so I've now submitted rust-lang/libc#2639 to fix it.

`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`.
@joshtriplett
Copy link
Member

@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.

@alexcrichton
Copy link
Member

r? @joshtriplett

@rust-highfive rust-highfive assigned joshtriplett and unassigned ehuss Feb 1, 2022
@sunfishcode
Copy link
Member Author

Makes sense! I'll likely continue to maintain my branch, as it's a good testcase, but I'll close this PR for now.

@sunfishcode sunfishcode deleted the sunfishcode/rustix branch December 28, 2022 04:25
@sunfishcode sunfishcode restored the sunfishcode/rustix branch December 28, 2022 04:25
@sunfishcode sunfishcode deleted the sunfishcode/rustix branch December 28, 2022 04:51
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants