@@ -231,7 +231,7 @@ impl Step for Std {
231
231
. join ( "bin" ) ;
232
232
if src_sysroot_bin. exists ( ) {
233
233
let target_sysroot_bin =
234
- builder. sysroot_libdir ( compiler, target) . parent ( ) . unwrap ( ) . join ( "bin" ) ;
234
+ builder. sysroot_target_libdir ( compiler, target) . parent ( ) . unwrap ( ) . join ( "bin" ) ;
235
235
t ! ( fs:: create_dir_all( & target_sysroot_bin) ) ;
236
236
builder. cp_link_r ( & src_sysroot_bin, & target_sysroot_bin) ;
237
237
}
@@ -345,7 +345,7 @@ fn copy_third_party_objects(
345
345
&& ( target. contains ( "linux" ) || target. contains ( "fuchsia" ) )
346
346
{
347
347
let libunwind_path =
348
- copy_llvm_libunwind ( builder, target, & builder. sysroot_libdir ( * compiler, target) ) ;
348
+ copy_llvm_libunwind ( builder, target, & builder. sysroot_target_libdir ( * compiler, target) ) ;
349
349
target_deps. push ( ( libunwind_path, DependencyType :: Target ) ) ;
350
350
}
351
351
@@ -358,7 +358,8 @@ fn copy_self_contained_objects(
358
358
compiler : & Compiler ,
359
359
target : TargetSelection ,
360
360
) -> Vec < ( PathBuf , DependencyType ) > {
361
- let libdir_self_contained = builder. sysroot_libdir ( * compiler, target) . join ( "self-contained" ) ;
361
+ let libdir_self_contained =
362
+ builder. sysroot_target_libdir ( * compiler, target) . join ( "self-contained" ) ;
362
363
t ! ( fs:: create_dir_all( & libdir_self_contained) ) ;
363
364
let mut target_deps = vec ! [ ] ;
364
365
@@ -612,8 +613,8 @@ impl Step for StdLink {
612
613
let hostdir = sysroot. join ( lib) . join ( "rustlib" ) . join ( compiler. host . triple ) . join ( "lib" ) ;
613
614
( libdir, hostdir)
614
615
} else {
615
- let libdir = builder. sysroot_libdir ( target_compiler, target) ;
616
- let hostdir = builder. sysroot_libdir ( target_compiler, compiler. host ) ;
616
+ let libdir = builder. sysroot_target_libdir ( target_compiler, target) ;
617
+ let hostdir = builder. sysroot_target_libdir ( target_compiler, compiler. host ) ;
617
618
( libdir, hostdir)
618
619
} ;
619
620
@@ -680,7 +681,7 @@ fn copy_sanitizers(
680
681
}
681
682
682
683
let mut target_deps = Vec :: new ( ) ;
683
- let libdir = builder. sysroot_libdir ( * compiler, target) ;
684
+ let libdir = builder. sysroot_target_libdir ( * compiler, target) ;
684
685
685
686
for runtime in & runtimes {
686
687
let dst = libdir. join ( & runtime. name ) ;
@@ -766,7 +767,7 @@ impl Step for StartupObjects {
766
767
767
768
let src_dir = & builder. src . join ( "library" ) . join ( "rtstartup" ) ;
768
769
let dst_dir = & builder. native_dir ( target) . join ( "rtstartup" ) ;
769
- let sysroot_dir = & builder. sysroot_libdir ( for_compiler, target) ;
770
+ let sysroot_dir = & builder. sysroot_target_libdir ( for_compiler, target) ;
770
771
t ! ( fs:: create_dir_all( dst_dir) ) ;
771
772
772
773
for file in & [ "rsbegin" , "rsend" ] {
@@ -1218,10 +1219,17 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
1218
1219
}
1219
1220
}
1220
1221
1222
+ /// `RustcLink` copies all of the rlibs from the rustc build into the previous stage's sysroot.
1223
+ /// This is necessary for tools using `rustc_private`, where the previous compiler will build
1224
+ /// a tool against the next compiler.
1225
+ /// To build a tool against a compiler, the rlibs of that compiler that it links against
1226
+ /// must be in the sysroot of the compiler that's doing the compiling.
1221
1227
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1222
1228
struct RustcLink {
1229
+ /// The compiler whose rlibs we are copying around.
1223
1230
pub compiler : Compiler ,
1224
- pub target_compiler : Compiler ,
1231
+ /// This is the compiler into whose sysroot we want to copy the rlibs into.
1232
+ pub previous_stage_compiler : Compiler ,
1225
1233
pub target : TargetSelection ,
1226
1234
/// Not actually used; only present to make sure the cache invalidation is correct.
1227
1235
crates : Vec < String > ,
@@ -1231,7 +1239,7 @@ impl RustcLink {
1231
1239
fn from_rustc ( rustc : Rustc , host_compiler : Compiler ) -> Self {
1232
1240
Self {
1233
1241
compiler : host_compiler,
1234
- target_compiler : rustc. compiler ,
1242
+ previous_stage_compiler : rustc. compiler ,
1235
1243
target : rustc. target ,
1236
1244
crates : rustc. crates ,
1237
1245
}
@@ -1248,12 +1256,12 @@ impl Step for RustcLink {
1248
1256
/// Same as `std_link`, only for librustc
1249
1257
fn run ( self , builder : & Builder < ' _ > ) {
1250
1258
let compiler = self . compiler ;
1251
- let target_compiler = self . target_compiler ;
1259
+ let previous_stage_compiler = self . previous_stage_compiler ;
1252
1260
let target = self . target ;
1253
1261
add_to_sysroot (
1254
1262
builder,
1255
- & builder. sysroot_libdir ( target_compiler , target) ,
1256
- & builder. sysroot_libdir ( target_compiler , compiler. host ) ,
1263
+ & builder. sysroot_target_libdir ( previous_stage_compiler , target) ,
1264
+ & builder. sysroot_target_libdir ( previous_stage_compiler , compiler. host ) ,
1257
1265
& librustc_stamp ( builder, compiler, target) ,
1258
1266
) ;
1259
1267
}
@@ -1797,7 +1805,7 @@ impl Step for Assemble {
1797
1805
let sysroot = builder. sysroot ( target_compiler) ;
1798
1806
let rustc_libdir = builder. rustc_libdir ( target_compiler) ;
1799
1807
t ! ( fs:: create_dir_all( & rustc_libdir) ) ;
1800
- let src_libdir = builder. sysroot_libdir ( build_compiler, host) ;
1808
+ let src_libdir = builder. sysroot_target_libdir ( build_compiler, host) ;
1801
1809
for f in builder. read_dir ( & src_libdir) {
1802
1810
let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
1803
1811
if ( is_dylib ( & filename) || is_debug_info ( & filename) ) && !proc_macros. contains ( & filename)
@@ -1810,7 +1818,7 @@ impl Step for Assemble {
1810
1818
1811
1819
// We prepend this bin directory to the user PATH when linking Rust binaries. To
1812
1820
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
1813
- let libdir = builder. sysroot_libdir ( target_compiler, target_compiler. host ) ;
1821
+ let libdir = builder. sysroot_target_libdir ( target_compiler, target_compiler. host ) ;
1814
1822
let libdir_bin = libdir. parent ( ) . unwrap ( ) . join ( "bin" ) ;
1815
1823
t ! ( fs:: create_dir_all( & libdir_bin) ) ;
1816
1824
if let Some ( lld_install) = lld_install {
0 commit comments