Member-only story
The Art of Shrinking Rust Binaries: Part 1
Not a Medium member? Read the full article for free here.
Ever wondered why your tiny Rust program turns into a surprisingly large binary after compilation?
A big part of the answer is that Rust compiles the standard library and all your dependencies into the binary itself, and by default it keeps extra information like symbols around. The good news is that much of this is under your control.
In this series, The Art of Shrinking Rust Binaries, we’ll explore different techniques to reduce the size of Rust binaries, from simple compiler settings to more advanced optimization techniques.
We’ll start with a few practical techniques in this part, understand what they actually do, and see how much space they can save.
Let’s start shrinking.
Before changing anything, build your project in release mode and note the size of the binary:
cargo build --release
ls -lh target/release/my_app










