From 4cfaaf563327d444cfc45f799cdd3d5fd4476707 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 22 Oct 2018 16:39:36 +0200 Subject: [PATCH 1/3] bootstrap: Allow for build libstd to have its own codegen-unit setting. --- config.toml.example | 4 ++++ src/bootstrap/builder.rs | 13 +++++++++---- src/bootstrap/config.rs | 4 ++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config.toml.example b/config.toml.example index e8cb0cba6b1f9..093b8f9e526ec 100644 --- a/config.toml.example +++ b/config.toml.example @@ -277,6 +277,10 @@ # compiler. #codegen-units = 1 +# Sets the number of codegen units to build the standard library with, +# regardless of what the codegen-unit setting for the rest of the compiler is. +#codegen-units-std = 1 + # Whether or not debug assertions are enabled for the compiler and standard # library. Also enables compilation of debug! and trace! logging macros. #debug-assertions = false diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 71a89cd6d76b4..5abc0455b5871 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1119,10 +1119,15 @@ impl<'a> Builder<'a> { 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()); + match (mode, self.config.rust_codegen_units_std, self.config.rust_codegen_units) { + (Mode::Std, Some(n), _) | + (Mode::Test, Some(n), _) | + (_, _, Some(n)) => { + cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); + } + _ => { + // Don't set anything + } } if self.config.rust_optimize { diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index a9d330e06a15d..3eb6e8d84e877 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -95,6 +95,7 @@ pub struct Config { // rust codegen options pub rust_optimize: bool, pub rust_codegen_units: Option, + pub rust_codegen_units_std: Option, pub rust_debug_assertions: bool, pub rust_debuginfo: bool, pub rust_debuginfo_lines: bool, @@ -294,6 +295,7 @@ impl Default for StringOrBool { struct Rust { optimize: Option, codegen_units: Option, + codegen_units_std: Option, debug_assertions: Option, debuginfo: Option, debuginfo_lines: Option, @@ -580,6 +582,8 @@ impl Config { Some(n) => config.rust_codegen_units = Some(n), None => {} } + + config.rust_codegen_units_std = rust.codegen_units_std; } if let Some(ref t) = toml.target { From 4545b3e42269877bdbc51ac98b6cee60a19285a9 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 23 Oct 2018 14:14:44 +0200 Subject: [PATCH 2/3] CI: Set codegen-units-std=1 for dist builds. --- src/ci/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ci/run.sh b/src/ci/run.sh index a2c271f0fc895..d19fbda8c20c9 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -56,6 +56,7 @@ if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo" + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1" if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" From 03551e139d867f3b4f13f2ac617a8eefc18bca4e Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 23 Oct 2018 15:35:49 +0200 Subject: [PATCH 3/3] Make configure.py handle numeric arguments for `--set` a little better. --- src/bootstrap/configure.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 0cf84a62986a5..ddb894eb1f659 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -393,6 +393,13 @@ def set(key, value): targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target) +def is_number(value): + try: + float(value) + return True + except: + return False + # Here we walk through the constructed configuration we have from the parsed # command line arguments. We then apply each piece of configuration by # basically just doing a `sed` to change the various configuration line to what @@ -406,7 +413,11 @@ def to_toml(value): elif isinstance(value, list): return '[' + ', '.join(map(to_toml, value)) + ']' elif isinstance(value, str): - return "'" + value + "'" + # Don't put quotes around numeric values + if is_number(value): + return value + else: + return "'" + value + "'" else: raise RuntimeError('no toml')