@@ -63,7 +63,7 @@ def support_xz():
63
63
except tarfile .CompressionError :
64
64
return False
65
65
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 ):
67
67
with tempfile .NamedTemporaryFile (delete = False ) as temp_file :
68
68
temp_path = temp_file .name
69
69
@@ -82,7 +82,7 @@ def get(base, url, path, checksums, verbose=False, do_verify=True):
82
82
print ("ignoring already-download file" ,
83
83
path , "due to failed verification" )
84
84
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 )
86
86
if do_verify and not verify (temp_path , sha256 , verbose ):
87
87
raise RuntimeError ("failed verification" )
88
88
if verbose :
@@ -95,17 +95,17 @@ def get(base, url, path, checksums, verbose=False, do_verify=True):
95
95
os .unlink (temp_path )
96
96
97
97
98
- def download (path , url , probably_big , verbose ):
98
+ def download (path , url , probably_big , verbose , help_on_error = None ):
99
99
for _ in range (0 , 4 ):
100
100
try :
101
- _download (path , url , probably_big , verbose , True )
101
+ _download (path , url , probably_big , verbose , True , help_on_error = help_on_error )
102
102
return
103
103
except RuntimeError :
104
104
print ("\n spurious 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 )
106
106
107
107
108
- def _download (path , url , probably_big , verbose , exception ):
108
+ def _download (path , url , probably_big , verbose , exception , help_on_error = None ):
109
109
if probably_big or verbose :
110
110
print ("downloading {}" .format (url ))
111
111
# see https://serverfault.com/questions/301128/how-to-download
@@ -126,7 +126,8 @@ def _download(path, url, probably_big, verbose, exception):
126
126
"--connect-timeout" , "30" , # timeout if cannot connect within 30 seconds
127
127
"--retry" , "3" , "-Sf" , "-o" , path , url ],
128
128
verbose = verbose ,
129
- exception = exception )
129
+ exception = exception ,
130
+ help_on_error = help_on_error )
130
131
131
132
132
133
def verify (path , expected , verbose ):
@@ -167,7 +168,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
167
168
shutil .rmtree (os .path .join (dst , fname ))
168
169
169
170
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 ):
171
172
"""Run a child program in a new process"""
172
173
if verbose :
173
174
print ("running: " + ' ' .join (args ))
@@ -178,6 +179,8 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs):
178
179
code = ret .wait ()
179
180
if code != 0 :
180
181
err = "failed to run: " + ' ' .join (args )
182
+ if help_on_error is not None :
183
+ err = f"{ err } \n { help_on_error } "
181
184
if verbose or exception :
182
185
raise RuntimeError (err )
183
186
# 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):
624
627
filename = "rust-dev-nightly-" + self .build + tarball_suffix
625
628
tarball = os .path .join (rustc_cache , filename )
626
629
if not os .path .exists (tarball ):
630
+ help_on_error = "error: failed to download llvm from ci"
631
+ help_on_error += "\n help: old builds get deleted after a certain time"
632
+ help_on_error += "\n help: 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 += "\n download-ci-llvm = false"
637
+ help_on_error += "\n "
627
638
get (
628
639
base ,
629
640
"{}/{}" .format (url , filename ),
630
641
tarball ,
631
642
self .checksums_sha256 ,
632
643
verbose = self .verbose ,
633
644
do_verify = False ,
645
+ help_on_error = help_on_error ,
634
646
)
635
647
unpack (tarball , tarball_suffix , self .llvm_root (),
636
648
match = "rust-dev" ,
0 commit comments