@@ -39,23 +39,23 @@ def get(base, url, path, checksums, verbose=False):
39
39
if os .path .exists (path ):
40
40
if verify (path , sha256 , False ):
41
41
if verbose :
42
- print ("using already-download file" , path )
42
+ print ("using already-download file" , path , file = sys . stderr )
43
43
return
44
44
else :
45
45
if verbose :
46
46
print ("ignoring already-download file" ,
47
- path , "due to failed verification" )
47
+ path , "due to failed verification" , file = sys . stderr )
48
48
os .unlink (path )
49
49
download (temp_path , "{}/{}" .format (base , url ), True , verbose )
50
50
if not verify (temp_path , sha256 , verbose ):
51
51
raise RuntimeError ("failed verification" )
52
52
if verbose :
53
- print ("moving {} to {}" .format (temp_path , path ))
53
+ print ("moving {} to {}" .format (temp_path , path ), file = sys . stderr )
54
54
shutil .move (temp_path , path )
55
55
finally :
56
56
if os .path .isfile (temp_path ):
57
57
if verbose :
58
- print ("removing" , temp_path )
58
+ print ("removing" , temp_path , file = sys . stderr )
59
59
os .unlink (temp_path )
60
60
61
61
@@ -65,7 +65,7 @@ def download(path, url, probably_big, verbose):
65
65
_download (path , url , probably_big , verbose , True )
66
66
return
67
67
except RuntimeError :
68
- print ("\n spurious failure, trying again" )
68
+ print ("\n spurious failure, trying again" , file = sys . stderr )
69
69
_download (path , url , probably_big , verbose , False )
70
70
71
71
@@ -76,7 +76,7 @@ def _download(path, url, probably_big, verbose, exception):
76
76
# - If we are on win32 fallback to powershell
77
77
# - Otherwise raise the error if appropriate
78
78
if probably_big or verbose :
79
- print ("downloading {}" .format (url ))
79
+ print ("downloading {}" .format (url ), file = sys . stderr )
80
80
81
81
platform_is_win32 = sys .platform == 'win32'
82
82
try :
@@ -113,20 +113,20 @@ def _download(path, url, probably_big, verbose, exception):
113
113
def verify (path , expected , verbose ):
114
114
"""Check if the sha256 sum of the given path is valid"""
115
115
if verbose :
116
- print ("verifying" , path )
116
+ print ("verifying" , path , file = sys . stderr )
117
117
with open (path , "rb" ) as source :
118
118
found = hashlib .sha256 (source .read ()).hexdigest ()
119
119
verified = found == expected
120
120
if not verified :
121
121
print ("invalid checksum:\n "
122
122
" found: {}\n "
123
- " expected: {}" .format (found , expected ))
123
+ " expected: {}" .format (found , expected ), file = sys . stderr )
124
124
return verified
125
125
126
126
127
127
def unpack (tarball , tarball_suffix , dst , verbose = False , match = None ):
128
128
"""Unpack the given tarball file"""
129
- print ("extracting" , tarball )
129
+ print ("extracting" , tarball , file = sys . stderr )
130
130
fname = os .path .basename (tarball ).replace (tarball_suffix , "" )
131
131
with contextlib .closing (tarfile .open (tarball )) as tar :
132
132
for member in tar .getnames ():
@@ -139,7 +139,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
139
139
140
140
dst_path = os .path .join (dst , name )
141
141
if verbose :
142
- print (" extracting" , member )
142
+ print (" extracting" , member , file = sys . stderr )
143
143
tar .extract (member , dst )
144
144
src_path = os .path .join (dst , member )
145
145
if os .path .isdir (src_path ) and os .path .exists (dst_path ):
@@ -151,7 +151,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
151
151
def run (args , verbose = False , exception = False , is_bootstrap = False , ** kwargs ):
152
152
"""Run a child program in a new process"""
153
153
if verbose :
154
- print ("running: " + ' ' .join (args ))
154
+ print ("running: " + ' ' .join (args ), file = sys . stderr )
155
155
sys .stdout .flush ()
156
156
# Ensure that the .exe is used on Windows just in case a Linux ELF has been
157
157
# compiled in the same directory.
@@ -187,8 +187,8 @@ def require(cmd, exit=True, exception=False):
187
187
if exception :
188
188
raise
189
189
elif exit :
190
- print ("error: unable to run `{}`: {}" .format (' ' .join (cmd ), exc ))
191
- print ("Please make sure it's installed and in the path." )
190
+ print ("error: unable to run `{}`: {}" .format (' ' .join (cmd ), exc ), file = sys . stderr )
191
+ print ("Please make sure it's installed and in the path." , file = sys . stderr )
192
192
sys .exit (1 )
193
193
return None
194
194
@@ -212,8 +212,8 @@ def default_build_triple(verbose):
212
212
213
213
if sys .platform == 'darwin' :
214
214
if verbose :
215
- print ("not using rustc detection as it is unreliable on macOS" )
216
- print ("falling back to auto-detect" )
215
+ print ("not using rustc detection as it is unreliable on macOS" , file = sys . stderr )
216
+ print ("falling back to auto-detect" , file = sys . stderr )
217
217
else :
218
218
try :
219
219
version = subprocess .check_output (["rustc" , "--version" , "--verbose" ],
@@ -222,12 +222,14 @@ def default_build_triple(verbose):
222
222
host = next (x for x in version .split ('\n ' ) if x .startswith ("host: " ))
223
223
triple = host .split ("host: " )[1 ]
224
224
if verbose :
225
- print ("detected default triple {} from pre-installed rustc" .format (triple ))
225
+ print ("detected default triple {} from pre-installed rustc" .format (triple ),
226
+ file = sys .stderr )
226
227
return triple
227
228
except Exception as e :
228
229
if verbose :
229
- print ("pre-installed rustc not detected: {}" .format (e ))
230
- print ("falling back to auto-detect" )
230
+ print ("pre-installed rustc not detected: {}" .format (e ),
231
+ file = sys .stderr )
232
+ print ("falling back to auto-detect" , file = sys .stderr )
231
233
232
234
required = sys .platform != 'win32'
233
235
ostype = require (["uname" , "-s" ], exit = required )
@@ -522,7 +524,7 @@ def get_answer():
522
524
523
525
answer = self ._should_fix_bins_and_dylibs = get_answer ()
524
526
if answer :
525
- print ("info: You seem to be using Nix." )
527
+ print ("info: You seem to be using Nix." , file = sys . stderr )
526
528
return answer
527
529
528
530
def fix_bin_or_dylib (self , fname ):
@@ -535,7 +537,7 @@ def fix_bin_or_dylib(self, fname):
535
537
Please see https://nixos.org/patchelf.html for more information
536
538
"""
537
539
assert self ._should_fix_bins_and_dylibs is True
538
- print ("attempting to patch" , fname )
540
+ print ("attempting to patch" , fname , file = sys . stderr )
539
541
540
542
# Only build `.nix-deps` once.
541
543
nix_deps_dir = self .nix_deps_dir
@@ -568,7 +570,7 @@ def fix_bin_or_dylib(self, fname):
568
570
"nix-build" , "-E" , nix_expr , "-o" , nix_deps_dir ,
569
571
])
570
572
except subprocess .CalledProcessError as reason :
571
- print ("warning: failed to call nix-build:" , reason )
573
+ print ("warning: failed to call nix-build:" , reason , file = sys . stderr )
572
574
return
573
575
self .nix_deps_dir = nix_deps_dir
574
576
@@ -588,7 +590,7 @@ def fix_bin_or_dylib(self, fname):
588
590
try :
589
591
subprocess .check_output ([patchelf ] + patchelf_args + [fname ])
590
592
except subprocess .CalledProcessError as reason :
591
- print ("warning: failed to call patchelf:" , reason )
593
+ print ("warning: failed to call patchelf:" , reason , file = sys . stderr )
592
594
return
593
595
594
596
def rustc_stamp (self ):
@@ -732,7 +734,7 @@ def build_bootstrap(self, color, verbose_count):
732
734
if "GITHUB_ACTIONS" in env :
733
735
print ("::group::Building bootstrap" )
734
736
else :
735
- print ("Building bootstrap" )
737
+ print ("Building bootstrap" , file = sys . stderr )
736
738
build_dir = os .path .join (self .build_dir , "bootstrap" )
737
739
if self .clean and os .path .exists (build_dir ):
738
740
shutil .rmtree (build_dir )
@@ -826,9 +828,12 @@ def check_vendored_status(self):
826
828
if 'SUDO_USER' in os .environ and not self .use_vendored_sources :
827
829
if os .getuid () == 0 :
828
830
self .use_vendored_sources = True
829
- print ('info: looks like you\' re trying to run this command as root' )
830
- print (' and so in order to preserve your $HOME this will now' )
831
- print (' use vendored sources by default.' )
831
+ print ('info: looks like you\' re trying to run this command as root' ,
832
+ file = sys .stderr )
833
+ print (' and so in order to preserve your $HOME this will now' ,
834
+ file = sys .stderr )
835
+ print (' use vendored sources by default.' ,
836
+ file = sys .stderr )
832
837
833
838
cargo_dir = os .path .join (self .rust_root , '.cargo' )
834
839
if self .use_vendored_sources :
@@ -838,14 +843,18 @@ def check_vendored_status(self):
838
843
"--sync ./src/tools/rust-analyzer/Cargo.toml " \
839
844
"--sync ./compiler/rustc_codegen_cranelift/Cargo.toml " \
840
845
"--sync ./src/bootstrap/Cargo.toml "
841
- print ('error: vendoring required, but vendor directory does not exist.' )
846
+ print ('error: vendoring required, but vendor directory does not exist.' ,
847
+ file = sys .stderr )
842
848
print (' Run `cargo vendor {}` to initialize the '
843
- 'vendor directory.' .format (sync_dirs ))
844
- print ('Alternatively, use the pre-vendored `rustc-src` dist component.' )
849
+ 'vendor directory.' .format (sync_dirs ),
850
+ file = sys .stderr )
851
+ print ('Alternatively, use the pre-vendored `rustc-src` dist component.' ,
852
+ file = sys .stderr )
845
853
raise Exception ("{} not found" .format (vendor_dir ))
846
854
847
855
if not os .path .exists (cargo_dir ):
848
- print ('error: vendoring required, but .cargo/config does not exist.' )
856
+ print ('error: vendoring required, but .cargo/config does not exist.' ,
857
+ file = sys .stderr )
849
858
raise Exception ("{} not found" .format (cargo_dir ))
850
859
else :
851
860
if os .path .exists (cargo_dir ):
@@ -955,7 +964,7 @@ def main():
955
964
print (
956
965
"info: Downloading and building bootstrap before processing --help command.\n "
957
966
" See src/bootstrap/README.md for help with common commands."
958
- )
967
+ , file = sys . stderr )
959
968
960
969
exit_code = 0
961
970
success_word = "successfully"
@@ -966,11 +975,12 @@ def main():
966
975
exit_code = error .code
967
976
else :
968
977
exit_code = 1
969
- print (error )
978
+ print (error , file = sys . stderr )
970
979
success_word = "unsuccessfully"
971
980
972
981
if not help_triggered :
973
- print ("Build completed" , success_word , "in" , format_build_time (time () - start_time ))
982
+ print ("Build completed" , success_word , "in" , format_build_time (time () - start_time ),
983
+ file = sys .stderr )
974
984
sys .exit (exit_code )
975
985
976
986
0 commit comments