Skip to content

Commit 00b7129

Browse files
committed
Auto merge of #55264 - michaelwoerister:single-cgu-std, r=<try>
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. r? @Mark-Simulacrum cc @rust-lang/release
2 parents 7cfe5de + 4545b3e commit 00b7129

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@
277277
# compiler.
278278
#codegen-units = 1
279279

280+
# Sets the number of codegen units to build the standard library with,
281+
# regardless of what the codegen-unit setting for the rest of the compiler is.
282+
#codegen-units-std = 1
283+
280284
# Whether or not debug assertions are enabled for the compiler and standard
281285
# library. Also enables compilation of debug! and trace! logging macros.
282286
#debug-assertions = false

src/bootstrap/builder.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1119,10 +1119,15 @@ impl<'a> Builder<'a> {
11191119
cargo.arg("-v");
11201120
}
11211121

1122-
// This must be kept before the thinlto check, as we set codegen units
1123-
// to 1 forcibly there.
1124-
if let Some(n) = self.config.rust_codegen_units {
1125-
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
1122+
match (mode, self.config.rust_codegen_units_std, self.config.rust_codegen_units) {
1123+
(Mode::Std, Some(n), _) |
1124+
(Mode::Test, Some(n), _) |
1125+
(_, _, Some(n)) => {
1126+
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
1127+
}
1128+
_ => {
1129+
// Don't set anything
1130+
}
11261131
}
11271132

11281133
if self.config.rust_optimize {

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub struct Config {
9595
// rust codegen options
9696
pub rust_optimize: bool,
9797
pub rust_codegen_units: Option<u32>,
98+
pub rust_codegen_units_std: Option<u32>,
9899
pub rust_debug_assertions: bool,
99100
pub rust_debuginfo: bool,
100101
pub rust_debuginfo_lines: bool,
@@ -294,6 +295,7 @@ impl Default for StringOrBool {
294295
struct Rust {
295296
optimize: Option<bool>,
296297
codegen_units: Option<u32>,
298+
codegen_units_std: Option<u32>,
297299
debug_assertions: Option<bool>,
298300
debuginfo: Option<bool>,
299301
debuginfo_lines: Option<bool>,
@@ -580,6 +582,8 @@ impl Config {
580582
Some(n) => config.rust_codegen_units = Some(n),
581583
None => {}
582584
}
585+
586+
config.rust_codegen_units_std = rust.codegen_units_std;
583587
}
584588

585589
if let Some(ref t) = toml.target {

src/ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
5656
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
5757
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
5858
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
59+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
5960

6061
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
6162
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"

0 commit comments

Comments
 (0)