cargo
cargo copied to clipboard
A top-level root profile for overriding dev and release profiles simultaneously
Problem
Currently, if you have some profile that needs to always apply regardless of whether the crate is being built in release mode or not, you're required to specify the options twice, once for dev mode and once for release mode:
# rustflags specified via the unstable profile-rustflags option
[profile.dev.package.aes]
# use software implementation
rustflags = ["--cfg", "aes_force_soft"]
[profile.release.package.aes]
# use software implementation
rustflags = ["--cfg", "aes_force_soft"]
Proposed Solution
Since profile inheritance is already a concept, it would be nice if the dev
and release
profiles inherited from a root
profile so that both dev
and release
could be overridden together:
# rustflags specified via the unstable profile-rustflags option
[profile.root.package.aes]
# use software implementation
rustflags = ["--cfg", "aes_force_soft"]
Notes
According to the Zulip thread here: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/profile.20wildcards/near/281732406 , the name "root" is already reserved for this purpose.
For example:
[profile.dev]
implements = "root" # or implement implicitly, but require that root be listed first
# parameters
[profile.release]
implements = "root" # or implement implicitly, but require that root be listed first
# parameters
[profile.root]
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# but not all
Better:
[profile.dev]
implements = [ "root", "custom1", "custom2" ] # or implement 'root' implicitly, but require be listed first
# parameters
[profile.release]
implements = [ "root", "custom1", "custom2" ] # or implement 'root' implicitly, but require be listed first
# parameters
[profile.root]
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# but not all
[profile.custom1]
# parameters
# parameters
[profile.custom2]
# parameters
# parameters