-
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
Move sycall functions and macro from linux_raw/arch
to the linux-raw-sys
crate?
#1055
Comments
I've so far resisted this idea on the theory that for any syscall you'd use this with, it'd be better to add a wrapper to rustix and use that. There are a lot of syscalls with non-trivial considerations. Some syscalls have y2038 bugs or other anachronisms. Some syscalls, like And, while it's more work to add a wrapper to rustix just to be able invoke the one syscall you need in a given situation, it helps the ecosystem when it turns out to be multiple people who want to invoke the same syscall. That said, I'm open to discussing other approaches. |
You are right, but all this stuff is "handled" by marking the syscall functions The main reason why I would like to have the raw syscall functions is for adding "raw syscall" backend to the Exposing syscall functions can also be useful for other people who would like to experiment with unsafe low-level stuff or with different approaches to wrapping the Linux syscall API. |
If rustix is seen as excessive, then it sounds to me like we just shouldn't do rust-random/getrandom#401 at this time. Using a raw syscall API in getrandom would be less safe than just using libc. I'm not eager to be a maintainer of a public general-purpose raw-syscall API. It's not just If Rust wants to work towards using raw syscalls for more things in general, my preference would be to focus on improving rustix, such as by adding more If people want to experiment with alternate ways of wrapping the Linux syscall API, that's great. I don't expect that forking the code in rustix (if that's what they want) would be the hard part of such experiments. If people come up with something that works well enough that they want to use it in practice, then great, let's talk about how to migrate things off of rustix, or how best to factor rustix to best share code, or whatever the situation calls for. |
Assuming the syscall functions are implemented correctly, how so? We already use
But this fully applies to Feel free to close this issue and the |
I didn't realize getrandom was already using libc::syscall. That's an unfortunate situation, though I can see the practical reasons for it now. The way I look at it, if this was just about getrandom, maybe it'd be ok (ignoring the 32-bit x86 issue for the moment). But if every crate that just needs 1 or 3 or 5 syscalls does its own raw syscalls, then we end up in an ecosystem in which a set of concerns that previously almost no one in the Rust universe needed to know about before become spread out around many different crates and harder to audit. And we get an ecosystem where it's harder for users to opt out of raw syscalls and use libc for everything if one wishes to (and there are several reasons people do this in practice). And it's harder to port Rust code to new CPU architectures (getrandom may not be affected by this, but other syscalls are). That's not an ecosystem I want to design for. |
It's not only about I am sympathetic with your concerns, but maybe let's leave this decision to crate developers? If raw syscalls will not be exposed by Hopefully, with development of |
I guess, I had imagined the x86_64-unknown-linux-none conversation going a different direction. In the original PR creating the x86_64-unknown-linux-none target, @morr0ne talked about using rustix for most or even all I/O, such that most applications would already have rustix in their dependency tree, such that the cost (compile time, auditing) of each new crate that starts using it would be low. I imagined we'd be doing this just for linux-none, and not changing any other target (unless it makes sense to anyway). I think a lot of the topics being discussed make more sense when that's the big picture. |
I hope that eventually the none targets will have a proper
In some rare cases it makes sense to use raw syscall on non-none targets. For example, with the aforementioned To reiterate my point: you either trust developers to use sharp tools responsibly (note that |
@newpavlov wrote:
Would it help if you had feature flags for |
I don't think it's possible to do it in a reasonable way, you effectively would need to cut almost everything. And even after that |
I think a raw syscall crate would be reasonable, under the following conditions:
|
I don't think it should be done in the same crate which defines raw syscall functions/macros. But it could be a good feature for |
In some cases it would be nice to be able to call syscalls directly using the
linux-raw-sys
crate without relying on wrappers inrustix
.The text was updated successfully, but these errors were encountered: