4 ms·
Is that 5MB with or without symbols? Note that on Linux, binaries aren't stripped by default. Having said that, if your binary ended up including a hyper-based
by mwcampbell 4y ago
Is that 5MB with or without symbols? Note that on Linux, binaries aren't stripped by default.
Having said that, if your binary ended up including a hyper-based HTTP server and a TLS implementation, and was built with the default release profile (optimizing for speed rather than size), I can believe it would reach 5MB stripped.
- pdimitar 4y agoYeah it's picking quite a lot of baggage by using the relatively short list of deps. Debug symbols stripped it clocks at 5.9M, all symbols stripped it's at 5.0M. Obviously this is not critical. But I have to admit I envy Zig and OCaml. :)
- mwcampbell 4y agoIf 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.