Does Cargo support custom profiles?

自古美人都是妖i 提交于 2020-01-04 03:00:59

问题


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'

And then run

cargo build --custom

I've read the documentation to no avail.


回答1:


Does Cargo support custom profiles?

No, stable releases of Cargo do not support this. It is available as an unstable nightly feature.

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

And then use them:

cargo +nightly build --profile release-lto -Z unstable-options


来源:https://stackoverflow.com/questions/41920192/does-cargo-support-custom-profiles

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!