gpt4 book ai didi

rust - cargo build --release 的默认优化级别是多少?

转载 作者:行者123 更新时间:2023-11-29 08:03:36 25 4
gpt4 key购买 nike

rustc 编译器有 four optimization levels , just like GCC :

opt-level
This flag controls the optimization level.

0: no optimization, also turns on cfg(debug_assertions) (the default).
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

最佳答案

根据 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
split-debuginfo = '...' # Platform-specific.
debug-assertions = false
overflow-checks = false
lto = false
panic = 'unwind'
incremental = false
codegen-units = 16
rpath = false

关于rust - cargo build --release 的默认优化级别是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55029638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com