Skip to content

Commit

Permalink
Auto merge of #102266 - Mark-Simulacrum:fix-custom-rustc, r=jyn514
Browse files Browse the repository at this point in the history
Support overriding initial rustc and cargo paths

This restores functionality broken by #98483. Unfortunately, it doesn't add a test to verify this works, but in this case we notice pretty quickly as perf uses this functionality and so reports breakage immediately after merging.

r? `@jyn514`

cc https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/rustc.20and.20cargo.20option.20broken.20in.20config.2Etoml, https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Rustc.20benchmark.20broken
  • Loading branch information
bors committed Sep 25, 2022
2 parents 17e8752 + 439597b commit f3fafbb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,7 @@ impl Config {
config.config = toml_path;

let build = toml.build.unwrap_or_default();
let has_custom_rustc = build.rustc.is_some();

set(&mut config.initial_rustc, build.rustc.map(PathBuf::from));
set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from)));
// NOTE: Bootstrap spawns various commands with different working directories.
// To avoid writing to random places on the file system, `config.out` needs to be an absolute path.
Expand All @@ -912,10 +910,14 @@ impl Config {
config.out = crate::util::absolute(&config.out);
}

if !has_custom_rustc && !config.initial_rustc.starts_with(&config.out) {
config.initial_rustc = config.out.join(config.build.triple).join("stage0/bin/rustc");
config.initial_cargo = config.out.join(config.build.triple).join("stage0/bin/cargo");
}
config.initial_rustc = build
.rustc
.map(PathBuf::from)
.unwrap_or_else(|| config.out.join(config.build.triple).join("stage0/bin/rustc"));
config.initial_cargo = build
.cargo
.map(PathBuf::from)
.unwrap_or_else(|| config.out.join(config.build.triple).join("stage0/bin/cargo"));

// NOTE: it's important this comes *after* we set `initial_rustc` just above.
if config.dry_run {
Expand Down

0 comments on commit f3fafbb

Please sign in to comment.