Skip to content

Commit dfa9d64

Browse files
committed
Suggest disabling download-ci-llvm option if url fails to download
1 parent e646f3d commit dfa9d64

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 = f"{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)