Skip to content

Support x clean --stage 1 rustc_query_impl #106271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 31, 2022
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
19 changes: 19 additions & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ impl RunConfig<'_> {
}
}

/// A description of the crates in this set, suitable for passing to `builder.info`.
///
/// `crates` should be generated by [`RunConfig::cargo_crates_in_set`].
pub fn crate_description(crates: Interned<Vec<String>>) -> String {
if crates.is_empty() {
return "".into();
}

let mut descr = String::from(": {");
for krate in &*crates {
write!(descr, "{}, ", krate.strip_prefix("-p=").unwrap()).unwrap();
}

descr.pop();
descr.pop();
descr.push('}');
descr
}

struct StepDescription {
default: bool,
only_hosts: bool,
Expand Down
22 changes: 10 additions & 12 deletions src/bootstrap/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use std::fs;
use std::io::{self, ErrorKind};
use std::path::Path;

use crate::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::builder::{crate_description, Builder, RunConfig, ShouldRun, Step};
use crate::cache::Interned;
use crate::config::TargetSelection;
use crate::util::t;
use crate::{Build, Mode, Subcommand};
use crate::{Build, Compiler, Mode, Subcommand};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct CleanAll {}
Expand All @@ -40,7 +39,7 @@ macro_rules! clean_crate_tree {
( $( $name:ident, $mode:path, $root_crate:literal);+ $(;)? ) => { $(
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct $name {
target: TargetSelection,
compiler: Compiler,
crates: Interned<Vec<String>>,
}

Expand All @@ -54,22 +53,21 @@ macro_rules! clean_crate_tree {

fn make_run(run: RunConfig<'_>) {
let builder = run.builder;
if builder.top_stage != 0 {
panic!("non-stage-0 clean not supported for individual crates");
}
builder.ensure(Self { crates: run.cargo_crates_in_set(), target: run.target });
let compiler = builder.compiler(builder.top_stage, run.target);
builder.ensure(Self { crates: run.cargo_crates_in_set(), compiler });
}

fn run(self, builder: &Builder<'_>) -> Self::Output {
let compiler = builder.compiler(0, self.target);
let mut cargo = builder.bare_cargo(compiler, $mode, self.target, "clean");
let compiler = self.compiler;
let target = compiler.host;
let mut cargo = builder.bare_cargo(compiler, $mode, target, "clean");
for krate in &*self.crates {
cargo.arg(krate);
}

builder.info(&format!(
"Cleaning stage{} {} artifacts ({} -> {})",
compiler.stage, stringify!($name).to_lowercase(), &compiler.host, self.target
"Cleaning stage{} {} artifacts ({} -> {}){}",
compiler.stage, stringify!($name).to_lowercase(), &compiler.host, target, crate_description(self.crates),
));

// NOTE: doesn't use `run_cargo` because we don't want to save a stamp file,
Expand Down
15 changes: 11 additions & 4 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::str;

use serde::Deserialize;

use crate::builder::crate_description;
use crate::builder::Cargo;
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
use crate::cache::{Interned, INTERNER};
Expand Down Expand Up @@ -128,8 +129,11 @@ impl Step for Std {
std_cargo(builder, target, compiler.stage, &mut cargo);

builder.info(&format!(
"Building stage{} std artifacts ({} -> {})",
compiler.stage, &compiler.host, target
"Building stage{} std artifacts ({} -> {}){}",
compiler.stage,
&compiler.host,
target,
crate_description(self.crates),
));
run_cargo(
builder,
Expand Down Expand Up @@ -715,8 +719,11 @@ impl Step for Rustc {
}

builder.info(&format!(
"Building stage{} compiler artifacts ({} -> {})",
compiler.stage, &compiler.host, target
"Building stage{} compiler artifacts ({} -> {}){}",
compiler.stage,
&compiler.host,
target,
crate_description(self.crates),
));
run_cargo(
builder,
Expand Down