Hello, maintainer of min-sized-rust
here. The purpose of the repo is to serve as a starting point for people to learn about the ways to minimize the size of a Rust binary.
I have historically recommended opt-level = "z"
since from the docs it seems like it should be "s"
+ also don't unroll loops (i.e. strictly better). But someone recently reported that "z"
performed noticabley worse at size optimization than "s"
in their example.
The docs state that this can happen
It is recommended to experiment with different levels to find the right balance for your project. There may be surprising results, such as level
3
being slower than2
, or the"s"
and"z"
levels not being necessarily smaller. You may also want to reevaluate your settings over time as newer versions ofrustc
changes optimization behavior.
So for me, I was curious from those that know much more about rustc
and LLVM, what should I put as the default in min-sized-rust
? I presume many users will simply copy whatever the default is there. Should I default instead to "s"
(e.g., is "s"
simpler such that it generally performs more reliably?)
I plan to at a minimum update the guide section for opt-level
to include a reference to the fact that "s"
and "z"
might not always be smaller. Any other insights that might help me craft this in the best way would be appreciated.