@@ -90,6 +90,54 @@ mod defaults {
9090 assert ! ( builder. cache. all:: <compile:: Rustc >( ) . is_empty( ) ) ;
9191 }
9292
93+ #[ test]
94+ fn build_cross_compile ( ) {
95+ let config = Config { stage : 1 , ..configure ( "build" , & [ "B" ] , & [ "B" ] ) } ;
96+ let build = Build :: new ( config) ;
97+ let mut builder = Builder :: new ( & build) ;
98+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Build ) , & [ ] ) ;
99+
100+ let a = TargetSelection :: from_user ( "A" ) ;
101+ let b = TargetSelection :: from_user ( "B" ) ;
102+
103+ // Ideally, this build wouldn't actually have `target: a`
104+ // rustdoc/rustcc/std here (the user only requested a host=B build, so
105+ // there's not really a need for us to build for target A in this case
106+ // (since we're producing stage 1 libraries/binaries). But currently
107+ // rustbuild is just a bit buggy here; this should be fixed though.
108+ assert_eq ! (
109+ first( builder. cache. all:: <compile:: Std >( ) ) ,
110+ & [
111+ compile:: Std { compiler: Compiler { host: a, stage: 0 } , target: a } ,
112+ compile:: Std { compiler: Compiler { host: a, stage: 1 } , target: a } ,
113+ compile:: Std { compiler: Compiler { host: a, stage: 0 } , target: b } ,
114+ compile:: Std { compiler: Compiler { host: a, stage: 1 } , target: b } ,
115+ ]
116+ ) ;
117+ assert_eq ! (
118+ first( builder. cache. all:: <compile:: Assemble >( ) ) ,
119+ & [
120+ compile:: Assemble { target_compiler: Compiler { host: a, stage: 0 } } ,
121+ compile:: Assemble { target_compiler: Compiler { host: a, stage: 1 } } ,
122+ compile:: Assemble { target_compiler: Compiler { host: b, stage: 1 } } ,
123+ ]
124+ ) ;
125+ assert_eq ! (
126+ first( builder. cache. all:: <tool:: Rustdoc >( ) ) ,
127+ & [
128+ tool:: Rustdoc { compiler: Compiler { host: a, stage: 1 } } ,
129+ tool:: Rustdoc { compiler: Compiler { host: b, stage: 1 } } ,
130+ ] ,
131+ ) ;
132+ assert_eq ! (
133+ first( builder. cache. all:: <compile:: Rustc >( ) ) ,
134+ & [
135+ compile:: Rustc { compiler: Compiler { host: a, stage: 0 } , target: a } ,
136+ compile:: Rustc { compiler: Compiler { host: a, stage: 0 } , target: b } ,
137+ ]
138+ ) ;
139+ }
140+
93141 #[ test]
94142 fn doc_default ( ) {
95143 let mut config = configure ( "doc" , & [ ] , & [ ] ) ;
0 commit comments