@@ -393,6 +393,27 @@ pub fn check_incompatible_options_for_ci_rustc(
393393    Ok ( ( ) ) 
394394} 
395395
396+ pub ( crate )  const  VALID_CODEGEN_BACKENDS :  & [ & str ]  = & [ "llvm" ,  "cranelift" ,  "gcc" ] ; 
397+ 
398+ pub ( crate )  fn  validate_codegen_backends ( backends :  Vec < String > ,  section :  & str )  -> Vec < String >  { 
399+     for  backend in  & backends { 
400+         if  let  Some ( stripped)  = backend. strip_prefix ( CODEGEN_BACKEND_PREFIX )  { 
401+             panic ! ( 
402+                 "Invalid value '{backend}' for '{section}.codegen-backends'. \  
403+ \ 
404+ 
405+             ) 
406+         } 
407+         if  !VALID_CODEGEN_BACKENDS . contains ( & backend. as_str ( ) )  { 
408+             println ! ( 
409+                 "HELP: '{backend}' for '{section}.codegen-backends' might fail. \  
410+ 
411+             ) ; 
412+         } 
413+     } 
414+     backends
415+ } 
416+ 
396417impl  Config  { 
397418    pub  fn  apply_rust_config ( 
398419        & mut  self , 
@@ -571,24 +592,10 @@ impl Config {
571592            set ( & mut  self . ehcont_guard ,  ehcont_guard) ; 
572593            self . llvm_libunwind_default  =
573594                llvm_libunwind. map ( |v| v. parse ( ) . expect ( "failed to parse rust.llvm-libunwind" ) ) ; 
574- 
575-             if  let  Some ( ref  backends)  = codegen_backends { 
576-                 let  available_backends = [ "llvm" ,  "cranelift" ,  "gcc" ] ; 
577- 
578-                 self . rust_codegen_backends  = backends. iter ( ) . map ( |s| { 
579-                     if  let  Some ( backend)  = s. strip_prefix ( CODEGEN_BACKEND_PREFIX )  { 
580-                         if  available_backends. contains ( & backend)  { 
581-                             panic ! ( "Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'." ) ; 
582-                         }  else  { 
583-                             println ! ( "HELP: '{s}' for 'rust.codegen-backends' might fail. \  
584- \ 
585- ) ; 
586-                         } 
587-                     } 
588- 
589-                     s. clone ( ) 
590-                 } ) . collect ( ) ; 
591-             } 
595+             set ( 
596+                 & mut  self . rust_codegen_backends , 
597+                 codegen_backends. map ( |backends| validate_codegen_backends ( backends,  "rust" ) ) , 
598+             ) ; 
592599
593600            self . rust_codegen_units  = codegen_units. map ( threads_from_config) ; 
594601            self . rust_codegen_units_std  = codegen_units_std. map ( threads_from_config) ; 
0 commit comments