88//! In theory if we get past this phase it's a bug if a build fails, but in
99//! practice that's likely not true!
1010
11- use std:: collections:: HashMap ;
11+ use std:: collections:: { HashMap , HashSet } ;
1212use std:: env;
1313use std:: ffi:: { OsStr , OsString } ;
1414use std:: fs;
@@ -33,8 +33,6 @@ pub struct Finder {
3333// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3434const STAGE0_MISSING_TARGETS : & [ & str ] = & [
3535 // just a dummy comment so the list doesn't get onelined
36- "aarch64-apple-visionos" ,
37- "aarch64-apple-visionos-sim" ,
3836] ;
3937
4038impl Finder {
@@ -195,8 +193,22 @@ than building it.
195193 if ![ "A" , "B" , "C" ] . contains ( & target_str. as_str ( ) ) {
196194 let mut has_target = false ;
197195
198- let supported_target_list =
199- output ( Command :: new ( & build. config . initial_rustc ) . args ( [ "--print" , "target-list" ] ) ) ;
196+ let supported_target_list: HashSet < String > =
197+ output ( Command :: new ( & build. config . initial_rustc ) . args ( [ "--print" , "target-list" ] ) )
198+ . lines ( )
199+ . map ( |s| s. to_string ( ) )
200+ . collect ( ) ;
201+
202+ let missing_targets_hashset: HashSet < _ > = STAGE0_MISSING_TARGETS . iter ( ) . map ( |t| t. to_string ( ) ) . collect ( ) ;
203+ let duplicated_targets: Vec < _ > = 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+ }
200212
201213 // Check if it's a built-in target.
202214 has_target |= supported_target_list. contains ( & target_str) ;
0 commit comments