-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: Recompiles due to RUSTC_BOOTSTRAP #16621
Conversation
Some packages (e.g. thiserror) force a recompile if the value of the `RUSTC_BOOTSTRAP` env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options it uses. This causes flapping recompiles when building outside of RA. As of Cargo 1.75 the `--keep-going` flag is stable. This change uses the flag without `RUSTC_BOOTSTRAP` if the Cargo version is >= 1.75, and drops `--keep-going` otherwise. This fixes build script recompilation.
`cargo rustc -- <args>` first builds dependencies then calls `rustc <args>` for the current package. Here, we don't want to build dependencies, we just want to call `rustc --print`. An unstable `cargo rustc` `--print` command bypasses building dependencies first. This speeds up execution of this code path and ensures RA doesn't recompile dependencies with the `RUSTC_BOOTSRAP=1` env var flag set. Note that we must pass `-Z unstable-options` twice, first to enable the `cargo` unstable `--print` flag, then later to enable the unstable `rustc` `target-spec-json` print request.
dc54800
to
2826eb5
Compare
.args([ | ||
"rustc", | ||
"-Z", | ||
"unstable-options", | ||
"--print", | ||
"target-spec-json", | ||
"--", | ||
"-Z", | ||
"unstable-options", | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an accidental change (from debugging perhaps)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it looks wonky, it's intended. I explained it in the commit message for this change, which I'm pasting here:
cargo rustc -- <args>
first builds dependencies then callsrustc <args>
for the current package. Here, we don't want to build dependencies, we just want to callrustc --print
. An unstablecargo rustc
RUSTC_BOOTSRAP=1
env var flag set.Note that we must pass
-Z unstable-options
twice, first to enable thecargo
unstablerustc
target-spec-json
print request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, I was very confused by the invoked command as it looks somewhat funny 😅
This is a great change thanks, I've been wondering if we could do better as one other downside of the current command is that it doesnt work in virtual workspaces, whereas this does!
Thanks! This is a nice small change! |
☀️ Test successful - checks-actions |
Some packages (e.g. thiserror) force a recompile if the value of the
RUSTC_BOOTSTRAP
env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options. This causes flapping recompiles when building outside of RA.Fixes #15057