Skip to content

Commit ea15935

Browse files
committed
handle release builds appropriately
Signed-off-by: onur-ozkan <[email protected]>
1 parent e0c54d8 commit ea15935

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,11 @@ impl Step for Analysis {
790790
return None;
791791
}
792792

793+
let mode = Mode::Std;
793794
let src = builder
794-
.stage_out(compiler, Mode::Std)
795+
.stage_out(compiler, mode)
795796
.join(target)
796-
.join(builder.cargo_dir())
797+
.join(builder.cargo_dir(&mode))
797798
.join("deps")
798799
.join("save-analysis");
799800

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,11 @@ impl Step for Clippy {
742742
let compiler = builder.compiler(stage, host);
743743

744744
builder.ensure(tool::Clippy { compiler, target: self.host });
745+
let mode = Mode::ToolRustc;
745746
let mut cargo = tool::prepare_tool_cargo(
746747
builder,
747748
compiler,
748-
Mode::ToolRustc,
749+
mode,
749750
host,
750751
Kind::Test,
751752
"src/tools/clippy",
@@ -755,7 +756,7 @@ impl Step for Clippy {
755756

756757
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
757758
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
758-
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
759+
let host_libs = builder.stage_out(compiler, mode).join(builder.cargo_dir(&mode));
759760
cargo.env("HOST_LIBS", host_libs);
760761

761762
cargo.add_rustc_lib_path(builder);

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ impl Builder<'_> {
422422
assert_eq!(target, compiler.host);
423423
}
424424

425-
if self.config.rust_optimize.is_release() &&
426-
// cargo bench/install do not accept `--release` and miri doesn't want it
427-
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest)
425+
if self.is_release_build(&mode) &&
426+
// cargo bench/install do not accept `--release` and miri doesn't want it
427+
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest)
428428
{
429429
cargo.arg("--release");
430430
}

src/bootstrap/src/lib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,19 @@ impl Build {
660660
features.join(" ")
661661
}
662662

663+
fn is_release_build(&self, mode: &Mode) -> bool {
664+
match mode {
665+
Mode::Std | Mode::Rustc => self.config.rust_optimize.is_release(),
666+
Mode::Codegen | Mode::ToolBootstrap | Mode::ToolStd | Mode::ToolRustc => {
667+
self.config.enable_release_build
668+
}
669+
}
670+
}
671+
663672
/// Component directory that Cargo will produce output into (e.g.
664673
/// release/debug)
665-
fn cargo_dir(&self) -> &'static str {
666-
if self.config.rust_optimize.is_release() { "release" } else { "debug" }
674+
fn cargo_dir(&self, mode: &Mode) -> &'static str {
675+
if self.is_release_build(mode) { "release" } else { "debug" }
667676
}
668677

669678
fn tools_dir(&self, compiler: Compiler) -> PathBuf {
@@ -691,7 +700,7 @@ impl Build {
691700
/// running a particular compiler, whether or not we're building the
692701
/// standard library, and targeting the specified architecture.
693702
fn cargo_out(&self, compiler: Compiler, mode: Mode, target: TargetSelection) -> PathBuf {
694-
self.stage_out(compiler, mode).join(target).join(self.cargo_dir())
703+
self.stage_out(compiler, mode).join(target).join(self.cargo_dir(&mode))
695704
}
696705

697706
/// Root output directory of LLVM for `target`

0 commit comments

Comments
 (0)