Rollup merge of #55264 - michaelwoerister:single-cgu-std, r=simulacrum
Compile the libstd we distribute with -Ccodegen-unit=1 This PR - adds the `single-codegen-unit-std` option to `config.toml` which allows for setting the CGU count for `libstd` and `libtest` independently of the one for the rest of the compiler, and - sets the new option to `true` for all dist jobs in CI. Fixes #54872.
This commit is contained in:
commit
5572f2df7f
@ -277,6 +277,10 @@
|
|||||||
# compiler.
|
# compiler.
|
||||||
#codegen-units = 1
|
#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
|
# Whether or not debug assertions are enabled for the compiler and standard
|
||||||
# library. Also enables compilation of debug! and trace! logging macros.
|
# library. Also enables compilation of debug! and trace! logging macros.
|
||||||
#debug-assertions = false
|
#debug-assertions = false
|
||||||
|
@ -1119,10 +1119,15 @@ impl<'a> Builder<'a> {
|
|||||||
cargo.arg("-v");
|
cargo.arg("-v");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This must be kept before the thinlto check, as we set codegen units
|
match (mode, self.config.rust_codegen_units_std, self.config.rust_codegen_units) {
|
||||||
// to 1 forcibly there.
|
(Mode::Std, Some(n), _) |
|
||||||
if let Some(n) = self.config.rust_codegen_units {
|
(Mode::Test, Some(n), _) |
|
||||||
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
|
(_, _, Some(n)) => {
|
||||||
|
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
// Don't set anything
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.config.rust_optimize {
|
if self.config.rust_optimize {
|
||||||
|
@ -95,6 +95,7 @@ pub struct Config {
|
|||||||
// rust codegen options
|
// rust codegen options
|
||||||
pub rust_optimize: bool,
|
pub rust_optimize: bool,
|
||||||
pub rust_codegen_units: Option<u32>,
|
pub rust_codegen_units: Option<u32>,
|
||||||
|
pub rust_codegen_units_std: Option<u32>,
|
||||||
pub rust_debug_assertions: bool,
|
pub rust_debug_assertions: bool,
|
||||||
pub rust_debuginfo: bool,
|
pub rust_debuginfo: bool,
|
||||||
pub rust_debuginfo_lines: bool,
|
pub rust_debuginfo_lines: bool,
|
||||||
@ -294,6 +295,7 @@ impl Default for StringOrBool {
|
|||||||
struct Rust {
|
struct Rust {
|
||||||
optimize: Option<bool>,
|
optimize: Option<bool>,
|
||||||
codegen_units: Option<u32>,
|
codegen_units: Option<u32>,
|
||||||
|
codegen_units_std: Option<u32>,
|
||||||
debug_assertions: Option<bool>,
|
debug_assertions: Option<bool>,
|
||||||
debuginfo: Option<bool>,
|
debuginfo: Option<bool>,
|
||||||
debuginfo_lines: Option<bool>,
|
debuginfo_lines: Option<bool>,
|
||||||
@ -580,6 +582,8 @@ impl Config {
|
|||||||
Some(n) => config.rust_codegen_units = Some(n),
|
Some(n) => config.rust_codegen_units = Some(n),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.rust_codegen_units_std = rust.codegen_units_std;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref t) = toml.target {
|
if let Some(ref t) = toml.target {
|
||||||
|
@ -393,6 +393,13 @@ for target in configured_targets:
|
|||||||
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target)
|
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
|
# Here we walk through the constructed configuration we have from the parsed
|
||||||
# command line arguments. We then apply each piece of configuration by
|
# command line arguments. We then apply each piece of configuration by
|
||||||
# basically just doing a `sed` to change the various configuration line to what
|
# 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):
|
elif isinstance(value, list):
|
||||||
return '[' + ', '.join(map(to_toml, value)) + ']'
|
return '[' + ', '.join(map(to_toml, value)) + ']'
|
||||||
elif isinstance(value, str):
|
elif isinstance(value, str):
|
||||||
return "'" + value + "'"
|
# Don't put quotes around numeric values
|
||||||
|
if is_number(value):
|
||||||
|
return value
|
||||||
|
else:
|
||||||
|
return "'" + value + "'"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('no toml')
|
raise RuntimeError('no toml')
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache"
|
|||||||
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
|
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
|
||||||
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
|
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
|
||||||
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static"
|
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static"
|
||||||
|
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
|
||||||
|
|
||||||
if [ "$DIST_SRC" = "" ]; then
|
if [ "$DIST_SRC" = "" ]; then
|
||||||
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
|
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user