File tree Expand file tree Collapse file tree 5 files changed +24
-3
lines changed Expand file tree Collapse file tree 5 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 223223
224224# Number of codegen units to use for each compiler invocation. A value of 0
225225# means "the number of cores on this machine", and 1+ is passed through to the
226- # compiler.
226+ # compiler. The `codegen-units` setting applies to std/rustc/tools whereas
227+ # `rustc-codegen-units` does not apply to std
227228# codegen-units = 1
229+ # rustc-codegen-units = 1
228230
229231# Whether or not debug assertions are enabled for the compiler and standard
230232# library. Also enables compilation of debug! and trace! logging macros.
Original file line number Diff line number Diff line change @@ -458,6 +458,12 @@ impl<'a> Builder<'a> {
458458 stage = compiler. stage ;
459459 }
460460
461+ let cgus = if mode == Mode :: Libstd {
462+ self . config . rust_codegen_units
463+ } else {
464+ self . config . rustc_codegen_units . unwrap_or ( self . config . rust_codegen_units )
465+ } ;
466+
461467 // Customize the compiler we're running. Specify the compiler to cargo
462468 // as our shim and then pass it some various options used to configure
463469 // how the actual compiler itself is called.
@@ -468,8 +474,7 @@ impl<'a> Builder<'a> {
468474 . env ( "RUSTC" , self . out . join ( "bootstrap/debug/rustc" ) )
469475 . env ( "RUSTC_REAL" , self . rustc ( compiler) )
470476 . env ( "RUSTC_STAGE" , stage. to_string ( ) )
471- . env ( "RUSTC_CODEGEN_UNITS" ,
472- self . config . rust_codegen_units . to_string ( ) )
477+ . env ( "RUSTC_CODEGEN_UNITS" , cgus. to_string ( ) )
473478 . env ( "RUSTC_DEBUG_ASSERTIONS" ,
474479 self . config . rust_debug_assertions . to_string ( ) )
475480 . env ( "RUSTC_SYSROOT" , self . sysroot ( compiler) )
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ pub struct Config {
8282 // rust codegen options
8383 pub rust_optimize : bool ,
8484 pub rust_codegen_units : u32 ,
85+ pub rustc_codegen_units : Option < u32 > ,
8586 pub rust_debug_assertions : bool ,
8687 pub rust_debuginfo : bool ,
8788 pub rust_debuginfo_lines : bool ,
@@ -254,6 +255,7 @@ impl Default for StringOrBool {
254255struct Rust {
255256 optimize : Option < bool > ,
256257 codegen_units : Option < u32 > ,
258+ rustc_codegen_units : Option < u32 > ,
257259 debug_assertions : Option < bool > ,
258260 debuginfo : Option < bool > ,
259261 debuginfo_lines : Option < bool > ,
@@ -472,6 +474,10 @@ impl Config {
472474 Some ( n) => config. rust_codegen_units = n,
473475 None => { }
474476 }
477+ match rust. rustc_codegen_units {
478+ Some ( 0 ) => config. rustc_codegen_units = Some ( num_cpus:: get ( ) as u32 ) ,
479+ other => config. rustc_codegen_units = other,
480+ }
475481 }
476482
477483 if let Some ( ref t) = toml. target {
Original file line number Diff line number Diff line change @@ -256,6 +256,8 @@ def set(key, value):
256256 value = True
257257 elif keyval [1 ] == "false" :
258258 value = False
259+ elif keyval [1 ].isdigit ():
260+ value = int (keyval [1 ])
259261 else :
260262 value = keyval [1 ]
261263 set (keyval [0 ], value )
@@ -357,6 +359,8 @@ def to_toml(value):
357359 return '[' + ', ' .join (map (to_toml , value )) + ']'
358360 elif isinstance (value , str ):
359361 return "'" + value + "'"
362+ elif isinstance (value , int ):
363+ return str (value )
360364 else :
361365 raise 'no toml'
362366
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
5252 RUST_CONFIGURE_ARGS=" $RUST_CONFIGURE_ARGS --disable-llvm-assertions"
5353 fi
5454else
55+ # Let's try to take advantage of some of those sweet sweet parallelism wins by
56+ # using multiple codegen units during the bootstrap
57+ RUST_CONFIGURE_ARGS=" $RUST_CONFIGURE_ARGS --set rust.rustc-codegen-units=8"
58+
5559 # We almost always want debug assertions enabled, but sometimes this takes too
5660 # long for too little benefit, so we just turn them off.
5761 if [ " $NO_DEBUG_ASSERTIONS " = " " ]; then
You can’t perform that action at this time.
0 commit comments