3 ms·
If you can easily rebuild the project, I wonder what the binary size is if you add this to your top-level Cargo.toml: [profile.release] codegen-units =
by mwcampbell 4y ago
If you can easily rebuild the project, I wonder what the binary size is if you add this to your top-level Cargo.toml:
[profile.release]
codegen-units = 1
lto = "fat"
opt-level = "z"
panic = "abort"
Take out that last line if you need to recover from panics at runtime. So far, in my limited use of Rust, I haven't had to. Anyway, those are all the easy tweaks to reduce binary size.
- pdimitar 4y agoHad the first two already. I always prefer to optimize for speed and not size but just for the heck of it I enabled it. Wasn't super sure about the panic thing so I never used it but your comment is reassuring so I will just leave it in. From 5.0M to 3.0M, not bad! Turned the optimization for speed back on -- 4.4M! Wow.