Skip to content

Commit b90a369

Browse files
authored
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 8d7707f ./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.
2 parents 783b56b + 410145e commit b90a369

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Diff for: src/bootstrap/bootstrap.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def support_xz():
6363
except tarfile.CompressionError:
6464
return False
6565

66-
def get(base, url, path, checksums, verbose=False, do_verify=True):
66+
def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error=None):
6767
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
6868
temp_path = temp_file.name
6969

@@ -82,7 +82,7 @@ def get(base, url, path, checksums, verbose=False, do_verify=True):
8282
print("ignoring already-download file",
8383
path, "due to failed verification")
8484
os.unlink(path)
85-
download(temp_path, "{}/{}".format(base, url), True, verbose)
85+
download(temp_path, "{}/{}".format(base, url), True, verbose, help_on_error=help_on_error)
8686
if do_verify and not verify(temp_path, sha256, verbose):
8787
raise RuntimeError("failed verification")
8888
if verbose:
@@ -95,17 +95,17 @@ def get(base, url, path, checksums, verbose=False, do_verify=True):
9595
os.unlink(temp_path)
9696

9797

98-
def download(path, url, probably_big, verbose):
98+
def download(path, url, probably_big, verbose, help_on_error=None):
9999
for _ in range(0, 4):
100100
try:
101-
_download(path, url, probably_big, verbose, True)
101+
_download(path, url, probably_big, verbose, True, help_on_error=help_on_error)
102102
return
103103
except RuntimeError:
104104
print("\nspurious failure, trying again")
105-
_download(path, url, probably_big, verbose, False)
105+
_download(path, url, probably_big, verbose, False, help_on_error=help_on_error)
106106

107107

108-
def _download(path, url, probably_big, verbose, exception):
108+
def _download(path, url, probably_big, verbose, exception, help_on_error=None):
109109
if probably_big or verbose:
110110
print("downloading {}".format(url))
111111
# see https://serverfault.com/questions/301128/how-to-download
@@ -126,7 +126,8 @@ def _download(path, url, probably_big, verbose, exception):
126126
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
127127
"--retry", "3", "-Sf", "-o", path, url],
128128
verbose=verbose,
129-
exception=exception)
129+
exception=exception,
130+
help_on_error=help_on_error)
130131

131132

132133
def verify(path, expected, verbose):
@@ -167,7 +168,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
167168
shutil.rmtree(os.path.join(dst, fname))
168169

169170

170-
def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs):
171+
def run(args, verbose=False, exception=False, is_bootstrap=False, help_on_error=None, **kwargs):
171172
"""Run a child program in a new process"""
172173
if verbose:
173174
print("running: " + ' '.join(args))
@@ -178,6 +179,8 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs):
178179
code = ret.wait()
179180
if code != 0:
180181
err = "failed to run: " + ' '.join(args)
182+
if help_on_error is not None:
183+
err += "\n" + help_on_error
181184
if verbose or exception:
182185
raise RuntimeError(err)
183186
# For most failures, we definitely do want to print this error, or the user will have no
@@ -624,13 +627,22 @@ def _download_ci_llvm(self, llvm_sha, llvm_assertions):
624627
filename = "rust-dev-nightly-" + self.build + tarball_suffix
625628
tarball = os.path.join(rustc_cache, filename)
626629
if not os.path.exists(tarball):
630+
help_on_error = "error: failed to download llvm from ci"
631+
help_on_error += "\nhelp: old builds get deleted after a certain time"
632+
help_on_error += "\nhelp: if trying to compile an old commit of rustc,"
633+
help_on_error += " disable `download-ci-llvm` in config.toml:"
634+
help_on_error += "\n"
635+
help_on_error += "\n[llvm]"
636+
help_on_error += "\ndownload-ci-llvm = false"
637+
help_on_error += "\n"
627638
get(
628639
base,
629640
"{}/{}".format(url, filename),
630641
tarball,
631642
self.checksums_sha256,
632643
verbose=self.verbose,
633644
do_verify=False,
645+
help_on_error=help_on_error,
634646
)
635647
unpack(tarball, tarball_suffix, self.llvm_root(),
636648
match="rust-dev",

0 commit comments

Comments
 (0)