3 ms·
> Another thing that has been attempted is a stdlib for Rust that uses syscalls into the kernel much like Go's. With Rust, it's easier just to replace the C li
by ekidd 9y ago
> Another thing that has been attempted is a stdlib for Rust that uses syscalls into the kernel much like Go's.
With Rust, it's easier just to replace the C library! In particular, cross-compiling with a static musl-libc has been supported out of the box with for a while now. For pure Rust programs (or ones with small amounts of C handled by cargo), just write:
cargo build --target=x86_64-unknown-linux-musl
This will produce a 100% static binary that relies on nothing except the kernel.
For programs which require external C libraries, it's a bit trickier, because you need a static version of those libraries built against musl-libc. For common libraries like OpenSSL and libpq, I have a Docker container that makes this easier: https://github.com/emk/rust-musl-builder https://github.com/emk/rust-musl-builder