about summary refs log tree commit diff
path: root/src/librustc_session
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2020-03-19 17:14:02 +0100
committerMichael Woerister <michaelwoerister@posteo>2020-03-31 16:11:16 +0200
commit1e5b4594e1aad47fccd855fa54dd40a84d07dbdf (patch)
treee1bfa779e0645444d337d020493b54cafb9e6e64 /src/librustc_session
parent2113659479a82ea69633b23ef710b58ab127755e (diff)
Make the rustc respect the `-C codegen-units` flag in incremental mode.
Before this commit `-C codegen-units` would just get silently be
ignored if `-C incremental` was specified too. After this commit
one can control the number of codegen units generated during
incremental compilation. The default is rather high at 256, so most
crates won't see a difference unless explicitly opting into a lower
count.
Diffstat (limited to 'src/librustc_session')
-rw-r--r--src/librustc_session/session.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs
index b3d75143c56..7f8b55d9d76 100644
--- a/src/librustc_session/session.rs
+++ b/src/librustc_session/session.rs
@@ -758,6 +758,13 @@ impl Session {
             return n as usize;
         }
 
+        // If incremental compilation is turned on, we default to a high number
+        // codegen units in order to reduce the "collateral damage" small
+        // changes cause.
+        if self.opts.incremental.is_some() {
+            return 256;
+        }
+
         // Why is 16 codegen units the default all the time?
         //
         // The main reason for enabling multiple codegen units by default is to