Description
Standard hello world program generated with cargo new --bin mytest
fn main() {
println!("Hello, world!");
}
Built with cargo build --release
, the resulting binary size is 4270408 bytes.
This sounds unreasonably large for a hello world program.
After strip --strip-all
, we get 449224.
The non-stripped version is almost 10 times larger than the stripped version. Why?
This is with rustc 1.23.0-nightly (fa26421f5 2017-11-15)
, installed through rustup.
$ rustc -vV
rustc 1.23.0-nightly (fa26421f5 2017-11-15)
binary: rustc
commit-hash: fa26421f56e385b1055e65b29a55b36bb2eae23e
commit-date: 2017-11-15
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0
Here is stable rustc 1.21.0 (3b72af97e 2017-10-09)
for good measure:
Normal: 4059968
Stripped: 404096
This time, the initial size is lower, but the stripped size is even smaller, making the non-stripped version slightly more than 10 times larger.
(As a sidenote, I've been noticing that binary sizes for the same program have been steadily increasing with every new rustc, at least on x86_64-unknown-linux-gnu
, but that's a separate issue, I suppose)