Skip to content

Commit

Permalink
fix x clippy --stage 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Nov 5, 2023
1 parent 56ec3c0 commit d69d34b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 11 additions & 2 deletions src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ fn main() {
// determine the version of the compiler, the real compiler needs to be
// used. Currently, these two states are differentiated based on whether
// --target and -vV is/isn't passed.
let (rustc, libdir) = if target.is_none() && version.is_none() {
let is_build_script = target.is_none() && version.is_none();
let (rustc, libdir) = if is_build_script {
("RUSTC_SNAPSHOT", "RUSTC_SNAPSHOT_LIBDIR")
} else {
("RUSTC_REAL", "RUSTC_LIBDIR")
Expand All @@ -70,7 +71,15 @@ fn main() {
.unwrap_or_else(|| env::var("CFG_COMPILER_HOST_TRIPLE").unwrap());
let is_clippy = args[0].to_string_lossy().ends_with(&exe("clippy-driver", &target_name));
let rustc_driver = if is_clippy {
args.remove(0)
if is_build_script {
// Don't run clippy on build scripts (for one thing, we may not have libstd built with
// the appropriate version yet, e.g. for stage 1 std).
// Also remove the `clippy-driver` param in addition to the RUSTC param.
args.drain(..2);
rustc_real
} else {
args.remove(0)
}
} else {
args.remove(0);
rustc_real
Expand Down
11 changes: 0 additions & 11 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,6 @@ impl<'a> Builder<'a> {
extra_features: vec![],
});
let mut dylib_path = dylib_path();
let run_compiler = self.compiler(build_compiler.stage + 1, self.build.build);
dylib_path.insert(0, self.sysroot(run_compiler).join("lib"));

let mut cmd = Command::new(cargo_clippy.unwrap());
Expand Down Expand Up @@ -1634,16 +1633,6 @@ impl<'a> Builder<'a> {
self.clear_if_dirty(&out_dir, &self.rustc(compiler));
}

// HACK: clippy will pass `--sysroot` to `RunCompiler` if and only if SYSROOT is set and
// `--sysroot is not already passed. Cargo doesn't pass `--sysroot` through RUSTFLAGS for
// build scripts and proc-macros, which is exactly when we want to use the beta sysroot
// instead of the in-tree libstd. Set SYSROOT so we use beta for stage 0 build
if cmd == "clippy" {
let build_script_sysroot =
if stage == 0 { self.rustc_snapshot_sysroot() } else { sysroot };
cargo.env("SYSROOT", build_script_sysroot);
}

// Customize the compiler we're running. Specify the compiler to cargo
// as our shim and then pass it some various options used to configure
// how the actual compiler itself is called.
Expand Down

0 comments on commit d69d34b

Please sign in to comment.