本文介绍了Cargo 是否支持自定义配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我经常想在发布模式下使用 debug = true
进行编译,以便我可以更轻松地阅读生成的程序集.我目前正在这样做:
I often want to compile in release mode with debug = true
so that I can read the generated assembly a bit easier. I am currently doing this:
[profile.release]
debug = true
但我不希望在我的最终版本中使用任何调试符号.我想做这样的事情:
but I don't want any debug symbols in my final release build. I'd like to do something like:
[profile.custom]
debug = true
opt-level = 3
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'unwind'
然后运行
cargo build --custom
我已经阅读了文档但无济于事.
I've read the documentation to no avail.
推荐答案
不,Cargo 的稳定版本不支持此功能.它可作为不稳定夜间功能使用.
No, stable releases of Cargo do not support this. It is available as an unstable nightly feature.
如果您使用的是夜间版本的 Cargo,您可以在 Cargo.toml 中创建自定义配置文件:
If you are using a nightly version of Cargo, you can create custom profiles in your Cargo.toml:
cargo-features = ["named-profiles"]
[profile.release-lto]
inherits = "release"
lto = true
然后使用它们:
cargo +nightly build --profile release-lto -Z unstable-options
这篇关于Cargo 是否支持自定义配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!