File tree 5 files changed +24
-3
lines changed
5 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 223
223
224
224
# Number of codegen units to use for each compiler invocation. A value of 0
225
225
# 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
227
228
#codegen-units = 1
229
+ #rustc-codegen-units = 1
228
230
229
231
# Whether or not debug assertions are enabled for the compiler and standard
230
232
# 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> {
458
458
stage = compiler. stage ;
459
459
}
460
460
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
+
461
467
// Customize the compiler we're running. Specify the compiler to cargo
462
468
// as our shim and then pass it some various options used to configure
463
469
// how the actual compiler itself is called.
@@ -468,8 +474,7 @@ impl<'a> Builder<'a> {
468
474
. env ( "RUSTC" , self . out . join ( "bootstrap/debug/rustc" ) )
469
475
. env ( "RUSTC_REAL" , self . rustc ( compiler) )
470
476
. 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 ( ) )
473
478
. env ( "RUSTC_DEBUG_ASSERTIONS" ,
474
479
self . config . rust_debug_assertions . to_string ( ) )
475
480
. env ( "RUSTC_SYSROOT" , self . sysroot ( compiler) )
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ pub struct Config {
82
82
// rust codegen options
83
83
pub rust_optimize : bool ,
84
84
pub rust_codegen_units : u32 ,
85
+ pub rustc_codegen_units : Option < u32 > ,
85
86
pub rust_debug_assertions : bool ,
86
87
pub rust_debuginfo : bool ,
87
88
pub rust_debuginfo_lines : bool ,
@@ -254,6 +255,7 @@ impl Default for StringOrBool {
254
255
struct Rust {
255
256
optimize : Option < bool > ,
256
257
codegen_units : Option < u32 > ,
258
+ rustc_codegen_units : Option < u32 > ,
257
259
debug_assertions : Option < bool > ,
258
260
debuginfo : Option < bool > ,
259
261
debuginfo_lines : Option < bool > ,
@@ -472,6 +474,10 @@ impl Config {
472
474
Some ( n) => config. rust_codegen_units = n,
473
475
None => { }
474
476
}
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
+ }
475
481
}
476
482
477
483
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):
256
256
value = True
257
257
elif keyval [1 ] == "false" :
258
258
value = False
259
+ elif keyval [1 ].isdigit ():
260
+ value = int (keyval [1 ])
259
261
else :
260
262
value = keyval [1 ]
261
263
set (keyval [0 ], value )
@@ -357,6 +359,8 @@ def to_toml(value):
357
359
return '[' + ', ' .join (map (to_toml , value )) + ']'
358
360
elif isinstance (value , str ):
359
361
return "'" + value + "'"
362
+ elif isinstance (value , int ):
363
+ return str (value )
360
364
else :
361
365
raise 'no toml'
362
366
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
52
52
RUST_CONFIGURE_ARGS=" $RUST_CONFIGURE_ARGS --disable-llvm-assertions"
53
53
fi
54
54
else
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
+
55
59
# We almost always want debug assertions enabled, but sometimes this takes too
56
60
# long for too little benefit, so we just turn them off.
57
61
if [ " $NO_DEBUG_ASSERTIONS " = " " ]; then
You can’t perform that action at this time.
0 commit comments