-
Notifications
You must be signed in to change notification settings - Fork 9
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
Port memfd to rustix. #27
Conversation
This ports memfd from using the libc crate directly to using [rustix], a syscall wrapper crate with a focus on safe APIs. This factors out several unsafe blocks, C string conversions, and error handling blocks. Rustix's MSRV is 1.48, so this would effectively bump memfd's MSRV to 1.48; Please feel free to decline this PR if you don't wish to take on these new requirements. [rustix]: https://crates.io/crates/rustix
This seems pretty nice to me at a quick scan. I think the most likely reason to not do this will be related to build times, if there's anything at all. |
Ah, it does add about 2 seconds to the build, on my machine; is that too much? In any case, I'll investigate the times to see if it can go faster. |
Thanks for the PR! Big fan of cap-std and rustix here, if @nagisa likes it too I'm happy to take it (I think they were not super happy with having To be honest I have one big concern about exposing To that extent, I'd feel much relieved if we could stick to suboptimal-but-boring stdlib/libc types in the signatures (e.g. in errors, constants, etc) and only use |
Makes sense. I've now fixed the use of |
My issue with the
Two seconds seem reasonable enough. That said, one other thought I had just now in favour of libc over rustix – libc is 0.2 and will remain 0.2 for the foreseeable future. This has a couple benefits, primary of which is a lower maintenance burden. Crates depending on libc are effectively always up-to-date (well, so long as they use a I feel like if we wanted to adopt something like That said… (in favour of rustix based implementation), I also consider an ability to build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Purely from the perspective of implementation this seems sound.
@@ -4,8 +4,6 @@ use std::fmt; | |||
/// Enumeration of errors possible in this library | |||
#[derive(Debug)] | |||
pub enum Error { | |||
/// Cannot convert the `name` argument to a C String! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self when releasing: this is a breaking change, so a semver-breaking version bump is necessary.
I investigated the build times, and found a few things that were easy to speed up. Rustix 0.33.1 now includes some build speedups which takes the extra build time down to about 1.5 seconds. I believe I've addressed all the review feedback now. |
NB: I still haven't forgotten this and have it in my TODO list. I'm hoping to one day get some time to set up dependabot or similar alert for dependency bounds. @sunfishcode are you looking to use |
Thanks! I see there's a build failure on Windows here. I'm preparing bytecodealliance/rustix#242 with a fix. |
This ports memfd from using the libc crate directly to using rustix, a syscall
wrapper crate with a focus on safe APIs. This factors out several unsafe
blocks, C string conversions, and error handling blocks.
Rustix's MSRV is 1.48, so this would effectively bump memfd's MSRV to 1.48;
Please feel free to decline this PR if you don't wish to take on these new
requirements.