News for hackers. Stuff that matters.
Re:Making Rust binaries smaller by default by chrismorgan on Wednesday January 24, 2024 @04:35AM (#39115419)
opt-level z would not be a reasonable default: you should normally optimise for speed, not binary size.

lto and codegen-units=1 have a huge compile time cost. For release for general distribution you should tend to favour them, but the release profile isn’t just about that activity (especially because debug/opt-level<2 is often just too slow to use while developing). You commonly want to create another profile for production distribution.

Abort on panic changes runtime behaviour by stopping you from catching panics, which will completely break some programs, and harm the failure mode of others, so that e.g. one defective route on a web server will suddenly take the entire website down for everyone (or, if you have a supervisor that can restart the server, at least disrupt it for everyone).

Re:Making Rust binaries smaller by default by flohofwoe on Wednesday January 24, 2024 @04:39AM (#39115443)
> you should normally optimise for speed, not binary size

IME optimize for speed vs size usually isn't as clear cut as the name says though, sometimes smaller code does indeed run faster, but in most cases I've seen there's not much of a difference between -O3, -O2, -Os and -Oz.

Re:Making Rust binaries smaller by default by kibwen on Wednesday January 24, 2024 @07:16AM (#39116391)
Weirdly, most of the time I find that -O3 produces smaller binaries than -Oz.