diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-30 14:33:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-30 14:33:51 +0200 |
| commit | 9bb3832ebd7aa820366598187862fd6370aefd9f (patch) | |
| tree | 6c80776050306e1032a3ceb450f50fa32144d9c9 /src | |
| parent | 106d5fde92f210b9a1728a54b9ce76ad52641b40 (diff) | |
| parent | c0f18f9412f222e7f314a637d69968618f633b01 (diff) | |
| download | rust-9bb3832ebd7aa820366598187862fd6370aefd9f.tar.gz rust-9bb3832ebd7aa820366598187862fd6370aefd9f.zip | |
Rollup merge of #97519 - binggh:readd-help-on-error, r=jyn514
Re-add help_on_error for download-ci-llvm Closes #97503 - Re-added `help_on_error` for `download_component()` and the downstream functions - Removed dead code in `bootstrap.py` Thanks `@jyn514` for the helpful tips! (first contribution here, please let me know if I missed anything out!)
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 18 | ||||
| -rw-r--r-- | src/bootstrap/builder.rs | 15 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/native.rs | 10 |
4 files changed, 30 insertions, 15 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 955edd94c78..a997c4f63ab 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -63,7 +63,7 @@ def support_xz(): except tarfile.CompressionError: return False -def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error=None): +def get(base, url, path, checksums, verbose=False, do_verify=True): with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_path = temp_file.name @@ -86,7 +86,7 @@ def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error print("ignoring already-download file", path, "due to failed verification") os.unlink(path) - download(temp_path, "{}/{}".format(base, url), True, verbose, help_on_error=help_on_error) + download(temp_path, "{}/{}".format(base, url), True, verbose) if do_verify and not verify(temp_path, sha256, verbose): raise RuntimeError("failed verification") if verbose: @@ -99,17 +99,17 @@ def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error os.unlink(temp_path) -def download(path, url, probably_big, verbose, help_on_error=None): +def download(path, url, probably_big, verbose): for _ in range(0, 4): try: - _download(path, url, probably_big, verbose, True, help_on_error=help_on_error) + _download(path, url, probably_big, verbose, True) return except RuntimeError: print("\nspurious failure, trying again") - _download(path, url, probably_big, verbose, False, help_on_error=help_on_error) + _download(path, url, probably_big, verbose, False) -def _download(path, url, probably_big, verbose, exception, help_on_error=None): +def _download(path, url, probably_big, verbose, exception): # Try to use curl (potentially available on win32 # https://devblogs.microsoft.com/commandline/tar-and-curl-come-to-windows/) # If an error occurs: @@ -134,7 +134,7 @@ def _download(path, url, probably_big, verbose, exception, help_on_error=None): "--retry", "3", "-Sf", "-o", path, url], verbose=verbose, exception=True, # Will raise RuntimeError on failure - help_on_error=help_on_error) + ) except (subprocess.CalledProcessError, OSError, RuntimeError): # see http://serverfault.com/questions/301128/how-to-download if platform_is_win32: @@ -186,7 +186,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): shutil.rmtree(os.path.join(dst, fname)) -def run(args, verbose=False, exception=False, is_bootstrap=False, help_on_error=None, **kwargs): +def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs): """Run a child program in a new process""" if verbose: print("running: " + ' '.join(args)) @@ -197,8 +197,6 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, help_on_error= code = ret.wait() if code != 0: err = "failed to run: " + ' '.join(args) - if help_on_error is not None: - err += "\n" + help_on_error if verbose or exception: raise RuntimeError(err) # For most failures, we definitely do want to print this error, or the user will have no diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index ab4b52f2555..17c2d1c79ec 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -869,15 +869,21 @@ impl<'a> Builder<'a> { self.try_run(patchelf.arg(fname)); } - pub(crate) fn download_component(&self, base: &str, url: &str, dest_path: &Path) { + pub(crate) fn download_component( + &self, + base: &str, + url: &str, + dest_path: &Path, + help_on_error: &str, + ) { // 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)); + self.download_with_retries(&tempfile, &format!("{}/{}", base, url), help_on_error); t!(std::fs::rename(&tempfile, dest_path)); } - fn download_with_retries(&self, tempfile: &Path, url: &str) { + fn download_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) { println!("downloading {}", url); // Try curl. If that fails and we are on windows, fallback to PowerShell. let mut curl = Command::new("curl"); @@ -914,6 +920,9 @@ impl<'a> Builder<'a> { println!("\nspurious failure, trying again"); } } + if !help_on_error.is_empty() { + eprintln!("{}", help_on_error); + } std::process::exit(1); } } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 7775e057370..8e94fc7c4be 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1491,7 +1491,7 @@ fn download_component(builder: &Builder<'_>, filename: String, prefix: &str, com let url = format!("rustc-builds/{commit}"); let tarball = rustc_cache.join(&filename); if !tarball.exists() { - builder.download_component(base, &format!("{url}/{filename}"), &tarball); + builder.download_component(base, &format!("{url}/{filename}"), &tarball, ""); } let bin_root = builder.out.join(builder.config.build.triple).join("ci-rustc"); builder.unpack(&tarball, &bin_root, prefix) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index b2d7ccb01cf..a41079333b1 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -179,7 +179,15 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) { let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple); let tarball = rustc_cache.join(&filename); if !tarball.exists() { - builder.download_component(base, &format!("{}/{}", url, filename), &tarball); + let help_on_error = "error: failed to download llvm from ci\n +\nhelp: old builds get deleted after a certain time +\nhelp: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml: +\n +\n[llvm] +\ndownload-ci-llvm = false +\n +"; + builder.download_component(base, &format!("{}/{}", url, filename), &tarball, help_on_error); } let llvm_root = builder.config.ci_llvm_root(); builder.unpack(&tarball, &llvm_root, "rust-dev"); |
