Related to #5777 but a separate issue:
Please allow specifying rustflags per 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/config now, (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).
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).