@@ -408,6 +408,7 @@ mod dist {
408408 use pretty_assertions:: assert_eq;
409409
410410 use super :: { Config , TEST_TRIPLE_1 , TEST_TRIPLE_2 , TEST_TRIPLE_3 , first, run_build} ;
411+ use crate :: Flags ;
411412 use crate :: core:: builder:: * ;
412413
413414 fn configure ( host : & [ & str ] , target : & [ & str ] ) -> Config {
@@ -646,6 +647,38 @@ mod dist {
646647 ) ;
647648 }
648649
650+ /// This also serves as an important regression test for <https://github.com/rust-lang/rust/issues/138123>
651+ /// and <https://github.com/rust-lang/rust/issues/138004>.
652+ #[ test]
653+ fn dist_all_cross ( ) {
654+ let cmd_args =
655+ & [ "dist" , "--stage" , "2" , "--dry-run" , "--config=/does/not/exist" ] . map ( str:: to_owned) ;
656+ let config_str = r#"
657+ [rust]
658+ channel = "nightly"
659+
660+ [build]
661+ extended = true
662+
663+ build = "i686-unknown-haiku"
664+ host = ["i686-unknown-netbsd"]
665+ target = ["i686-unknown-netbsd"]
666+
667+ "# ;
668+ let config = Config :: parse_inner ( Flags :: parse ( cmd_args) , |& _| toml:: from_str ( config_str) ) ;
669+ let mut cache = run_build ( & [ ] , config) ;
670+
671+ // Stage 2 `compile::Rustc` should **NEVER** be cached here.
672+ assert_eq ! (
673+ first( cache. all:: <compile:: Rustc >( ) ) ,
674+ & [
675+ rustc!( TEST_TRIPLE_1 => TEST_TRIPLE_1 , stage = 0 ) ,
676+ rustc!( TEST_TRIPLE_1 => TEST_TRIPLE_1 , stage = 1 ) ,
677+ rustc!( TEST_TRIPLE_1 => TEST_TRIPLE_3 , stage = 1 ) ,
678+ ]
679+ ) ;
680+ }
681+
649682 #[ test]
650683 fn build_all ( ) {
651684 let build = Build :: new ( configure (
0 commit comments