about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-22 04:42:11 +0000
committerbors <bors@rust-lang.org>2014-10-22 04:42:11 +0000
commitc29a7520e7fb4a5b4d4eccfc594e05793ef6688d (patch)
tree494c36371a1efda91ac5dab213d3cd522636a900 /src
parent3d2cf60631502567007ea652f8ef299d907ee2c3 (diff)
parentc245c5bbad10923b47c9f66d5f0da2913ef11a38 (diff)
downloadrust-c29a7520e7fb4a5b4d4eccfc594e05793ef6688d.tar.gz
rust-c29a7520e7fb4a5b4d4eccfc594e05793ef6688d.zip
auto merge of #18213 : pcwalton/rust/pcg-default, r=aturon
Enable parallel codegen (2 units) by default when --opt-level is 0 or 1.  This
gives a minor speedup on large crates (~10%), with only a tiny slowdown (~2%)
for small ones (which usually build in under a second regardless).  The current
default (no parallelization) is used when the user requests optimization
(--opt-level 2 or 3), and when the user has enabled LTO (which is incompatible
with parallel codegen).

This commit also changes the rust build system to use parallel codegen
when appropriate.  This means codegen-units=4 for stage0 always, and
also for stage1 and stage2 when configured with --disable-optimize.
(Other settings use codegen-units=1 for stage1 and stage2, to get
maximum performance for release binaries.)  The build system also sets
codegen-units=1 for compiletest tests (compiletest does its own
parallelization) and uses the same setting as stage2 for crate tests.

r? @aturon
Diffstat (limited to 'src')
-rw-r--r--src/librustc/driver/config.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs
index 1f44808275f..d6798d59ecb 100644
--- a/src/librustc/driver/config.rs
+++ b/src/librustc/driver/config.rs
@@ -780,7 +780,20 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         early_warn("the --crate-file-name argument has been renamed to \
                     --print-file-name");
     }
-    let cg = build_codegen_options(matches);
+
+    let mut cg = build_codegen_options(matches);
+
+    if cg.codegen_units == 0 {
+        match opt_level {
+            // `-C lto` doesn't work with multiple codegen units.
+            _ if cg.lto => cg.codegen_units = 1,
+
+            No | Less => cg.codegen_units = 2,
+            Default | Aggressive => cg.codegen_units = 1,
+        }
+    }
+    let cg = cg;
+
 
     if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
         early_warn("-C remark will not show source locations without --debuginfo");