File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,30 @@ than building it.
177177 continue ;
178178 }
179179
180+ // Check if there exists a built-in target in the list of supported targets.
181+ let mut has_target = false ;
182+ let target_str = target. to_string ( ) ;
183+
184+ let supported_target_list = Command :: new ( & build. config . initial_rustc )
185+ . args ( [ "--print" , "target-list" ] )
186+ . output ( )
187+ . expect ( "Should have been able to fetch the target list." ) ;
188+
189+ if let Some ( stdout) = String :: from_utf8 ( supported_target_list. stdout ) . ok ( ) {
190+ has_target |= stdout. contains ( & target_str) ;
191+ }
192+
193+ // If not, check for a valid file location that may have been specified
194+ // by the user for the custom target.
195+ has_target |= env:: var_os ( "RUST_TARGET_PATH" ) . is_some ( ) ;
196+
197+ if !has_target && !( target_str == "A" || target_str == "B" || target_str == "C" ) {
198+ panic ! (
199+ "No such target exists in the target list,
200+ specify a correct location of the JSON specification file for custom targets!"
201+ ) ;
202+ }
203+
180204 if !build. config . dry_run ( ) {
181205 cmd_finder. must_have ( build. cc ( * target) ) ;
182206 if let Some ( ar) = build. ar ( * target) {
You can’t perform that action at this time.
0 commit comments