-
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
Should Android use linux_raw by default? #1095
Comments
As a data point, in the platform, we use the libc backend explicitly. Changing the default won't cause us any trouble, but we chose to do it this way because:
|
For 1: rustix is in some ways a lower-level interface than the platform libc or the standard library, and many users of rustix want to directly use specific syscalls and know which ones they're using. I think people already understand that by using rustix they may create dependencies on newer kernels for the functionality they use, and may have to write their own fallbacks if they want to support older kernels. For 3: the Rust targets are e.g. Point 2 is the one that seems like a tradeoff where people might want either behavior. This is a standard argument that reoccurs regularly. Some debugging tools operate on syscalls, some operate on library calls, and anything that uses syscalls directly will bypass debugging tools that operate on library calls. Operating on syscalls also bypasses I would argue that any debugging tool relying on all operations passing through libc calls is always going to miss some things, and is only useful for debugging cooperative programs. And if you're counting on programs to be cooperative, I think it's reasonable to need to build the program with options that target debugging. Based on that, I'd argue that rustix should default to |
I've more frequently seen it used as a way to get a more Rust-ergonomic interface to features exported by Re: "if they want to support older kernels", Android apps ship against an SDK version, not against a kernel version, and need to work on all kernels that vendors were allowed to ship with that SDK version. (I'm assuming apps here, because for platform or vendor work, folks are mostly grabbing packages from us, at which point the defaults become largely irrelevant.) The table for which kernel versions you must support for which API versions is somewhat complex, but
This is correct, but everything built with the SDK/NDK via C goes through All that said, this doesn't cause direct difficulties for our work if the default is raw system calls since as I pointed out, we explicitly set the backend for platform builds; I just think it is likely to be a hazard for app developers, as it may result in them accidentally producing apps which don't actually run on the target API level they describe, which may result in devices failing to run them that they expected would work, or trouble with store analyses etc. |
Clarification: I meant that rustix is in some ways lower level (or at the same level as) the platform C library, in that it isn't necessarily expected to call a libc function to do its work, and often calls a syscall directly just as libc does. I didn't mean that rustix is lower level than the libc crate.
It's not at all an issue of efficiency. If this were just about efficiency, I would absolutely agree that that's not a good enough reason to bypass libc. (Though sometimes size or dependencies are useful kinds of efficiency.) It's more about control: sometimes you want to invoke a specific syscall, or have the direct syscall interface rather than the libc abstraction (e.g. to get access to kernel functionality that libc doesn't expose). Any time you can get the functionality in a higher-level way (e.g. through std or through your app framework), you probably should. If you're using rustix directly, it's probably for a reason. That said, I'd also expect Rust app frameworks for Android to provide things such as feature flags for what Android SDK version your app supports, and those could in turn depend on any bits rustix might have for supporting older kernels. |
#1090 proposes to switch the default backend on Android from libc to linux_raw. I myself don't have enough context to determine whether this is a good idea. I'm opening this issue in case anyone who sees this has any insight to add.
The text was updated successfully, but these errors were encountered: