Fix staging for x clippy std

This commit is contained in:
Jakub Beránek 2025-08-08 17:23:34 +02:00
parent 2071a68bd6
commit c5dac1aa2a
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
3 changed files with 68 additions and 57 deletions

View file

@ -134,12 +134,29 @@ impl LintConfig {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Std {
pub target: TargetSelection,
build_compiler: Compiler,
target: TargetSelection,
config: LintConfig,
/// Whether to lint only a subset of crates.
crates: Vec<String>,
}
impl Std {
fn new(
builder: &Builder<'_>,
target: TargetSelection,
config: LintConfig,
crates: Vec<String>,
) -> Self {
Self {
build_compiler: builder.compiler(builder.top_stage, builder.host_target),
target,
config,
crates,
}
}
}
impl Step for Std {
type Output = ();
const DEFAULT: bool = true;
@ -151,12 +168,12 @@ impl Step for Std {
fn make_run(run: RunConfig<'_>) {
let crates = std_crates_for_run_make(&run);
let config = LintConfig::new(run.builder);
run.builder.ensure(Std { target: run.target, config, crates });
run.builder.ensure(Std::new(run.builder, run.target, config, crates));
}
fn run(self, builder: &Builder<'_>) {
let target = self.target;
let build_compiler = builder.compiler(builder.top_stage, builder.config.host_target);
let build_compiler = self.build_compiler;
let mut cargo = builder::Cargo::new(
builder,
@ -193,7 +210,7 @@ impl Step for Std {
}
fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::clippy("std", self.target))
Some(StepMetadata::clippy("std", self.target).built_by(self.build_compiler))
}
}
@ -510,11 +527,12 @@ impl Step for CI {
],
forbid: vec![],
};
builder.ensure(Std {
target: self.target,
config: self.config.merge(&library_clippy_cfg),
crates: vec![],
});
builder.ensure(Std::new(
builder,
self.target,
self.config.merge(&library_clippy_cfg),
vec![],
));
let compiler_clippy_cfg = LintConfig {
allow: vec!["clippy::all".into()],

View file

@ -1556,38 +1556,6 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s
self.ensure(tool::Rustdoc { target_compiler })
}
/// Create a Cargo command for running Clippy.
/// The used Clippy is (or in the case of stage 0, already was) built using `build_compiler`.
pub fn cargo_clippy_cmd(&self, build_compiler: Compiler) -> BootstrapCommand {
if build_compiler.stage == 0 {
let cargo_clippy = self
.config
.initial_cargo_clippy
.clone()
.unwrap_or_else(|| self.build.config.download_clippy());
let mut cmd = command(cargo_clippy);
cmd.env("CARGO", &self.initial_cargo);
return cmd;
}
let compilers = RustcPrivateCompilers::from_build_compiler(
self,
build_compiler,
self.build.host_target,
);
let _ = self.ensure(tool::Clippy::from_compilers(compilers));
let cargo_clippy = self.ensure(tool::CargoClippy::from_compilers(compilers));
let mut dylib_path = helpers::dylib_path();
dylib_path.insert(0, self.sysroot(build_compiler).join("lib"));
let mut cmd = command(cargo_clippy.tool_path);
cmd.env(helpers::dylib_path_var(), env::join_paths(&dylib_path).unwrap());
cmd.env("CARGO", &self.initial_cargo);
cmd
}
pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
assert!(run_compiler.stage > 0, "miri can not be invoked at stage 0");
@ -1614,6 +1582,37 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s
cmd
}
/// Create a Cargo command for running Clippy.
/// The used Clippy is (or in the case of stage 0, already was) built using `build_compiler`.
pub fn cargo_clippy_cmd(&self, build_compiler: Compiler) -> BootstrapCommand {
if build_compiler.stage == 0 {
let cargo_clippy = self
.config
.initial_cargo_clippy
.clone()
.unwrap_or_else(|| self.build.config.download_clippy());
let mut cmd = command(cargo_clippy);
cmd.env("CARGO", &self.initial_cargo);
return cmd;
}
// If we're linting something with build_compiler stage N, we want to build Clippy stage N
// and use that to lint it. That is why we use the `build_compiler` as the target compiler
// for RustcPrivateCompilers. We will use build compiler stage N-1 to build Clippy stage N.
let compilers = RustcPrivateCompilers::from_target_compiler(self, build_compiler);
let _ = self.ensure(tool::Clippy::from_compilers(compilers));
let cargo_clippy = self.ensure(tool::CargoClippy::from_compilers(compilers));
let mut dylib_path = helpers::dylib_path();
dylib_path.insert(0, self.sysroot(build_compiler).join("lib"));
let mut cmd = command(cargo_clippy.tool_path);
cmd.env(helpers::dylib_path_var(), env::join_paths(&dylib_path).unwrap());
cmd.env("CARGO", &self.initial_cargo);
cmd
}
pub fn rustdoc_cmd(&self, compiler: Compiler) -> BootstrapCommand {
let mut cmd = command(self.bootstrap_out.join("rustdoc"));
cmd.env("RUSTC_STAGE", compiler.stage.to_string())

View file

@ -2076,12 +2076,10 @@ mod snapshot {
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[check] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> clippy-driver 2 <host>
[build] rustc 1 <host> -> cargo-clippy 2 <host>
[build] rustc 0 <host> -> clippy-driver 1 <host>
[build] rustc 0 <host> -> cargo-clippy 1 <host>
[clippy] bootstrap <host>
[clippy] std <host>
[clippy] rustc 1 <host> -> std 1 <host>
[clippy] rustc 0 <host> -> rustc 1 <host>
[clippy] rustc 0 <host> -> rustc_codegen_gcc 1 <host>
");
@ -2100,14 +2098,12 @@ mod snapshot {
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[check] rustc 2 <host> -> rustc 3 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 2 <host> -> rustc 3 <host>
[build] rustc 2 <host> -> clippy-driver 3 <host>
[build] rustc 2 <host> -> cargo-clippy 3 <host>
[clippy] bootstrap <host>
[clippy] std <host>
[build] rustc 1 <host> -> clippy-driver 2 <host>
[build] rustc 1 <host> -> cargo-clippy 2 <host>
[clippy] bootstrap <host>
[clippy] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> clippy-driver 1 <host>
[build] rustc 0 <host> -> cargo-clippy 1 <host>
[clippy] rustc 1 <host> -> rustc 2 <host>
[clippy] rustc 1 <host> -> rustc_codegen_gcc 2 <host>
");
@ -2134,11 +2130,9 @@ mod snapshot {
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> clippy-driver 2 <host>
[build] rustc 1 <host> -> cargo-clippy 2 <host>
[clippy] std <host>
[build] rustc 0 <host> -> clippy-driver 1 <host>
[build] rustc 0 <host> -> cargo-clippy 1 <host>
[clippy] rustc 1 <host> -> std 1 <host>
");
}
}