about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-07-08 08:00:39 +0200
committerGitHub <noreply@github.com>2022-07-08 08:00:39 +0200
commit6c6791a45831f2c15367fb96d09ea18f756d621e (patch)
tree7a0b9a8e8b14becef9a8d7d9cccfe31e63b1d06d
parent5dcd28cd1964969d605cddfcaec102006aa020c9 (diff)
parent75dfd5e1c1a51c44c8eb8d7474879f6ae5969085 (diff)
Rollup merge of #98798 - jyn514:download-rustc-cached, r=Mark-Simulacrum
Fix caching bug in `download-rustc = true`

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`.

Fixes the following error:
```
thread 'main' panicked at 'fs::read_dir(&lib_dir) failed with No such file or directory (os error 2) ("/home/jnelson/rust-lang/rust2/build/x86_64-unknown-linux-gnu/ci-rustc/lib")', config.rs:1563:20
```

r? ``@Mark-Simulacrum``
-rw-r--r--src/bootstrap/builder.rs1
-rw-r--r--src/bootstrap/config.rs3
2 files changed, 3 insertions, 1 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 2e89abe202c..fa6a5ee1668 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -949,6 +949,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
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index e71fbff14dd..ee3b072fe35 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -1558,7 +1558,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());
@@ -1634,6 +1634,7 @@ fn download_component(
         }
         Some(sha256)
     } else if tarball.exists() {
+        builder.unpack(&tarball, &bin_root, prefix);
         return;
     } else {
         None