Skip to content

Commit b607b7b

Browse files
authored
Rollup merge of rust-lang#137541 - onur-ozkan:fix-cargo-clippy-bin, r=jieyouxu
add `tool::CargoClippy` and `tool::Cargofmt` binary to target sysroot When running `x build clippy`, we expect `stage1-tool-bin/cargo-clippy` and `stage2/bin/cargo-clippy` to be the same, but they aren't. This happens because `tool::CargoClippy` doesn't place its binary in the `stage2` directory. As a result, `stage1-tool-bin/cargo-clippy` comes from `tool::CargoClippy`, while `stage2/bin/cargo-clippy` comes from `tool::Cargo`. Same applies for `tool::Cargofmt`. This PR fixes the issue by adding `tool::CargoClippy` and ``tool::Cargofmt`` binaries to the expected sysroot and makes sure both directories share the same binary. To test this, run `x build --stage 2 compiler clippy rustfmt`, link the stage2 sysroot with rustup, and then call `cargo +stage2 fmt` and `cargo +stage2 clippy` on any rust project (it wouldn't work without this PR).
2 parents 8d77084 + f677bab commit b607b7b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,13 +1189,23 @@ fn run_tool_build_step(
11891189
}
11901190
}
11911191

1192-
tool_extended!(Cargofmt { path: "src/tools/rustfmt", tool_name: "cargo-fmt", stable: true });
1193-
tool_extended!(CargoClippy { path: "src/tools/clippy", tool_name: "cargo-clippy", stable: true });
1192+
tool_extended!(Cargofmt {
1193+
path: "src/tools/rustfmt",
1194+
tool_name: "cargo-fmt",
1195+
stable: true,
1196+
add_bins_to_sysroot: ["cargo-fmt"]
1197+
});
1198+
tool_extended!(CargoClippy {
1199+
path: "src/tools/clippy",
1200+
tool_name: "cargo-clippy",
1201+
stable: true,
1202+
add_bins_to_sysroot: ["cargo-clippy"]
1203+
});
11941204
tool_extended!(Clippy {
11951205
path: "src/tools/clippy",
11961206
tool_name: "clippy-driver",
11971207
stable: true,
1198-
add_bins_to_sysroot: ["clippy-driver", "cargo-clippy"]
1208+
add_bins_to_sysroot: ["clippy-driver"]
11991209
});
12001210
tool_extended!(Miri {
12011211
path: "src/tools/miri",
@@ -1214,7 +1224,7 @@ tool_extended!(Rustfmt {
12141224
path: "src/tools/rustfmt",
12151225
tool_name: "rustfmt",
12161226
stable: true,
1217-
add_bins_to_sysroot: ["rustfmt", "cargo-fmt"]
1227+
add_bins_to_sysroot: ["rustfmt"]
12181228
});
12191229

12201230
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

src/bootstrap/src/core/builder/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ impl<'a> Builder<'a> {
890890
gcc::Gcc,
891891
llvm::Sanitizers,
892892
tool::Rustfmt,
893+
tool::Cargofmt,
893894
tool::Miri,
894895
tool::CargoMiri,
895896
llvm::Lld,

0 commit comments

Comments
 (0)