You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--env-set interaction with the compiler itself #161609
I wonder how should all of them interact with --set-env.
Never interact? Always interact? Interact on a case-by-case basis?
I.e. should --env-set PATH=. have a impact on where rustc would search the linker and other tools that the compiler may use, or if it should be restricted to the Rust code it-self: env!, option_env!, ... as it's currently the case ?
@fenollp@xclaesse@dblsaiko@bonzini(cc-ing you since expressed interest in the feature before) could you share your opinion on the blocker to stabilization.
Even after stabilization it wouldn't be applicable for some time to procedural macros (because they currently use std::env and proc_macro::tracked::env_var is not stable, which is a chicken-and-egg situation); also, it doesn't apply to build.rs files that compute the env var's name, because of the difference between env! and env::var.
These may not be huge issues (proc macros that read environment variables are relatively rare, and e.g. meson doesn't use build.rs at all), but there are some high profile cases like proc_macro_crate; and overall, they make the feature unortogonal.
I think it should be considered a failed experiment.
There is work in progress to use a wrapper program to invoke rustc with environment variables on Windows, at this point --env-set would be unnecessary. It is only used in connection with experimental parts of meson anyway.
Activity
Urgau commentedon Aug 23, 2026
@fenollp @xclaesse @dblsaiko @bonzini (cc-ing you since expressed interest in the feature before) could you share your opinion on the blocker to stabilization.
bonzini commentedon Aug 23, 2026
Even after stabilization it wouldn't be applicable for some time to procedural macros (because they currently use
std::envandproc_macro::tracked::env_varis not stable, which is a chicken-and-egg situation); also, it doesn't apply to build.rs files that compute the env var's name, because of the difference betweenenv!andenv::var.These may not be huge issues (proc macros that read environment variables are relatively rare, and e.g. meson doesn't use build.rs at all), but there are some high profile cases like
proc_macro_crate; and overall, they make the feature unortogonal.I think it should be considered a failed experiment.
Urgau commentedon Aug 24, 2026
Yeah, that's the difference between compile-time and runtime-time environment variables. The compiler can't do anything about runtime envs.
As you said it, it a chicken-and-egg situation, we have to start somewhere, and I'm sure we can push #99515 forward as well.
I'm not familar with the issues regarding this crate, could you explain them?
How does mesonbuild/meson#15148 fall into this? Are you expecting mesonbuild/meson#15148 to reverted?
bonzini commentedon Aug 24, 2026
It's an example of the chicken and egg situation.
There is work in progress to use a wrapper program to invoke rustc with environment variables on Windows, at this point --env-set would be unnecessary. It is only used in connection with experimental parts of meson anyway.
[-]`--env-set` interaction with the compiler it-self[/-][+]`--env-set` interaction with the compiler itself[/+]Urgau commentedon Aug 24, 2026
@dtolnay I see that buck2 is also using
--env-setin some places.As per above meson doesn't seems to be needed it anymore, what about buck2?
dtolnay commentedon Aug 24, 2026
Buck does not pass
--env-setto rustc, they are intercepted here.Urgau commentedon Aug 26, 2026
Thanks everyone for the feedback. There doesn't to be a future for the feature. I will propose removing it.
Rollup merge of rust-lang#161831 - Urgau:rm-env-set, r=nnethercote
Unrolled build for #161831 in rollup 162035
Rollup merge of #161831 - Urgau:rm-env-set, r=nnethercote