Skip to content

Commit

Permalink
Fix caching bug in download-rustc = true
Browse files Browse the repository at this point in the history
When moving this to rustbuild, I introduced a bug: if you had the file already downloaded, but
deleted the sysroot for whatever reason, rustbuil would fail to unpack the cached tarball.

This only affects people if they have a cached tarball, which is probably why we haven't seen an issue yet -
wiping `build/cache` would work around the issue, or just not deleting `build/$TARGET/stage2`.
  • Loading branch information
jyn514 committed Jul 2, 2022
1 parent acdcdfb commit 75dfd5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,7 @@ impl<'a> Builder<'a> {
}

pub(crate) fn download_component(&self, url: &str, dest_path: &Path, help_on_error: &str) {
self.verbose(&format!("download {url}"));
// 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());
// While bootstrap itself only supports http and https downloads, downstream forks might
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));
builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustdoc"));
let lib_dir = bin_root.join("lib");
for lib in t!(fs::read_dir(lib_dir)) {
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
let lib = t!(lib);
if lib.path().extension() == Some(OsStr::new("so")) {
builder.fix_bin_or_dylib(&lib.path());
Expand Down Expand Up @@ -1636,6 +1636,7 @@ fn download_component(
}
Some(sha256)
} else if tarball.exists() {
builder.unpack(&tarball, &bin_root, prefix);
return;
} else {
None
Expand Down

0 comments on commit 75dfd5e

Please sign in to comment.