@@ -137,6 +137,16 @@ impl Step for Std {
137
137
let target = self . target ;
138
138
let compiler = self . compiler ;
139
139
140
+ // We already have std ready to be used for stage 0.
141
+ if compiler. stage == 0 {
142
+ builder. ensure ( StdLink :: from_std (
143
+ self ,
144
+ builder. compiler ( compiler. stage , builder. config . build ) ,
145
+ ) ) ;
146
+
147
+ return ;
148
+ }
149
+
140
150
// When using `download-rustc`, we already have artifacts for the host available. Don't
141
151
// recompile them.
142
152
if builder. download_rustc ( ) && target == builder. build . build
@@ -585,18 +595,16 @@ impl Step for StdLink {
585
595
( libdir, hostdir)
586
596
} ;
587
597
588
- add_to_sysroot ( builder, & libdir, & hostdir, & libstd_stamp ( builder, compiler, target) ) ;
598
+ let is_downloaded_beta_stage0 = builder
599
+ . build
600
+ . config
601
+ . initial_rustc
602
+ . starts_with ( builder. out . join ( & compiler. host . triple ) . join ( "stage0/bin" ) ) ;
589
603
590
604
// Special case for stage0, to make `rustup toolchain link` and `x dist --stage 0`
591
605
// work for stage0-sysroot. We only do this if the stage0 compiler comes from beta,
592
606
// and is not set to a custom path.
593
- if compiler. stage == 0
594
- && builder
595
- . build
596
- . config
597
- . initial_rustc
598
- . starts_with ( builder. out . join ( & compiler. host . triple ) . join ( "stage0/bin" ) )
599
- {
607
+ if compiler. stage == 0 && is_downloaded_beta_stage0 {
600
608
// Copy bin files from stage0/bin to stage0-sysroot/bin
601
609
let sysroot = builder. out . join ( & compiler. host . triple ) . join ( "stage0-sysroot" ) ;
602
610
@@ -608,15 +616,7 @@ impl Step for StdLink {
608
616
609
617
// Copy all *.so files from stage0/lib to stage0-sysroot/lib
610
618
let stage0_lib_dir = builder. out . join ( & host) . join ( "stage0/lib" ) ;
611
- if let Ok ( files) = fs:: read_dir ( & stage0_lib_dir) {
612
- for file in files {
613
- let file = t ! ( file) ;
614
- let path = file. path ( ) ;
615
- if path. is_file ( ) && is_dylib ( & file. file_name ( ) . into_string ( ) . unwrap ( ) ) {
616
- builder. copy ( & path, & sysroot. join ( "lib" ) . join ( path. file_name ( ) . unwrap ( ) ) ) ;
617
- }
618
- }
619
- }
619
+ builder. cp_r ( & stage0_lib_dir, & sysroot. join ( "lib" ) ) ;
620
620
621
621
// Copy codegen-backends from stage0
622
622
let sysroot_codegen_backends = builder. sysroot_codegen_backends ( compiler) ;
@@ -630,6 +630,11 @@ impl Step for StdLink {
630
630
if stage0_codegen_backends. exists ( ) {
631
631
builder. cp_r ( & stage0_codegen_backends, & sysroot_codegen_backends) ;
632
632
}
633
+ } else if compiler. stage == 0 {
634
+ let sysroot = builder. out . join ( & compiler. host . triple ) . join ( "stage0-sysroot" ) ;
635
+ builder. cp_r ( & builder. initial_sysroot . join ( "lib" ) , & sysroot. join ( "lib" ) ) ;
636
+ } else {
637
+ add_to_sysroot ( builder, & libdir, & hostdir, & libstd_stamp ( builder, compiler, target) ) ;
633
638
}
634
639
}
635
640
}
0 commit comments