Skip to content

Commit 2d6f3fe

Browse files
committed
Move handling of codegen-units to builder.rs
1 parent 22699d3 commit 2d6f3fe

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ fn main() {
165165
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
166166
}
167167

168-
if let Ok(s) = env::var("RUSTC_CODEGEN_UNITS") {
169-
cmd.arg("-C").arg(format!("codegen-units={}", s));
170-
}
171-
172168
if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {
173169
cmd.arg("--remap-path-prefix").arg(&map);
174170
}

src/bootstrap/builder.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,17 @@ impl<'a> Builder<'a> {
774774

775775
cargo
776776
.env("CARGO_TARGET_DIR", out_dir)
777-
.arg(cmd);
777+
.arg(cmd)
778+
.arg("-Zconfig-profile");
779+
780+
let profile_var = |name: &str| {
781+
let profile = if self.config.rust_optimize {
782+
"RELEASE"
783+
} else {
784+
"DEV"
785+
};
786+
format!("CARGO_PROFILE_{}_{}", profile, name)
787+
};
778788

779789
// See comment in librustc_llvm/build.rs for why this is necessary, largely llvm-config
780790
// needs to not accidentally link to libLLVM in stage0/lib.
@@ -1190,7 +1200,7 @@ impl<'a> Builder<'a> {
11901200
match (mode, self.config.rust_codegen_units_std, self.config.rust_codegen_units) {
11911201
(Mode::Std, Some(n), _) |
11921202
(_, _, Some(n)) => {
1193-
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
1203+
cargo.env(profile_var("CODEGEN_UNITS"), n.to_string());
11941204
}
11951205
_ => {
11961206
// Don't set anything

0 commit comments

Comments
 (0)