diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index e815158398433..95174b18f7aa0 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -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") @@ -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 diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index eea825464fb7e..2ea3383bfd93d 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -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()); @@ -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.