8
8
//! In theory if we get past this phase it's a bug if a build fails, but in
9
9
//! practice that's likely not true!
10
10
11
- use std:: collections:: HashMap ;
11
+ use std:: collections:: { HashMap , HashSet } ;
12
12
use std:: env;
13
13
use std:: ffi:: { OsStr , OsString } ;
14
14
use std:: fs;
@@ -33,8 +33,6 @@ pub struct Finder {
33
33
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
34
34
const STAGE0_MISSING_TARGETS : & [ & str ] = & [
35
35
// just a dummy comment so the list doesn't get onelined
36
- "aarch64-apple-visionos" ,
37
- "aarch64-apple-visionos-sim" ,
38
36
] ;
39
37
40
38
impl Finder {
@@ -169,6 +167,12 @@ than building it.
169
167
. map ( |p| cmd_finder. must_have ( p) )
170
168
. or_else ( || cmd_finder. maybe_have ( "reuse" ) ) ;
171
169
170
+ let stage0_supported_target_list: HashSet < String > =
171
+ output ( Command :: new ( & build. config . initial_rustc ) . args ( [ "--print" , "target-list" ] ) )
172
+ . lines ( )
173
+ . map ( |s| s. to_string ( ) )
174
+ . collect ( ) ;
175
+
172
176
// We're gonna build some custom C code here and there, host triples
173
177
// also build some C++ shims for LLVM so we need a C++ compiler.
174
178
for target in & build. targets {
@@ -195,11 +199,19 @@ than building it.
195
199
if ![ "A" , "B" , "C" ] . contains ( & target_str. as_str ( ) ) {
196
200
let mut has_target = false ;
197
201
198
- let supported_target_list =
199
- output ( Command :: new ( & build. config . initial_rustc ) . args ( [ "--print" , "target-list" ] ) ) ;
202
+ let missing_targets_hashset: HashSet < _ > = STAGE0_MISSING_TARGETS . iter ( ) . map ( |t| t. to_string ( ) ) . collect ( ) ;
203
+ let duplicated_targets: Vec < _ > = stage0_supported_target_list. intersection ( & missing_targets_hashset) . collect ( ) ;
204
+
205
+ if !duplicated_targets. is_empty ( ) {
206
+ println ! ( "Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list." ) ;
207
+ for duplicated_target in duplicated_targets {
208
+ println ! ( " {duplicated_target}" ) ;
209
+ }
210
+ std:: process:: exit ( 1 ) ;
211
+ }
200
212
201
213
// Check if it's a built-in target.
202
- has_target |= supported_target_list . contains ( & target_str) ;
214
+ has_target |= stage0_supported_target_list . contains ( & target_str) ;
203
215
has_target |= STAGE0_MISSING_TARGETS . contains ( & target_str. as_str ( ) ) ;
204
216
205
217
if !has_target {
0 commit comments