Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]),
Subcommand::Install { ref paths } => (Kind::Install, &paths[..]),
Subcommand::Run { ref paths } => (Kind::Run, &paths[..]),
- Subcommand::Format { .. } | Subcommand::Clean { .. } | Subcommand::Setup { .. } => {
+ Subcommand::Format { .. } => (Kind::Format, &[][..]),
+ Subcommand::Clean { .. } | Subcommand::Setup { .. } => {
panic!()
}
};
) {
// Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
let tempfile = self.tempdir().join(dest_path.file_name().unwrap());
- // FIXME: support `do_verify` (only really needed for nightly rustfmt)
self.download_with_retries(&tempfile, &format!("{}/{}", base, url), help_on_error);
t!(std::fs::rename(&tempfile, dest_path));
}
t!(fs::remove_dir_all(dst.join(directory_prefix)));
}
+ /// Returns whether the SHA256 checksum of `path` matches `expected`.
+ pub(crate) fn verify(&self, path: &Path, expected: &str) -> bool {
+ use sha2::Digest;
+
+ self.verbose(&format!("verifying {}", path.display()));
+ let mut hasher = sha2::Sha256::new();
+ // FIXME: this is ok for rustfmt (4.1 MB large at time of writing), but it seems memory-intensive for rustc and larger components.
+ // Consider using streaming IO instead?
+ let contents = if self.config.dry_run { vec![] } else { t!(fs::read(path)) };
+ hasher.update(&contents);
+ let found = hex::encode(hasher.finalize().as_slice());
+ let verified = found == expected;
+ if !verified && !self.config.dry_run {
+ println!(
+ "invalid checksum: \n\
+ found: {found}\n\
+ expected: {expected}",
+ );
+ }
+ return verified;
+ }
+
/// Obtain a compiler at a given stage and for a given host. Explicitly does
/// not take `Compiler` since all `Compiler` instances are meant to be
/// obtained through this function, since it ensures that they are valid
Config::download_rustc(self)
}
+ pub(crate) fn initial_rustfmt(&self) -> Option<PathBuf> {
+ Config::initial_rustfmt(self)
+ }
+
/// Prepares an invocation of `cargo` to be run.
///
/// This will create a `Command` that represents a pending execution of
// get some support for setting `--check-cfg` within build script, it's the least invasive
// hack that still let's us have cfg checking for the vast majority of the codebase.
if stage != 0 {
- // Enable cfg checking of cargo features for everything but std.
+ // Enable cfg checking of cargo features for everything but std and also enable cfg
+ // checking of names and values.
//
// Note: `std`, `alloc` and `core` imports some dependencies by #[path] (like
- // backtrace, core_simd, std_float, ...), those dependencies have their own features
- // but cargo isn't involved in the #[path] and so cannot pass the complete list of
- // features, so for that reason we don't enable checking of features for std.
+ // backtrace, core_simd, std_float, ...), those dependencies have their own
+ // features but cargo isn't involved in the #[path] process and so cannot pass the
+ // complete list of features, so for that reason we don't enable checking of
+ // features for std crates.
+ cargo.arg(if mode != Mode::Std {
+ "-Zcheck-cfg=names,values,features"
+ } else {
+ "-Zcheck-cfg=names,values"
+ });
+
+ // Add extra cfg not defined in/by rustc
//
- // FIXME: Re-enable this after the beta bump as apperently rustc-perf doesn't use the
- // beta cargo. See https://github.com/rust-lang/rust/pull/96984#issuecomment-1126678773
- // #[cfg(not(bootstrap))]
- // if mode != Mode::Std {
- // cargo.arg("-Zcheck-cfg-features"); // -Zcheck-cfg=features after bump
- // }
-
- // Enable cfg checking of well known names/values
- rustflags
- .arg("-Zunstable-options")
- // Enable checking of well known names
- .arg("--check-cfg=names()")
- // Enable checking of well known values
- .arg("--check-cfg=values()");
-
- // Add extra cfg not defined in rustc
+ // Note: Altrough it would seems that "-Zunstable-options" to `rustflags` is useless as
+ // cargo would implicitly add it, it was discover that sometimes bootstrap only use
+ // `rustflags` without `cargo` making it required.
+ rustflags.arg("-Zunstable-options");
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
if *restricted_mode == None || *restricted_mode == Some(mode) {
// Creating a string of the values by concatenating each value:
stack.push(Box::new(step.clone()));
}
+ #[cfg(feature = "build-metrics")]
+ self.metrics.enter_step(&step);
+
let (out, dur) = {
let start = Instant::now();
let zero = Duration::new(0, 0);
);
}
+ #[cfg(feature = "build-metrics")]
+ self.metrics.exit_step();
+
{
let mut stack = self.stack.borrow_mut();
let cur_step = stack.pop().expect("step stack empty");