-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Allow specifying rustflags per profile #7878
Copy link
Copy link
Closed
Labels
A-profilesArea: profilesArea: profilesA-rustflagsArea: rustflagsArea: rustflagsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Z-profile-rustflagsNightly: profile-rustflagsNightly: profile-rustflags
Metadata
Metadata
Assignees
Labels
A-profilesArea: profilesArea: profilesA-rustflagsArea: rustflagsArea: rustflagsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Z-profile-rustflagsNightly: profile-rustflagsNightly: profile-rustflags
Type
Fields
Give feedbackNo fields configured for issues without a type.
Related to #5777 but a separate issue:
Please allow specifying
rustflagsper profile.It would be very useful for setting certain flags only in debug or release (or even custom profiles).
E.g. I have a workspace with multiple crates, plus one backend bin crate and one frontend wasm crate, and I want to set
rustflags = ["-Ctarget-feature=+crt-static", "-Ctarget-cpu=haswell"]only for the backend and only for release builds!Btw, when I just set
rustflags = ["-Ctarget-feature=+crt-static", "-Ctarget-cpu=haswell"]in.cargo/confignow, (even though rustc ignores these flags when building my wasm frontend), cargo always recompiles all deps when switching between building the backend and frontend sub-crates. Even though for the frontend, everything is compiled for the wasm target anyway, so the compiled deps are never shared between frontend and backend crates! (Probably avoidable / another issue.)If it was possible to set rustflags per profile, together with profile-overrides it would be possible to avoid the unnecessary recompilation because I could set rustflags only for the backend and only for release builds, and in addition I could set other flags only for the frontend crate.
Also this would allow things like using the standard linker for release and lld for debug builds (to shorten linking time).