What do the optimization levels `-Os` and `-Oz` do

2019-02-16 05:30发布

Executing rustc -C help shows (among other things):

-C opt-level=val       -- optimize with possible levels 0-3, s, or z

The levels 0 to 3 are fairly intuitive, I think: the higher the level, the more aggressive optimizations will be performed. However, I have no clue what the s and z options are doing and I couldn't find Rust-related information about them.

标签: rust
2条回答
祖国的老花朵
2楼-- · 2019-02-16 05:51

It seems like you are not the only one confused, as described in a Rust issue. It seems to follow the same pattern as Clang:

  • Os For optimising the size when compiling.
  • Oz For even more size optimisation.
查看更多
等我变得足够好
3楼-- · 2019-02-16 05:56

Looking at these and these lines in Rust's source code, I can say that s means optimize for size, and z means optimize for size some more.

All optimizations seem to be performed by the LLVM code-generation engine.

查看更多
登录 后发表回答