Increasing binary sizes with each nightly


#1

I’m working on a project which is developed using nightly. I tend to keep my nightly compiler up-to-date, updating weekly in the worst case. Before every update I run cargo build --release, note down the executable binary size, then do the update, then check the new binary size.

It’s not uncommon to see 0,3M+ increase. Just today the binary size increased 0,5M, compared to last week’s nightly (can’t tell the exact date though – sorry!). I remember doing update & rebuild and seeing 0,3M+ increase many times.

I’m wondering what’s causing the increase. Any ideas? Is this because of sub-optimal tree-shaking in the compiler? (maybe bringing in unused stuff from std)

(I wish I had also measured stripped binary sizes, but I don’t have that info now. So I’m not sure if these are all debug symbols etc. or not.)


#2

Interesting. Can you maybe compile your binary against a bunch of older nightlies? rustup should make that easy enough :slight_smile:


Also, if binary size is important to you, have you set:

[profile.release]
opt-level = "z"
lto = true
panic = "abort"

By default, LLVM optimizes for expected runtime and will inline and loop-unroll as much as it can.