@@ -859,14 +859,17 @@ impl Build {
859859 if self . config . rust_optimize . is_release ( ) { "release" } else { "debug" }
860860 }
861861
862- fn tools_dir ( & self , compiler : Compiler ) -> PathBuf {
863- let out = self . out . join ( compiler. host ) . join ( format ! ( "stage{}-tools-bin" , compiler. stage) ) ;
862+ fn tools_dir ( & self , build_compiler : Compiler ) -> PathBuf {
863+ let out = self
864+ . out
865+ . join ( build_compiler. host )
866+ . join ( format ! ( "stage{}-tools-bin" , build_compiler. stage + 1 ) ) ;
864867 t ! ( fs:: create_dir_all( & out) ) ;
865868 out
866869 }
867870
868871 /// Returns the root directory for all output generated in a particular
869- /// stage when running with a particular host compiler.
872+ /// stage when being built with a particular build compiler.
870873 ///
871874 /// The mode indicates what the root directory is for.
872875 fn stage_out ( & self , build_compiler : Compiler , mode : Mode ) -> PathBuf {
@@ -876,15 +879,17 @@ impl Build {
876879 ( None , "bootstrap-tools" )
877880 }
878881 fn staged_tool ( build_compiler : Compiler ) -> ( Option < u32 > , & ' static str ) {
879- ( Some ( build_compiler. stage ) , "tools" )
882+ ( Some ( build_compiler. stage + 1 ) , "tools" )
880883 }
881884
882885 let ( stage, suffix) = match mode {
886+ // Std is special, stage N std is built with stage N rustc
883887 Mode :: Std => ( Some ( build_compiler. stage ) , "std" ) ,
884- Mode :: Rustc => ( Some ( build_compiler. stage ) , "rustc" ) ,
885- Mode :: Codegen => ( Some ( build_compiler. stage ) , "codegen" ) ,
888+ // The rest of things are built with stage N-1 rustc
889+ Mode :: Rustc => ( Some ( build_compiler. stage + 1 ) , "rustc" ) ,
890+ Mode :: Codegen => ( Some ( build_compiler. stage + 1 ) , "codegen" ) ,
886891 Mode :: ToolBootstrap => bootstrap_tool ( ) ,
887- Mode :: ToolStd | Mode :: ToolRustc => ( Some ( build_compiler. stage ) , "tools" ) ,
892+ Mode :: ToolStd | Mode :: ToolRustc => ( Some ( build_compiler. stage + 1 ) , "tools" ) ,
888893 Mode :: ToolTarget => {
889894 // If we're not cross-compiling (the common case), share the target directory with
890895 // bootstrap tools to reuse the build cache.
@@ -907,8 +912,8 @@ impl Build {
907912 /// Returns the root output directory for all Cargo output in a given stage,
908913 /// running a particular compiler, whether or not we're building the
909914 /// standard library, and targeting the specified architecture.
910- fn cargo_out ( & self , compiler : Compiler , mode : Mode , target : TargetSelection ) -> PathBuf {
911- self . stage_out ( compiler , mode) . join ( target) . join ( self . cargo_dir ( ) )
915+ fn cargo_out ( & self , build_compiler : Compiler , mode : Mode , target : TargetSelection ) -> PathBuf {
916+ self . stage_out ( build_compiler , mode) . join ( target) . join ( self . cargo_dir ( ) )
912917 }
913918
914919 /// Root output directory of LLVM for `target`
0 commit comments