@@ -637,28 +637,6 @@ impl Step for DebuggerScripts {
637
637
}
638
638
}
639
639
640
- fn skip_host_target_lib ( builder : & Builder < ' _ > , compiler : Compiler ) -> bool {
641
- // The only true set of target libraries came from the build triple, so
642
- // let's reduce redundant work by only producing archives from that host.
643
- if compiler. host != builder. config . build {
644
- builder. info ( "\t skipping, not a build host" ) ;
645
- true
646
- } else {
647
- false
648
- }
649
- }
650
-
651
- /// Copy stamped files into an image's `target/lib` directory.
652
- fn copy_target_libs ( builder : & Builder < ' _ > , target : & str , image : & Path , stamp : & Path ) {
653
- let dst = image. join ( "lib/rustlib" ) . join ( target) . join ( "lib" ) ;
654
- t ! ( fs:: create_dir_all( & dst) ) ;
655
- for ( path, host) in builder. read_stamp_file ( stamp) {
656
- if !host || builder. config . build == target {
657
- builder. copy ( & path, & dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
658
- }
659
- }
660
- }
661
-
662
640
#[ derive( Debug , PartialOrd , Ord , Copy , Clone , Hash , PartialEq , Eq ) ]
663
641
pub struct Std {
664
642
pub compiler : Compiler ,
@@ -689,19 +667,44 @@ impl Step for Std {
689
667
let target = self . target ;
690
668
691
669
let name = pkgname ( builder, "rust-std" ) ;
692
- let archive = distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) ;
693
- if skip_host_target_lib ( builder, compiler) {
694
- return archive;
670
+
671
+ // The only true set of target libraries came from the build triple, so
672
+ // let's reduce redundant work by only producing archives from that host.
673
+ if compiler. host != builder. config . build {
674
+ builder. info ( "\t skipping, not a build host" ) ;
675
+ return distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) ;
695
676
}
696
677
697
- builder. ensure ( compile:: Std { compiler, target } ) ;
678
+ // We want to package up as many target libraries as possible
679
+ // for the `rust-std` package, so if this is a host target we
680
+ // depend on librustc and otherwise we just depend on libtest.
681
+ if builder. hosts . iter ( ) . any ( |t| t == target) {
682
+ builder. ensure ( compile:: Rustc { compiler, target } ) ;
683
+ } else {
684
+ builder. ensure ( compile:: Std { compiler, target } ) ;
685
+ }
698
686
699
687
let image = tmpdir ( builder) . join ( format ! ( "{}-{}-image" , name, target) ) ;
700
688
let _ = fs:: remove_dir_all ( & image) ;
701
689
702
- let compiler_to_use = builder. compiler_for ( compiler. stage , compiler. host , target) ;
703
- let stamp = compile:: libstd_stamp ( builder, compiler_to_use, target) ;
704
- copy_target_libs ( builder, & target, & image, & stamp) ;
690
+ let dst = image. join ( "lib/rustlib" ) . join ( target) ;
691
+ t ! ( fs:: create_dir_all( & dst) ) ;
692
+ let mut src = builder. sysroot_libdir ( compiler, target) . to_path_buf ( ) ;
693
+ src. pop ( ) ; // Remove the trailing /lib folder from the sysroot_libdir
694
+ builder. cp_filtered ( & src, & dst, & |path| {
695
+ if let Some ( name) = path. file_name ( ) . and_then ( |s| s. to_str ( ) ) {
696
+ if name == builder. config . rust_codegen_backends_dir . as_str ( ) {
697
+ return false
698
+ }
699
+ if name == "bin" {
700
+ return false
701
+ }
702
+ if name. contains ( "LLVM" ) {
703
+ return false
704
+ }
705
+ }
706
+ true
707
+ } ) ;
705
708
706
709
let mut cmd = rust_installer ( builder) ;
707
710
cmd. arg ( "generate" )
@@ -720,73 +723,7 @@ impl Step for Std {
720
723
let _time = timeit ( builder) ;
721
724
builder. run ( & mut cmd) ;
722
725
builder. remove_dir ( & image) ;
723
- archive
724
- }
725
- }
726
-
727
- #[ derive( Debug , PartialOrd , Ord , Copy , Clone , Hash , PartialEq , Eq ) ]
728
- pub struct RustcDev {
729
- pub compiler : Compiler ,
730
- pub target : Interned < String > ,
731
- }
732
-
733
- impl Step for RustcDev {
734
- type Output = PathBuf ;
735
- const DEFAULT : bool = true ;
736
- const ONLY_HOSTS : bool = true ;
737
-
738
- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
739
- run. path ( "rustc-dev" )
740
- }
741
-
742
- fn make_run ( run : RunConfig < ' _ > ) {
743
- run. builder . ensure ( RustcDev {
744
- compiler : run. builder . compiler_for (
745
- run. builder . top_stage ,
746
- run. builder . config . build ,
747
- run. target ,
748
- ) ,
749
- target : run. target ,
750
- } ) ;
751
- }
752
-
753
- fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
754
- let compiler = self . compiler ;
755
- let target = self . target ;
756
-
757
- let name = pkgname ( builder, "rustc-dev" ) ;
758
- let archive = distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) ;
759
- if skip_host_target_lib ( builder, compiler) {
760
- return archive;
761
- }
762
-
763
- builder. ensure ( compile:: Rustc { compiler, target } ) ;
764
-
765
- let image = tmpdir ( builder) . join ( format ! ( "{}-{}-image" , name, target) ) ;
766
- let _ = fs:: remove_dir_all ( & image) ;
767
-
768
- let compiler_to_use = builder. compiler_for ( compiler. stage , compiler. host , target) ;
769
- let stamp = compile:: librustc_stamp ( builder, compiler_to_use, target) ;
770
- copy_target_libs ( builder, & target, & image, & stamp) ;
771
-
772
- let mut cmd = rust_installer ( builder) ;
773
- cmd. arg ( "generate" )
774
- . arg ( "--product-name=Rust" )
775
- . arg ( "--rel-manifest-dir=rustlib" )
776
- . arg ( "--success-message=Rust-is-ready-to-develop." )
777
- . arg ( "--image-dir" ) . arg ( & image)
778
- . arg ( "--work-dir" ) . arg ( & tmpdir ( builder) )
779
- . arg ( "--output-dir" ) . arg ( & distdir ( builder) )
780
- . arg ( format ! ( "--package-name={}-{}" , name, target) )
781
- . arg ( format ! ( "--component-name=rustc-dev-{}" , target) )
782
- . arg ( "--legacy-manifest-dirs=rustlib,cargo" ) ;
783
-
784
- builder. info ( & format ! ( "Dist rustc-dev stage{} ({} -> {})" ,
785
- compiler. stage, & compiler. host, target) ) ;
786
- let _time = timeit ( builder) ;
787
- builder. run ( & mut cmd) ;
788
- builder. remove_dir ( & image) ;
789
- archive
726
+ distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) )
790
727
}
791
728
}
792
729
0 commit comments