[英]What do the optimization levels `-Os` and `-Oz` do in rustc?
Executing rustc -C help
shows (among other things):执行
rustc -C help
显示(除其他外):
-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.我认为 0 到 3 级相当直观:级别越高,执行的优化就越积极。 However, I have no clue what the
s
and z
options are doing and I couldn't find Rust-related information about them.但是,我不知道
s
和z
选项在做什么,而且我找不到关于它们的 Rust 相关信息。
It seems like you are not the only one confused, as described in a Rust issue .正如Rust 问题中所述,您似乎并不是唯一一个感到困惑的人。 It seems to follow the same pattern as Clang:
它似乎遵循与 Clang 相同的模式:
Os
For optimising the size when compiling. Os
用于优化编译时的大小。Oz
For even more size optimisation. Oz
进行更多尺寸优化。These two sequences, Os and Oz, within LLVM, are pretty similar. LLVM 中的这两个序列 Os 和 Oz 非常相似。 Oz invokes 260 passes (I am using LLVM 12.0), whereas Os invokes 264. Oz' sequence of analyses and optimizations is almost a strict subsequence of Os', except for one pass (opt -loops), which appears in a different place within Os.
Oz 调用 260 次传递(我使用的是 LLVM 12.0),而 Os 调用 264 次。Oz 的分析和优化序列几乎是 Os' 的严格子序列,除了一次传递(opt -loops),它出现在内部的不同位置操作系统This said, notice that the effects of the optimizations can still be different, because they use different cost models, eg, constants that determine the behavior of optimizations.
这就是说,请注意优化的效果仍然可能不同,因为它们使用不同的成本模型,例如,确定优化行为的常数。 Thus, optimizations that have impact on size, like loop unrolling and inlining can behave differently in these two sequences.
因此,对大小有影响的优化,如循环展开和内联,在这两个序列中的行为可能不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.