如果我使用cargo build --release命令,默认优化级别是什么?

问题描述 投票:2回答:1

The rustc compiler has 4 optimization leveljust like gcc.

opt-level    
This flag lets you control the optimization level.

0: no optimizations
1: basic optimizations
2: some optimizations
3: all optimizations
s: optimize for binary size
z: optimize for binary size, but also turn off loop vectorization.

如果我使用Cargo及其--release选项进行构建,使用哪个优化级别?

cargo build --release
Finished release [optimized] target(s) in 0.75s
rust rust-cargo
1个回答
5
投票

根据the cargo manual,发布版本的默认级别是-O3

# The release profile, used for `cargo build --release` (and the dependencies
# for `cargo test --release`,  including the local library or binary).
[profile.release]
opt-level = 3
debug = false
rpath = false
lto = false
debug-assertions = false
codegen-units = 16
panic = 'unwind'
incremental = false
overflow-checks = false
© www.soinside.com 2019 - 2024. All rights reserved.