Fat static binaries with Rust
September 15 201867 words, ~1 min. read
fat-binary, rust, linux
The following steps were required on a Linux system to build a fat, static binary with Rust.
- Add rust toolchain with musl
$ rustup target add x86_64-unknown-linux-musl
- Build the application by providing the above
musltarget
$ cargo build --target=x86_64-unknown-linux-musl
- Verify build output
$ file target/x86_64-unknown-linux-musl/debug/<app>
target/x86_64-unknown-linux-musl/debug/<app>: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=071b24021cc31a5f6f136c5148f69c163bbd1733, not stripped
$ ldd target/x86_64-unknown-linux-musl/debug/<app>
not a dynamic executable