-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
bootstrap: CARGO_TARGET_$TARGET_RUSTFLAGS is appended to RUSTFLAGS #94874
Comments
This whole problem could be avoided once #94829 is implemented. |
Or alternatively, it might make sense to add a RUSTFLAGS_BOOTSTRAP_ITSELF flag or similar. |
@jonhoo, would this issue be solved by teaching bootstrap.py to append |
@intelfx That feels like it probably just adds another corner case users need to be aware of 😅 |
The What I wanted to know is — is this idea semantically correct? i. e. if you just make the bootstrap-the-bootstrap invocation use the same flags as the bootstrap itself for the host triple, will it always work, or are there plausible cases where bootstrap-the-bootstrap would need different flags than bootstrap-the-compiler for target == host? |
It's a good question. I think that would be fine, but it's also been a while since I was very deeply steeped in this, so take it with a grain of salt. |
In the bootstrap build, we respect
CARGO_TARGET_$TARGET_RUSTFLAGS
so that users can set target-specific rustflags if they wish. Unfortunately, the semantics ofCARGO_TARGET_$TARGET_RUSTFLAGS
in bootstrap do not match those of Cargo. In Cargo,CARGO_TARGET_$TARGET_RUSTFLAGS
are equivalent to settingtarget.$target.rustflags
, and it is overridden by theRUSTFLAGS
environment variable. Whereas what bootstrap currently does is concatenate them:rust/src/bootstrap/builder.rs
Lines 1802 to 1807 in 2c6a29a
Now, bootstrap is in a slightly weird position where it always sets
RUSTFLAGS
, so the "usual" rules don't really make sense. Instead, the intention is probably to allow users to set a "general" set of flags forrustc
(throughRUSTFLAGS
) more akin tobuild.rustflags
and then override them for specific targets if desired. But unfortunately that doesn't match today's semantics either since the two environment variables are simply merged.The big downside of having them always merge is that it makes it much more difficult to deal with targets that need fewer flags than the "general" set. For example, I have to set
-Clink-arg=--gcc-toolchain=...
inRUSTFLAGS
. But when trying to build for Android targets that particular GCC toolchain won't work. So, I need to "reset" rustflags to not include the general set fromRUSTFLAGS
for those targets. But today, I have no way of doing that.Now, in theory, I could just not set
RUSTFLAGS
and all would be well. But unfortunately that won't work either becauseRUSTFLAGS
is the only environment variable that can be set to pass flags torustc
for buildingrustbuild
itself (see, for example, #94234). And since in my environment--gcc-toolchain=
is a required argument to the linker, I'm stuck between a rock and a hard place — either I setRUSTFLAGS
and my Android builds fail, or I don't set it and therustbuild
build fails.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: