Skip to content

Commit a96fa31

Browse files
committed
Auto merge of #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 446649d + f677bab commit a96fa31

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

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

+14-4
Original file line numberDiff line numberDiff line change
@@ -1201,13 +1201,23 @@ fn run_tool_build_step(
12011201
}
12021202
}
12031203

1204-
tool_extended!(Cargofmt { path: "src/tools/rustfmt", tool_name: "cargo-fmt", stable: true });
1205-
tool_extended!(CargoClippy { path: "src/tools/clippy", tool_name: "cargo-clippy", stable: true });
1204+
tool_extended!(Cargofmt {
1205+
path: "src/tools/rustfmt",
1206+
tool_name: "cargo-fmt",
1207+
stable: true,
1208+
add_bins_to_sysroot: ["cargo-fmt"]
1209+
});
1210+
tool_extended!(CargoClippy {
1211+
path: "src/tools/clippy",
1212+
tool_name: "cargo-clippy",
1213+
stable: true,
1214+
add_bins_to_sysroot: ["cargo-clippy"]
1215+
});
12061216
tool_extended!(Clippy {
12071217
path: "src/tools/clippy",
12081218
tool_name: "clippy-driver",
12091219
stable: true,
1210-
add_bins_to_sysroot: ["clippy-driver", "cargo-clippy"]
1220+
add_bins_to_sysroot: ["clippy-driver"]
12111221
});
12121222
tool_extended!(Miri {
12131223
path: "src/tools/miri",
@@ -1226,7 +1236,7 @@ tool_extended!(Rustfmt {
12261236
path: "src/tools/rustfmt",
12271237
tool_name: "rustfmt",
12281238
stable: true,
1229-
add_bins_to_sysroot: ["rustfmt", "cargo-fmt"]
1239+
add_bins_to_sysroot: ["rustfmt"]
12301240
});
12311241

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

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

+1
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)