Why is libc used? #5507
-
I have no experience with developing such binaries so please excuse the ignorance. It looks like the usage of RedoxOS developers have an incomplete rewrite of libc (relibc), but is libc absolutely necessary? Is libc a shortcut to the implementation of certain features too complicated to implement in rust? Is rewriting those parts of libc out of scope of the project? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Oh good question! You're gonna get a long answer 😄 We have to do syscalls somewhere, which means that somewhere in our dependency tree, there's Developing a libc alternative is definitely out of scope for this project, but we try to help out a bit with some of the projects I've mentioned when we need them. Also note that |
Beta Was this translation helpful? Give feedback.
Oh good question! You're gonna get a long answer 😄
We have to do syscalls somewhere, which means that somewhere in our dependency tree, there's
unsafe
. Either we useunsafe
ourselves or we let some library do it for us.libc
is used throughout the Rust ecosystem, even in the standard library. This also means that we are always usinglibc
indirectly throughstd
already. It is usually the recommended way to deal with low-level stuff, becauselibc
standardizes behaviour across many platforms. However, that doesn't mean that we're stuck withlibc
! We want to use as many safe abstractions overlibc
as possible. Thenix
crate, for example, provides safe APIs overlibc
. We also (indirectly) user…