@@ -859,14 +859,17 @@ impl Build {
859
859
if self . config . rust_optimize . is_release ( ) { "release" } else { "debug" }
860
860
}
861
861
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 ) ) ;
864
867
t ! ( fs:: create_dir_all( & out) ) ;
865
868
out
866
869
}
867
870
868
871
/// 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.
870
873
///
871
874
/// The mode indicates what the root directory is for.
872
875
fn stage_out ( & self , build_compiler : Compiler , mode : Mode ) -> PathBuf {
@@ -876,15 +879,17 @@ impl Build {
876
879
( None , "bootstrap-tools" )
877
880
}
878
881
fn staged_tool ( build_compiler : Compiler ) -> ( Option < u32 > , & ' static str ) {
879
- ( Some ( build_compiler. stage ) , "tools" )
882
+ ( Some ( build_compiler. stage + 1 ) , "tools" )
880
883
}
881
884
882
885
let ( stage, suffix) = match mode {
886
+ // Std is special, stage N std is built with stage N rustc
883
887
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" ) ,
886
891
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" ) ,
888
893
Mode :: ToolTarget => {
889
894
// If we're not cross-compiling (the common case), share the target directory with
890
895
// bootstrap tools to reuse the build cache.
@@ -907,8 +912,8 @@ impl Build {
907
912
/// Returns the root output directory for all Cargo output in a given stage,
908
913
/// running a particular compiler, whether or not we're building the
909
914
/// 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 ( ) )
912
917
}
913
918
914
919
/// Root output directory of LLVM for `target`
0 commit comments