-
Notifications
You must be signed in to change notification settings - Fork 161
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
What might porting std
to use rustix
look like?
#76
Comments
std
to use rsix
look like?std
to use rustix
look like?
I've now created a Building on these, I now have a fork of the To build it, set If anyone is interested in helping out, here are the next steps (in either order):
If anyone takes a look at this and runs into trouble, or has questions, please feel free to post here, or reach out on zulip. |
Rust already have ffi in core
|
rust-lang/rust#78802 is expected to allow |
According to https://github.com/rust-lang/rfcs/blob/master/text/2521-c_void-reunification.md#unresolved-questions, we can implement reset ctypes in core::ffi |
@sunfishcode hello! Thank you for the great library! I would like to help with issue. |
@ikrivosheev Great! I guess the first step would be to see if you can build it; I posted instructions above, but I'd be interested to hear if it works for anyone other than me :-). |
I just made a pass through everything updating it to use the latest rustix and origin. |
It appears the answer is no; it seems no one else is interested in this at this time. If anyone is interested in working on this, or even in just talking about what this might look like, please reach out! I hope to keep minimally maintaining this code, as it's a useful testcase for rustix, but I don't currently have a plan beyond that. |
Porting Rust's std to use
rustix
instead of using libc directly for I/O on Unix-family platforms would factor outunsafe
code, both for memory safety and I/O safety, and raw error handling, from std's main implementation code, making it easier to maintain. Secondarily, it'd also bring a number of optimizations, such as avoiding the allocation that std does on every system call that takes a string, and making system calls directly and avoidingerrno
.cap-std and mustang demonstrate that
rustix
can do most of the I/O that std does, and the pieces that are missing should be straightforward to add.rustix
and libc can coexist, so the work could be done incrementally.rustix
does depend on some things from std, though there's a workingno_std
branch, so we know the dependencies. The most interesting here are:std::os::raw::*
,CStr
,Ip*Addr
,SocketAddr*
,IoSlice*
- Rust has avoided moving these intocore
because they invove OS-specific types, so perhaps we could introduce a newcore_ffi
library and move these into it? Or, perhaps rustix should define its own versions of these which convert to and from thestd
versions. rustix doesn't need them to be full-featured, so it should be doable.BorrowedFd
,OwnedFd
, etc. - Could these also make sense in acore_ffi
library? Alternatively, rustix could similarly define its own.CString
- Similarly, this could go into a newalloc_ffi
library, or rustix could similarly define its own.Once we have the dependencies sorted out, I imagine the next steps would be to make a temporary fork of std, and port some calls to use rustix, and then make a proposal to the std maintainers and use the fork to show how it simplifies the code and factors out
unsafe
, as the primary motivators.For any of this to happen, I'll need help! Both because it's a lot of work, and because if there isn't community interest in helping with this, it's a sign that this doesn't actually make sense to do.
Does the above sound reasonable? Is it missing anything major? Is there anything about
rustix
's design that should be different? What questions should I be asking here that I'm not?Are there people interested and available to implement pieces of this? Many of the pieces should be straightforward, and I'd be happy to mentor people and explain what needs to be done.
The text was updated successfully, but these errors were encountered: