Skip to content

Commit

Permalink
Drop RUSTC_BOOTSTRAP env var when building build scripts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
txase committed Feb 21, 2024
1 parent 543d7e9 commit 344a79c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/project-model/src/build_scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl WorkspaceBuildScripts {
toolchain: &Option<Version>,
sysroot: Option<&Sysroot>,
) -> io::Result<WorkspaceBuildScripts> {
const RUST_1_62: Version = Version::new(1, 62, 0);
const RUST_1_75: Version = Version::new(1, 75, 0);

let current_dir = match &config.invocation_location {
InvocationLocation::Root(root) if config.run_build_script_command.is_some() => {
Expand All @@ -162,7 +162,7 @@ impl WorkspaceBuildScripts {
progress,
) {
Ok(WorkspaceBuildScripts { error: Some(error), .. })
if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_62) =>
if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_75) =>
{
// building build scripts failed, attempt to build with --keep-going so
// that we potentially get more build data
Expand All @@ -172,7 +172,8 @@ impl WorkspaceBuildScripts {
&workspace.workspace_root().to_path_buf(),
sysroot,
)?;
cmd.args(["-Z", "unstable-options", "--keep-going"]).env("RUSTC_BOOTSTRAP", "1");

cmd.args(["--keep-going"]);
let mut res = Self::run_per_ws(cmd, workspace, current_dir, progress)?;
res.error = Some(error);
Ok(res)
Expand Down

0 comments on commit 344a79c

Please sign in to comment.