@@ -488,8 +488,10 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
488
488
}
489
489
490
490
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
+ ) ;
493
495
let rust_dir = Some ( Path :: new ( "rust" ) ) ;
494
496
// If the repository was already cloned, command will fail, so doesn't matter.
495
497
let _ = run_command_with_output_and_env (
@@ -524,6 +526,18 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
524
526
Ok ( cargo)
525
527
}
526
528
} ) ?;
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
+ } ) ?;
527
541
let llvm_filecheck = match run_command_with_env (
528
542
& [
529
543
& "bash" ,
@@ -556,18 +570,16 @@ verbose-tests = true
556
570
[build]
557
571
cargo = "{cargo}"
558
572
local-rebuild = true
559
- rustc = "{home}/.rustup/toolchains/{toolchain}-{host_triple}/bin/ rustc"
573
+ rustc = "{rustc} "
560
574
561
575
[target.x86_64-unknown-linux-gnu]
562
576
llvm-filecheck = "{llvm_filecheck}"
563
577
564
578
[llvm]
565
579
download-ci-llvm = false
566
580
"# ,
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,
571
583
llvm_filecheck = llvm_filecheck. trim( ) ,
572
584
) ,
573
585
)
0 commit comments