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
18 changes: 5 additions & 13 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ impl Step for Std {
return;
}

// Explicitly pass -p for all dependencies crates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
// than just the leaf crate.
let crates = std_crates_for_run_make(&run);
run.builder.ensure(Std {
build_compiler: prepare_compiler_for_check(run.builder, run.target, Mode::Std)
Expand All @@ -83,16 +86,12 @@ impl Step for Std {
Kind::Check,
);

std_cargo(builder, target, &mut cargo);
std_cargo(builder, target, &mut cargo, &self.crates);
if matches!(builder.config.cmd, Subcommand::Fix) {
// By default, cargo tries to fix all targets. Tell it not to fix tests until we've added `test` to the sysroot.
cargo.arg("--lib");
}

for krate in &*self.crates {
cargo.arg("-p").arg(krate);
}

let _guard = builder.msg(
Kind::Check,
format_args!("library artifacts{}", crate_description(&self.crates)),
Expand Down Expand Up @@ -135,14 +134,7 @@ impl Step for Std {
Kind::Check,
);

std_cargo(builder, target, &mut cargo);

// Explicitly pass -p for all dependencies krates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
// than just the leaf crate.
for krate in &*self.crates {
cargo.arg("-p").arg(krate);
}
std_cargo(builder, target, &mut cargo, &self.crates);

let stamp =
build_stamp::libstd_stamp(builder, build_compiler, target).with_prefix("check-test");
Expand Down
6 changes: 1 addition & 5 deletions src/bootstrap/src/core/build_steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ impl Step for Std {
Kind::Clippy,
);

std_cargo(builder, target, &mut cargo);

for krate in &*self.crates {
cargo.arg("-p").arg(krate);
}
std_cargo(builder, target, &mut cargo, &self.crates);

let _guard = builder.msg(
Kind::Clippy,
Expand Down
20 changes: 14 additions & 6 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,7 @@ impl Step for Std {
target,
Kind::Build,
);
std_cargo(builder, target, &mut cargo);
for krate in &*self.crates {
cargo.arg("-p").arg(krate);
}
std_cargo(builder, target, &mut cargo, &self.crates);
cargo
};

Expand Down Expand Up @@ -497,7 +494,12 @@ fn compiler_rt_for_profiler(builder: &Builder<'_>) -> PathBuf {

/// Configure cargo to compile the standard library, adding appropriate env vars
/// and such.
pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, cargo: &mut Cargo) {
pub fn std_cargo(
builder: &Builder<'_>,
target: TargetSelection,
cargo: &mut Cargo,
crates: &[String],
) {
// rustc already ensures that it builds with the minimum deployment
// target, so ideally we shouldn't need to do anything here.
//
Expand Down Expand Up @@ -605,6 +607,10 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, cargo: &mut Car
cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1");
}

for krate in crates {
cargo.args(["-p", krate]);
}

let mut features = String::new();

if builder.no_std(target) == Some(true) {
Expand All @@ -614,8 +620,10 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, cargo: &mut Car
}

// for no-std targets we only compile a few no_std crates
if crates.is_empty() {
cargo.args(["-p", "alloc"]);
}
cargo
.args(["-p", "alloc"])
.arg("--manifest-path")
.arg(builder.src.join("library/alloc/Cargo.toml"))
.arg("--features")
Expand Down
6 changes: 1 addition & 5 deletions src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ fn doc_std(
Kind::Doc,
);

compile::std_cargo(builder, target, &mut cargo);
compile::std_cargo(builder, target, &mut cargo, requested_crates);
cargo
.arg("--no-deps")
.arg("--target-dir")
Expand All @@ -803,10 +803,6 @@ fn doc_std(
cargo.rustdocflag("--document-private-items").rustdocflag("--document-hidden-items");
}

for krate in requested_crates {
cargo.arg("-p").arg(krate);
}

let description =
format!("library{} in {} format", crate_description(requested_crates), format.as_str());
let _guard = builder.msg(Kind::Doc, description, Mode::Std, build_compiler, target);
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2963,7 +2963,7 @@ impl Step for Crate {
.arg("--manifest-path")
.arg(builder.src.join("library/sysroot/Cargo.toml"));
} else {
compile::std_cargo(builder, target, &mut cargo);
compile::std_cargo(builder, target, &mut cargo, &[]);
}
}
Mode::Rustc => {
Expand Down
Loading