Reputation: 16148
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.
Upvotes: 9
Views: 3643
Reputation: 26559
As of Rust v1.57.0, the custom profiles feature is now stable.
Add a profile section, specify a base profile to inherit from, and tweak as you see fit:
[profile.production]
inherits = "release"
lto = true
Specify the profile to use via the --profile <name>
flag to cargo.
Upvotes: 12
Reputation: 430554
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
Upvotes: 2