-
Notifications
You must be signed in to change notification settings - Fork 217
Description
I propose that on all targets where we know libstd is available, we use libstd instead of pthreads and libc for the use_file
implementation, effectively reverting to the original implementation.
The current proposal for x86_64-unknown-linux-none in #424 is to limit support for that target to Linux kernel versions that have the getrandom
syscall, so it won't use use_file
.
Historically, we've tried to make it so getrandom
avoids using libstd in part so that libstd itself could use getrandom
as a dependency. However, I think it is clear that libstd is not going to use this crate as its needs are almost completely different; indeed its code has diverged considerably.
Another reason we've avoided libstd is to ensure that we are #[no_std]
compatible. However, once we add x86_64-unknown-linux-none support, we'll have an actual no-std target that we can build (at least) for to ensure the core parts of this crate remain no_std
compatible.
use_file
is a significant chunk of the unsafe code, with the most problematic dependencies (libpthreads). It duplicates functionality that's in libstd, and the functionality it duplicates is exactly the kind of functionality (threading primitives) that we should avoid duplicating, as we're not getting any benefit from the QA and improvements in libstd.
Of all the targets that use the use_file
implementation, only one doesn't have libstd support: 32-bit x86 QNX Neutrino. I believe @samkearney is working on it, based on their comment in rust-lang/rust#109173 (comment).