@@ -754,76 +754,20 @@ impl<'a> Builder<'a> {
754
754
let mut cargo = Command :: new ( & self . initial_cargo ) ;
755
755
let out_dir = self . stage_out ( compiler, mode) ;
756
756
757
- // command specific path, we call clear_if_dirty with this
758
- let mut my_out = match cmd {
759
- "build" => self . cargo_out ( compiler, mode, target) ,
760
-
761
- // This is the intended out directory for crate documentation.
762
- "doc" | "rustdoc" => self . crate_doc_out ( target) ,
763
-
764
- _ => self . stage_out ( compiler, mode) ,
765
- } ;
766
-
767
- // This is for the original compiler, but if we're forced to use stage 1, then
768
- // std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
769
- // we copy the libs forward.
770
- let cmp = self . compiler_for ( compiler. stage , compiler. host , target) ;
771
-
772
- let libstd_stamp = match cmd {
773
- "check" | "clippy" | "fix" => check:: libstd_stamp ( self , cmp, target) ,
774
- _ => compile:: libstd_stamp ( self , cmp, target) ,
775
- } ;
776
-
777
- let libtest_stamp = match cmd {
778
- "check" | "clippy" | "fix" => check:: libtest_stamp ( self , cmp, target) ,
779
- _ => compile:: libtest_stamp ( self , cmp, target) ,
780
- } ;
781
-
782
- let librustc_stamp = match cmd {
783
- "check" | "clippy" | "fix" => check:: librustc_stamp ( self , cmp, target) ,
784
- _ => compile:: librustc_stamp ( self , cmp, target) ,
785
- } ;
757
+ // Codegen backends are not yet tracked by -Zbinary-dep-depinfo,
758
+ // so we need to explicitly clear out if they've been updated.
759
+ for backend in self . codegen_backends ( compiler) {
760
+ self . clear_if_dirty ( & out_dir, & backend) ;
761
+ }
786
762
787
763
if cmd == "doc" || cmd == "rustdoc" {
788
- if mode == Mode :: Rustc || mode == Mode :: ToolRustc || mode == Mode :: Codegen {
764
+ let my_out = match mode {
789
765
// This is the intended out directory for compiler documentation.
790
- my_out = self . compiler_doc_out ( target) ;
791
- }
766
+ Mode :: Rustc | Mode :: ToolRustc | Mode :: Codegen => self . compiler_doc_out ( target) ,
767
+ _ => self . crate_doc_out ( target) ,
768
+ } ;
792
769
let rustdoc = self . rustdoc ( compiler) ;
793
770
self . clear_if_dirty ( & my_out, & rustdoc) ;
794
- } else if cmd != "test" {
795
- match mode {
796
- Mode :: Std => {
797
- self . clear_if_dirty ( & my_out, & self . rustc ( compiler) ) ;
798
- for backend in self . codegen_backends ( compiler) {
799
- self . clear_if_dirty ( & my_out, & backend) ;
800
- }
801
- } ,
802
- Mode :: Test => {
803
- self . clear_if_dirty ( & my_out, & libstd_stamp) ;
804
- } ,
805
- Mode :: Rustc => {
806
- self . clear_if_dirty ( & my_out, & self . rustc ( compiler) ) ;
807
- self . clear_if_dirty ( & my_out, & libstd_stamp) ;
808
- self . clear_if_dirty ( & my_out, & libtest_stamp) ;
809
- } ,
810
- Mode :: Codegen => {
811
- self . clear_if_dirty ( & my_out, & librustc_stamp) ;
812
- } ,
813
- Mode :: ToolBootstrap => { } ,
814
- Mode :: ToolStd => {
815
- self . clear_if_dirty ( & my_out, & libstd_stamp) ;
816
- } ,
817
- Mode :: ToolTest => {
818
- self . clear_if_dirty ( & my_out, & libstd_stamp) ;
819
- self . clear_if_dirty ( & my_out, & libtest_stamp) ;
820
- } ,
821
- Mode :: ToolRustc => {
822
- self . clear_if_dirty ( & my_out, & libstd_stamp) ;
823
- self . clear_if_dirty ( & my_out, & libtest_stamp) ;
824
- self . clear_if_dirty ( & my_out, & librustc_stamp) ;
825
- } ,
826
- }
827
771
}
828
772
829
773
cargo
@@ -861,6 +805,19 @@ impl<'a> Builder<'a> {
861
805
} ,
862
806
}
863
807
808
+ // This tells Cargo (and in turn, rustc) to output more complete
809
+ // dependency information. Most importantly for rustbuild, this
810
+ // includes sysroot artifacts, like libstd, which means that we don't
811
+ // need to track those in rustbuild (an error prone process!). This
812
+ // feature is currently unstable as there may be some bugs and such, but
813
+ // it represents a big improvement in rustbuild's reliability on
814
+ // rebuilds, so we're using it here.
815
+ //
816
+ // For some additional context, see #63470 (the PR originally adding
817
+ // this), as well as #63012 which is the tracking issue for this
818
+ // feature on the rustc side.
819
+ cargo. arg ( "-Zbinary-dep-depinfo" ) ;
820
+
864
821
cargo. arg ( "-j" ) . arg ( self . jobs ( ) . to_string ( ) ) ;
865
822
// Remove make-related flags to ensure Cargo can correctly set things up
866
823
cargo. env_remove ( "MAKEFLAGS" ) ;
0 commit comments