Skip to content

Commit e4e9365

Browse files
authored
Merge pull request #413 from NCGThompson/check-rustup-home-flag
Honor `$RUSTUP_HOME`
2 parents 1a8e0c3 + dcb531f commit e4e9365

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

build_system/src/test.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,10 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
488488
}
489489

490490
fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
491-
let toolchain = get_toolchain()?;
492-
491+
let toolchain = format!("+{channel}-{host}",
492+
channel = get_toolchain()?, // May also include date
493+
host = args.config_info.host_triple
494+
);
493495
let rust_dir = Some(Path::new("rust"));
494496
// If the repository was already cloned, command will fail, so doesn't matter.
495497
let _ = run_command_with_output_and_env(
@@ -524,6 +526,18 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
524526
Ok(cargo)
525527
}
526528
})?;
529+
let rustc = String::from_utf8(
530+
run_command_with_env(&[&"rustup", &toolchain, &"which", &"rustc"], rust_dir, Some(env))?.stdout,
531+
)
532+
.map_err(|error| format!("Failed to retrieve rustc path: {:?}", error))
533+
.and_then(|rustc| {
534+
let rustc = rustc.trim().to_owned();
535+
if rustc.is_empty() {
536+
Err(format!("`rustc` path is empty"))
537+
} else {
538+
Ok(rustc)
539+
}
540+
})?;
527541
let llvm_filecheck = match run_command_with_env(
528542
&[
529543
&"bash",
@@ -556,18 +570,16 @@ verbose-tests = true
556570
[build]
557571
cargo = "{cargo}"
558572
local-rebuild = true
559-
rustc = "{home}/.rustup/toolchains/{toolchain}-{host_triple}/bin/rustc"
573+
rustc = "{rustc}"
560574
561575
[target.x86_64-unknown-linux-gnu]
562576
llvm-filecheck = "{llvm_filecheck}"
563577
564578
[llvm]
565579
download-ci-llvm = false
566580
"#,
567-
cargo = cargo.trim(),
568-
home = env.get("HOME").unwrap(),
569-
toolchain = toolchain,
570-
host_triple = args.config_info.host_triple,
581+
cargo = cargo,
582+
rustc = rustc,
571583
llvm_filecheck = llvm_filecheck.trim(),
572584
),
573585
)

0 commit comments

Comments
 (0)