This topic (and Rust in general) are way more low level than things I’ve experienced previously, so my understanding is very low, but what is the fundamental difference between Rust and Go that prevents Rust from creating binaries that don’t dynamically link to glibc?
In Linking golang statically, the author statically links glibc with a “glibc-static” package, which, according to everything I’ve read on this topic in the Rust world, says is either not possible or extremely ill-advised. It’s probably my lack of general knowledge on this type of systems programming, but I’m not clear about why Rust can’t take this same approach. The Rust team has been working on support for using musl instead of glibc, but Go has not had to do this to achieve static binaries, AFAIK.
My use case is creating Docker images that contain only static binaries with no operating system, like this:
FROM scratch
COPY ./rust_program /rust_program
CMD ["/rust_program"]
…where rust_program is just a binary that was compiled on any system with a Linux kernel. This is a pattern that is used and hyped a lot by people like Kelsey Hightower and I really want to be able to write Rust programs I can distribute this way. In most of Kelsey’s examples he just uses CGO_ENABLED=0 when building and that’s all it takes.