Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl Step for CrateBootstrap {
SourceType::InTree,
&[],
);

let crate_name = path.rsplit_once('/').unwrap().1;
run_cargo_test(cargo, &[], &[], crate_name, crate_name, bootstrap_host, builder);
}
Expand Down Expand Up @@ -3099,6 +3100,8 @@ impl Step for Bootstrap {
&[],
);

cargo.release_build(false);

cargo
.rustflag("-Cdebuginfo=2")
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
Expand Down
28 changes: 20 additions & 8 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ impl HostFlags {
#[derive(Debug)]
pub struct Cargo {
command: BootstrapCommand,
args: Vec<OsString>,
compiler: Compiler,
target: TargetSelection,
rustflags: Rustflags,
rustdocflags: Rustflags,
hostflags: HostFlags,
allow_features: String,
release_build: bool,
}

impl Cargo {
Expand Down Expand Up @@ -121,6 +123,10 @@ impl Cargo {
cargo
}

pub fn release_build(&mut self, release_build: bool) {
self.release_build = release_build;
}

pub fn compiler(&self) -> Compiler {
self.compiler
}
Expand Down Expand Up @@ -153,7 +159,7 @@ impl Cargo {
}

pub fn arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Cargo {
self.command.arg(arg.as_ref());
self.args.push(arg.as_ref().into());
self
}

Expand Down Expand Up @@ -335,6 +341,12 @@ impl Cargo {

impl From<Cargo> for BootstrapCommand {
fn from(mut cargo: Cargo) -> BootstrapCommand {
if cargo.release_build {
cargo.args.insert(0, "--release".into());
}

cargo.command.args(cargo.args);

let rustflags = &cargo.rustflags.0;
if !rustflags.is_empty() {
cargo.command.env("RUSTFLAGS", rustflags);
Expand All @@ -353,6 +365,7 @@ impl From<Cargo> for BootstrapCommand {
if !cargo.allow_features.is_empty() {
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
}

cargo.command
}
}
Expand Down Expand Up @@ -422,13 +435,6 @@ impl Builder<'_> {
assert_eq!(target, compiler.host);
}

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

// Remove make-related flags to ensure Cargo can correctly set things up
cargo.env_remove("MAKEFLAGS");
cargo.env_remove("MFLAGS");
Expand Down Expand Up @@ -1214,14 +1220,20 @@ impl Builder<'_> {
rustflags.arg("-Zmir_strip_debuginfo=locals-in-tiny-functions");
}

let release_build = self.config.rust_optimize.is_release() &&
// cargo bench/install do not accept `--release` and miri doesn't want it
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest);

Cargo {
command: cargo,
args: vec![],
compiler,
target,
rustflags,
rustdocflags,
hostflags,
allow_features,
release_build,
}
}
}
Loading