Skip to content

Commit 4d01cc8

Browse files
authored
Unrolled build for rust-lang#129152
Rollup merge of rust-lang#129152 - onur-ozkan:custom-clippy, r=Kobzol custom/external clippy support for bootstrapping Similar to cargo, rustc, and rustfmt, this adds the support of using custom clippy on bootstrap. It’s designed for those who want to test their own clippy builds or avoid downloading the stage0 clippy. Closes rust-lang#121518
2 parents 6199b69 + 1a991e5 commit 4d01cc8

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

config.example.toml

+7
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@
230230
# use this rustfmt binary instead as the stage0 snapshot rustfmt.
231231
#rustfmt = "/path/to/rustfmt"
232232

233+
# Instead of downloading the src/stage0 version of cargo-clippy specified,
234+
# use this cargo-clippy binary instead as the stage0 snapshot cargo-clippy.
235+
#
236+
# Note that this option should be used with the same toolchain as the `rustc` option above.
237+
# Otherwise, clippy is likely to fail due to a toolchain conflict.
238+
#cargo-clippy = "/path/to/cargo-clippy"
239+
233240
# Whether to build documentation by default. If false, rustdoc and
234241
# friends will still be compiled but they will not be used to generate any
235242
# documentation.

src/bootstrap/src/core/builder.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,12 @@ impl<'a> Builder<'a> {
12981298

12991299
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
13001300
if run_compiler.stage == 0 {
1301-
// `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy.
1302-
let cargo_clippy = self.build.config.download_clippy();
1301+
let cargo_clippy = self
1302+
.config
1303+
.initial_cargo_clippy
1304+
.clone()
1305+
.unwrap_or_else(|| self.build.config.download_clippy());
1306+
13031307
let mut cmd = command(cargo_clippy);
13041308
cmd.env("CARGO", &self.initial_cargo);
13051309
return cmd;

src/bootstrap/src/core/config/config.rs

+11
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ pub struct Config {
344344
// These are either the stage0 downloaded binaries or the locally installed ones.
345345
pub initial_cargo: PathBuf,
346346
pub initial_rustc: PathBuf,
347+
pub initial_cargo_clippy: Option<PathBuf>,
347348

348349
#[cfg(not(test))]
349350
initial_rustfmt: RefCell<RustfmtState>,
@@ -834,6 +835,7 @@ define_config! {
834835
cargo: Option<PathBuf> = "cargo",
835836
rustc: Option<PathBuf> = "rustc",
836837
rustfmt: Option<PathBuf> = "rustfmt",
838+
cargo_clippy: Option<PathBuf> = "cargo-clippy",
837839
docs: Option<bool> = "docs",
838840
compiler_docs: Option<bool> = "compiler-docs",
839841
library_docs_private_items: Option<bool> = "library-docs-private-items",
@@ -1439,6 +1441,7 @@ impl Config {
14391441
cargo,
14401442
rustc,
14411443
rustfmt,
1444+
cargo_clippy,
14421445
docs,
14431446
compiler_docs,
14441447
library_docs_private_items,
@@ -1491,6 +1494,14 @@ impl Config {
14911494
config.out = absolute(&config.out).expect("can't make empty path absolute");
14921495
}
14931496

1497+
if cargo_clippy.is_some() && rustc.is_none() {
1498+
println!(
1499+
"WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict."
1500+
);
1501+
}
1502+
1503+
config.initial_cargo_clippy = cargo_clippy;
1504+
14941505
config.initial_rustc = if let Some(rustc) = rustc {
14951506
if !flags.skip_stage0_validation {
14961507
config.check_stage0_version(&rustc, "rustc");

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
235235
severity: ChangeSeverity::Info,
236236
summary: "The `build.profiler` option now tries to use source code from `download-ci-llvm` if possible, instead of checking out the `src/llvm-project` submodule.",
237237
},
238+
ChangeInfo {
239+
change_id: 129152,
240+
severity: ChangeSeverity::Info,
241+
summary: "New option `build.cargo-clippy` added for supporting the use of custom/external clippy.",
242+
},
238243
];

0 commit comments

Comments
 (0)