about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorMark Simulacrum <mark.simulacrum@gmail.com>2018-01-28 15:50:03 -0700
committerMark Simulacrum <mark.simulacrum@gmail.com>2018-02-03 18:38:17 -0700
commite1f04c04dffc1615fde9dd1e51d27bcc5275cdb2 (patch)
treeed7e0e4c8805d3ed42a8868270ce583fe739df71 /src/bootstrap
parent616b66dca25a67321b1654e5a65acc6337d63cf4 (diff)
Disable ThinLTO for dist builds.
Dist builds should always be as fast as we can make them, and since
those run on CI we don't care quite as much for the build being somewhat
slower. As such, we don't automatically enable ThinLTO on builds for the
dist builders.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/builder.rs21
-rw-r--r--src/bootstrap/config.rs5
-rwxr-xr-xsrc/bootstrap/configure.py1
3 files changed, 21 insertions, 6 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 780513dd943..bf7b1015a49 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -509,10 +509,6 @@ impl<'a> Builder<'a> {
              })
              .env("TEST_MIRI", self.config.test_miri.to_string())
              .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
-        if let Some(n) = self.config.rust_codegen_units {
-            cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
-        }
-
 
         if let Some(host_linker) = self.build.linker(compiler.host) {
             cargo.env("RUSTC_HOST_LINKER", host_linker);
@@ -679,6 +675,13 @@ impl<'a> Builder<'a> {
         if self.is_very_verbose() {
             cargo.arg("-v");
         }
+
+        // This must be kept before the thinlto check, as we set codegen units
+        // to 1 forcibly there.
+        if let Some(n) = self.config.rust_codegen_units {
+            cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
+        }
+
         if self.config.rust_optimize {
             // FIXME: cargo bench does not accept `--release`
             if cmd != "bench" {
@@ -686,11 +689,17 @@ impl<'a> Builder<'a> {
             }
 
             if self.config.rust_codegen_units.is_none() &&
-               self.build.is_rust_llvm(compiler.host)
-            {
+               self.build.is_rust_llvm(compiler.host) &&
+               self.config.rust_thinlto {
                 cargo.env("RUSTC_THINLTO", "1");
+            } else if self.config.rust_codegen_units.is_none() {
+                // Generally, if ThinLTO has been disabled for some reason, we
+                // want to set the codegen units to 1. However, we shouldn't do
+                // this if the option was specifically set by the user.
+                cargo.env("RUSTC_CODEGEN_UNITS", "1");
             }
         }
+
         if self.config.locked_deps {
             cargo.arg("--locked");
         }
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 0da04bebac5..be8910120ee 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -81,6 +81,7 @@ pub struct Config {
     // rust codegen options
     pub rust_optimize: bool,
     pub rust_codegen_units: Option<u32>,
+    pub rust_thinlto: bool,
     pub rust_debug_assertions: bool,
     pub rust_debuginfo: bool,
     pub rust_debuginfo_lines: bool,
@@ -261,6 +262,7 @@ impl Default for StringOrBool {
 struct Rust {
     optimize: Option<bool>,
     codegen_units: Option<u32>,
+    thinlto: Option<bool>,
     debug_assertions: Option<bool>,
     debuginfo: Option<bool>,
     debuginfo_lines: Option<bool>,
@@ -412,6 +414,7 @@ impl Config {
 
         // Store off these values as options because if they're not provided
         // we'll infer default values for them later
+        let mut thinlto = None;
         let mut llvm_assertions = None;
         let mut debuginfo_lines = None;
         let mut debuginfo_only_std = None;
@@ -455,6 +458,7 @@ impl Config {
             optimize = rust.optimize;
             ignore_git = rust.ignore_git;
             debug_jemalloc = rust.debug_jemalloc;
+            thinlto = rust.thinlto;
             set(&mut config.rust_optimize_tests, rust.optimize_tests);
             set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
             set(&mut config.codegen_tests, rust.codegen_tests);
@@ -539,6 +543,7 @@ impl Config {
             "stable" | "beta" | "nightly" => true,
             _ => false,
         };
+        config.rust_thinlto = thinlto.unwrap_or(true);
         config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default);
         config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default);
 
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index bc6f666d001..d51752a12d9 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -70,6 +70,7 @@ o("emscripten", None, "compile the emscripten backend as well as LLVM")
 # Optimization and debugging options. These may be overridden by the release
 # channel, etc.
 o("optimize", "rust.optimize", "build optimized rust code")
+o("thinlto", "rust.thinlto", "build Rust with ThinLTO enabled")
 o("optimize-llvm", "llvm.optimize", "build optimized LLVM")
 o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
 o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")