Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A top-level root profile for overriding dev and release profiles simultaneously #10953

Open
bstrie opened this issue Aug 8, 2022 · 1 comment
Labels
A-profiles Area: profiles C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@bstrie
Copy link
Contributor

bstrie commented Aug 8, 2022

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.

@bstrie bstrie added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Aug 8, 2022
@ehuss ehuss added the A-profiles Area: profiles label Aug 13, 2022
@ehuss ehuss mentioned this issue Aug 23, 2022
@Zymlex
Copy link

Zymlex commented Aug 23, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-profiles Area: profiles C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

3 participants