Skip to content

Commit

Permalink
Merge pull request #205 from dtolnay/envrustc
Browse files Browse the repository at this point in the history
Respect RUSTC environment variable if present
  • Loading branch information
dtolnay authored Dec 26, 2023
2 parents 1d4e1fb + fe8bd08 commit 6020de3
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,22 +410,26 @@ fn apply_args(cmd: &mut Command, args: &Expand, color: &Coloring, outfile: &Path
}

fn needs_rustc_bootstrap() -> bool {
let mut cmd = Command::new(cargo_binary());
cmd.arg("rustc");
cmd.arg("-Zunstable-options");
cmd.arg("--print=sysroot");
cmd.env("RUSTC_BOOTSTRAP", "1");
cmd.stdin(Stdio::null());
cmd.stderr(Stdio::null());
let Ok(output) = cmd.output() else {
return true;
};
let Ok(stdout) = str::from_utf8(&output.stdout) else {
return true;
let rustc = if let Some(rustc) = env::var_os("RUSTC") {
PathBuf::from(rustc)
} else {
let mut cmd = Command::new(cargo_binary());
cmd.arg("rustc");
cmd.arg("-Zunstable-options");
cmd.arg("--print=sysroot");
cmd.env("RUSTC_BOOTSTRAP", "1");
cmd.stdin(Stdio::null());
cmd.stderr(Stdio::null());
let Ok(output) = cmd.output() else {
return true;
};
let Ok(stdout) = str::from_utf8(&output.stdout) else {
return true;
};
let sysroot = Path::new(stdout.trim_end());
sysroot.join("bin").join("rustc")
};

let sysroot = Path::new(stdout.trim_end());
let rustc = sysroot.join("bin").join("rustc");
let mut cmd = Command::new(rustc);
cmd.arg("-Zunpretty=expanded");
cmd.arg("-");
Expand Down

0 comments on commit 6020de3

Please sign in to comment.