diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-13 06:44:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-13 06:44:16 +0100 |
| commit | b90a369f7c2660cb10cee6d0ee79cf4cdead08ee (patch) | |
| tree | f60777e485dda32a2bda7b24d725138e1e1059aa | |
| parent | 783b56ba68c5737d9593c6e9bb964b44b6889ddc (diff) | |
| parent | 410145e0a7dfac0f9a09ac0cde7301f69a5e64b3 (diff) | |
| download | rust-b90a369f7c2660cb10cee6d0ee79cf4cdead08ee.tar.gz rust-b90a369f7c2660cb10cee6d0ee79cf4cdead08ee.zip | |
Rollup merge of #93885 - Badel2:error-download-ci-llvm, r=Mark-Simulacrum
bootstrap.py: Suggest disabling download-ci-llvm option if url fails to download
I got an error when trying to build the compiler using an old commit, and it turns out it was because the option `download-ci-llvm` was implicitly set to true. So this pull request tries to add a help message for other people that may run into the same problem.
To reproduce my error:
```
git checkout 8d7707f3c4f72e6eb334d897354beca692b265d1
./x.py test
[...]
spurious failure, trying again
downloading https://ci-artifacts.rust-lang.org/rustc-builds/db002a06ae9154a35d410550bc5132df883d7baa/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
curl: (22) The requested URL returned error: 404
failed to run: curl -# -y 30 -Y 10 --connect-timeout 30 --retry 3 -Sf -o /tmp/tmp8g13rb4n https://ci-artifacts.rust-lang.org/rustc-builds/db002a06ae9154a35d410550bc5132df883d7baa/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
Build completed unsuccessfully in 0:00:46
```
This is my `config.toml`:
```
# Includes one of the default files in src/bootstrap/defaults
profile = "compiler"
changelog-seen = 2
[rust]
debug = true
```
To reproduce an error with this branch:
Change line 618 of bootstrap.py to
```
url = "rustc-builds-error404/{}".format(llvm_sha)
```
Delete llvm and cached tarball, and set `llvm.download-ci-llvm=true` in config.toml.
```
./x.py test
[...]
spurious failure, trying again
downloading https://ci-artifacts.rust-lang.org/rustc-builds-error404/719b04ca99be0c78e09a8ec5e2eda082a5d8ccae/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
curl: (22) The requested URL returned error: 404
failed to run: curl -# -y 30 -Y 10 --connect-timeout 30 --retry 3 -Sf -o /tmp/tmpesl1ydvo https://ci-artifacts.rust-lang.org/rustc-builds-error404/719b04ca99be0c78e09a8ec5e2eda082a5d8ccae/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
error: failed to download llvm from ci
help: old builds get deleted after a certain time
help: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml:
[llvm]
download-ci-llvm = false
Build completed unsuccessfully in 0:00:01
```
Regarding the implementation, I expected to be able to use a try/catch block in `_download_ci_llvm`, but the `run` function calls `sys.exit` instead of raising an exception so that's not possible. Also, suggestions for better wording of the help message are welcome.
| -rw-r--r-- | src/bootstrap/bootstrap.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 86115a90294..6c1128b393f 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): +def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error=None): with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_path = temp_file.name @@ -82,7 +82,7 @@ def get(base, url, path, checksums, verbose=False, do_verify=True): print("ignoring already-download file", path, "due to failed verification") os.unlink(path) - download(temp_path, "{}/{}".format(base, url), True, verbose) + download(temp_path, "{}/{}".format(base, url), True, verbose, help_on_error=help_on_error) if do_verify and not verify(temp_path, sha256, verbose): raise RuntimeError("failed verification") if verbose: @@ -95,17 +95,17 @@ def get(base, url, path, checksums, verbose=False, do_verify=True): os.unlink(temp_path) -def download(path, url, probably_big, verbose): +def download(path, url, probably_big, verbose, help_on_error=None): for _ in range(0, 4): try: - _download(path, url, probably_big, verbose, True) + _download(path, url, probably_big, verbose, True, help_on_error=help_on_error) return except RuntimeError: print("\nspurious failure, trying again") - _download(path, url, probably_big, verbose, False) + _download(path, url, probably_big, verbose, False, help_on_error=help_on_error) -def _download(path, url, probably_big, verbose, exception): +def _download(path, url, probably_big, verbose, exception, help_on_error=None): if probably_big or verbose: print("downloading {}".format(url)) # see https://serverfault.com/questions/301128/how-to-download @@ -126,7 +126,8 @@ def _download(path, url, probably_big, verbose, exception): "--connect-timeout", "30", # timeout if cannot connect within 30 seconds "--retry", "3", "-Sf", "-o", path, url], verbose=verbose, - exception=exception) + exception=exception, + help_on_error=help_on_error) def verify(path, expected, verbose): @@ -167,7 +168,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, **kwargs): +def run(args, verbose=False, exception=False, is_bootstrap=False, help_on_error=None, **kwargs): """Run a child program in a new process""" if verbose: print("running: " + ' '.join(args)) @@ -178,6 +179,8 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs): 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 @@ -624,6 +627,14 @@ class RustBuild(object): filename = "rust-dev-nightly-" + self.build + tarball_suffix tarball = os.path.join(rustc_cache, filename) if not os.path.exists(tarball): + help_on_error = "error: failed to download llvm from ci" + help_on_error += "\nhelp: old builds get deleted after a certain time" + help_on_error += "\nhelp: if trying to compile an old commit of rustc," + help_on_error += " disable `download-ci-llvm` in config.toml:" + help_on_error += "\n" + help_on_error += "\n[llvm]" + help_on_error += "\ndownload-ci-llvm = false" + help_on_error += "\n" get( base, "{}/{}".format(url, filename), @@ -631,6 +642,7 @@ class RustBuild(object): self.checksums_sha256, verbose=self.verbose, do_verify=False, + help_on_error=help_on_error, ) unpack(tarball, tarball_suffix, self.llvm_root(), match="rust-dev", |
