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

Allow setting Cargo flags (e.g., -Zbuild-std) per profile #15053

Open
ProgrammedInsanity opened this issue Jan 11, 2025 · 2 comments
Open

Allow setting Cargo flags (e.g., -Zbuild-std) per profile #15053

ProgrammedInsanity opened this issue Jan 11, 2025 · 2 comments
Labels
A-profiles Area: profiles A-unstable Area: nightly unstable support C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@ProgrammedInsanity
Copy link

ProgrammedInsanity commented Jan 11, 2025

Problem

It would be great if we could specify flags like -Zbuild-std for individual profiles in Cargo.toml, instead of creating aliases or global config. This would provide more flexibility, especially when specific configurations are needed for development or release builds. It would also eliminate the need for different aliases for building, running, benchmarks, and tests, allowing us to simply specify --profile .....

Proposed Solution

Example

[profile.release]
cargoflags = [" -Zbuild-std"]

Notes

No response

@ProgrammedInsanity ProgrammedInsanity added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Jan 11, 2025
@epage epage added A-profiles Area: profiles A-unstable Area: nightly unstable support labels Jan 13, 2025
@epage
Copy link
Contributor

epage commented Jan 13, 2025

It would also eliminate the need for different aliases for building, running, benchmarks, and tests, allowing us to simply specify --profile .....

Instead of cargo check -Zbuild-std, you can do cargo -Zbuild-std check. You can then create a single alias

[alias]
z = "-Zbuild-std"

and run commands like

cargo z check

Or you can be like me and have a shell alias. Mine is called nargo so I can do nargo check.

You can also set -Z flags in config which can also be set in the environment or through --config.

@epage
Copy link
Contributor

epage commented Jan 13, 2025

It would be great if we could specify flags like -Zbuild-std for individual profiles in Cargo.toml, instead of creating aliases or global config.

Unstable features require an explicit opt-in. We could claim this new profile is just that but for myself, I'd prefer a central field for simplicity / reduced risk. In this way the solution would be

cargo-features = ["profile-cargo-features"]

# ...

[profile.release]
cargo-flags = ["-Zbuild-std']

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

No branches or pull requests

2 participants