@@ -765,6 +765,54 @@ impl Kind {
765765 }
766766}
767767
768+ #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
769+ struct Libdir {
770+ compiler : Compiler ,
771+ target : TargetSelection ,
772+ }
773+
774+ impl Step for Libdir {
775+ type Output = PathBuf ;
776+
777+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
778+ run. never ( )
779+ }
780+
781+ fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
782+ let relative_sysroot_libdir = builder. sysroot_libdir_relative ( self . compiler ) ;
783+ let sysroot = builder. sysroot ( self . compiler ) . join ( relative_sysroot_libdir) . join ( "rustlib" ) ;
784+
785+ if !builder. config . dry_run ( ) {
786+ // Avoid deleting the `rustlib/` directory we just copied (in `impl Step for
787+ // Sysroot`).
788+ if !builder. download_rustc ( ) {
789+ let sysroot_target_libdir = sysroot. join ( self . target ) . join ( "lib" ) ;
790+ builder. verbose ( || {
791+ eprintln ! (
792+ "Removing sysroot {} to avoid caching bugs" ,
793+ sysroot_target_libdir. display( )
794+ )
795+ } ) ;
796+ let _ = fs:: remove_dir_all ( & sysroot_target_libdir) ;
797+ t ! ( fs:: create_dir_all( & sysroot_target_libdir) ) ;
798+ }
799+
800+ if self . compiler . stage == 0 {
801+ // The stage 0 compiler for the build triple is always pre-built. Ensure that
802+ // `libLLVM.so` ends up in the target libdir, so that ui-fulldeps tests can use
803+ // it when run.
804+ dist:: maybe_install_llvm_target (
805+ builder,
806+ self . compiler . host ,
807+ & builder. sysroot ( self . compiler ) ,
808+ ) ;
809+ }
810+ }
811+
812+ sysroot
813+ }
814+ }
815+
768816impl < ' a > Builder < ' a > {
769817 fn get_step_descriptions ( kind : Kind ) -> Vec < StepDescription > {
770818 macro_rules! describe {
@@ -1165,56 +1213,13 @@ impl<'a> Builder<'a> {
11651213
11661214 /// Returns the bindir for a compiler's sysroot.
11671215 pub fn sysroot_target_bindir ( & self , compiler : Compiler , target : TargetSelection ) -> PathBuf {
1168- self . sysroot_target_libdir ( compiler, target) . parent ( ) . unwrap ( ) . join ( "bin" )
1216+ self . ensure ( Libdir { compiler, target } ) . join ( target ) . join ( "bin" )
11691217 }
11701218
11711219 /// Returns the libdir where the standard library and other artifacts are
11721220 /// found for a compiler's sysroot.
11731221 pub fn sysroot_target_libdir ( & self , compiler : Compiler , target : TargetSelection ) -> PathBuf {
1174- #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
1175- struct Libdir {
1176- compiler : Compiler ,
1177- target : TargetSelection ,
1178- }
1179- impl Step for Libdir {
1180- type Output = PathBuf ;
1181-
1182- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
1183- run. never ( )
1184- }
1185-
1186- fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
1187- let lib = builder. sysroot_libdir_relative ( self . compiler ) ;
1188- let sysroot = builder
1189- . sysroot ( self . compiler )
1190- . join ( lib)
1191- . join ( "rustlib" )
1192- . join ( self . target )
1193- . join ( "lib" ) ;
1194- // Avoid deleting the rustlib/ directory we just copied
1195- // (in `impl Step for Sysroot`).
1196- if !builder. download_rustc ( ) {
1197- builder. verbose ( || {
1198- println ! ( "Removing sysroot {} to avoid caching bugs" , sysroot. display( ) )
1199- } ) ;
1200- let _ = fs:: remove_dir_all ( & sysroot) ;
1201- t ! ( fs:: create_dir_all( & sysroot) ) ;
1202- }
1203-
1204- if self . compiler . stage == 0 {
1205- // The stage 0 compiler for the build triple is always pre-built.
1206- // Ensure that `libLLVM.so` ends up in the target libdir, so that ui-fulldeps tests can use it when run.
1207- dist:: maybe_install_llvm_target (
1208- builder,
1209- self . compiler . host ,
1210- & builder. sysroot ( self . compiler ) ,
1211- ) ;
1212- }
1213-
1214- sysroot
1215- }
1216- }
1217- self . ensure ( Libdir { compiler, target } )
1222+ self . ensure ( Libdir { compiler, target } ) . join ( target) . join ( "lib" )
12181223 }
12191224
12201225 pub fn sysroot_codegen_backends ( & self , compiler : Compiler ) -> PathBuf {
0 commit comments