@@ -1104,10 +1104,13 @@ impl Step for Sysroot {
1104
1104
/// 1-3.
1105
1105
fn run ( self , builder : & Builder < ' _ > ) -> Interned < PathBuf > {
1106
1106
let compiler = self . compiler ;
1107
+ let host_dir = builder. out . join ( & compiler. host . triple ) ;
1107
1108
let sysroot = if compiler. stage == 0 {
1108
- builder. out . join ( & compiler. host . triple ) . join ( "stage0-sysroot" )
1109
+ host_dir. join ( "stage0-sysroot" )
1110
+ } else if builder. download_rustc ( ) {
1111
+ host_dir. join ( "ci-rustc-sysroot" )
1109
1112
} else {
1110
- builder . out . join ( & compiler . host . triple ) . join ( format ! ( "stage{}" , compiler. stage) )
1113
+ host_dir . join ( format ! ( "stage{}" , compiler. stage) )
1111
1114
} ;
1112
1115
let _ = fs:: remove_dir_all ( & sysroot) ;
1113
1116
t ! ( fs:: create_dir_all( & sysroot) ) ;
@@ -1118,6 +1121,11 @@ impl Step for Sysroot {
1118
1121
builder. config. build, compiler. host,
1119
1122
"Cross-compiling is not yet supported with `download-rustc`" ,
1120
1123
) ;
1124
+
1125
+ // #102002, cleanup stage1 and stage0-sysroot folders when using download-rustc so people don't use old versions of the toolchain by accident.
1126
+ let _ = fs:: remove_dir_all ( host_dir. join ( "stage1" ) ) ;
1127
+ let _ = fs:: remove_dir_all ( host_dir. join ( "stage0-sysroot" ) ) ;
1128
+
1121
1129
// Copy the compiler into the correct sysroot.
1122
1130
let ci_rustc_dir =
1123
1131
builder. config . out . join ( & * builder. config . build . triple ) . join ( "ci-rustc" ) ;
0 commit comments