by bobsomers · 4y ago · 0 comments
Yes, and it's very important to note that Bazel does nothing to solve the problem about having a reproducible and hermetic runtime. Even if you think you aren't linking against anything dynamically, you are probably linking against several system libraries which must be present in the same versions to get reproducible and hermetic behavior.
This is solvable with Docker or exceptionally arcane Linux hackery, but it's completely missing from the Bazel messaging and it often leaves people thinking it provides more than it really does.
In particular, it’s almost impossible to get glibc to link statically. You need to switch to musl or another libc that supports it.
Go creates static binaries. I was a bit bummed out to learn that Rust doesn't by default since it requires glibc (and copying a binary to an older distribution fails because glibc is too old).
Two commands to get you running:
1) rustup target add x86_64-unknown-linux-musl
2) cargo build --target=x86_64-unknown-linux-musl
For other languages I'd say openssl is probably the next most common.
I don't think that's true for Rust. It defaults to depending on glibc, at least on Linux, and you need to explicitly build with musl to get static binaries.
Maybe I just like cults ^_^
Also, I do prefer to avoid dynamic linking altogether.