@@ -11,7 +11,6 @@ use std::process;
1111use  std:: cmp; 
1212
1313use  build_helper:: t; 
14- use  num_cpus; 
1514use  toml; 
1615use  serde:: Deserialize ; 
1716use  crate :: cache:: { INTERNER ,  Interned } ; 
@@ -401,7 +400,7 @@ impl Config {
401400        config. rustc_error_format  = flags. rustc_error_format ; 
402401        config. on_fail  = flags. on_fail ; 
403402        config. stage  = flags. stage ; 
404-         config. jobs  = flags. jobs ; 
403+         config. jobs  = flags. jobs . map ( threads_from_config ) ; 
405404        config. cmd  = flags. cmd ; 
406405        config. incremental  = flags. incremental ; 
407406        config. dry_run  = flags. dry_run ; 
@@ -583,13 +582,8 @@ impl Config {
583582
584583            set ( & mut  config. rust_codegen_backends_dir ,  rust. codegen_backends_dir . clone ( ) ) ; 
585584
586-             match  rust. codegen_units  { 
587-                 Some ( 0 )  => config. rust_codegen_units  = Some ( num_cpus:: get ( )  as  u32 ) , 
588-                 Some ( n)  => config. rust_codegen_units  = Some ( n) , 
589-                 None  => { } 
590-             } 
591- 
592-             config. rust_codegen_units_std  = rust. codegen_units_std ; 
585+             config. rust_codegen_units  = rust. codegen_units . map ( threads_from_config) ; 
586+             config. rust_codegen_units_std  = rust. codegen_units_std . map ( threads_from_config) ; 
593587        } 
594588
595589        if  let  Some ( ref  t)  = toml. target  { 
@@ -688,3 +682,10 @@ fn set<T>(field: &mut T, val: Option<T>) {
688682        * field = v; 
689683    } 
690684} 
685+ 
686+ fn  threads_from_config ( v :  u32 )  -> u32  { 
687+     match  v { 
688+         0  => num_cpus:: get ( )  as  u32 , 
689+         n => n, 
690+     } 
691+ } 
0 commit comments