在开发版本和发行版本之间共享编译的依赖项

时间:2019-12-28 14:23:09

标签: performance rust compilation rust-cargo

我可以在优化模式下编译Rust依赖项,而在调试模式下编译自己的代码:

# Cargo.toml
[profile.dev.package."*"]
opt-level = 3
debug = false

但这仍然编译了我所有的依赖项两次:一次用于调试模式,一次用于发布模式,这似乎很浪费(即使使用sccache):

$ cargo clean
$ cargo build
... all the dependencies ...
Finished dev [unoptimized + debuginfo] target(s) in 1m 44s
$ cargo build --release
... all the dependencies ...
Finished release [optimized] target(s) in 2m 08s

理论上它只有一次,但是实际上有多个开发人员,干净的构建,cicd管道...

如何使开发模式和发布模式共享已编译的目标?

0 个答案:

没有答案