@@ -42,23 +42,23 @@ def get(base, url, path, checksums, verbose=False):
42
42
if os .path .exists (path ):
43
43
if verify (path , sha256 , False ):
44
44
if verbose :
45
- print ("using already-download file" , path )
45
+ print ("using already-download file" , path , file = sys . stderr )
46
46
return
47
47
else :
48
48
if verbose :
49
49
print ("ignoring already-download file" ,
50
- path , "due to failed verification" )
50
+ path , "due to failed verification" , file = sys . stderr )
51
51
os .unlink (path )
52
52
download (temp_path , "{}/{}" .format (base , url ), True , verbose )
53
53
if not verify (temp_path , sha256 , verbose ):
54
54
raise RuntimeError ("failed verification" )
55
55
if verbose :
56
- print ("moving {} to {}" .format (temp_path , path ))
56
+ print ("moving {} to {}" .format (temp_path , path ), file = sys . stderr )
57
57
shutil .move (temp_path , path )
58
58
finally :
59
59
if os .path .isfile (temp_path ):
60
60
if verbose :
61
- print ("removing" , temp_path )
61
+ print ("removing" , temp_path , file = sys . stderr )
62
62
os .unlink (temp_path )
63
63
64
64
@@ -68,7 +68,7 @@ def download(path, url, probably_big, verbose):
68
68
_download (path , url , probably_big , verbose , True )
69
69
return
70
70
except RuntimeError :
71
- print ("\n spurious failure, trying again" )
71
+ print ("\n spurious failure, trying again" , file = sys . stderr )
72
72
_download (path , url , probably_big , verbose , False )
73
73
74
74
@@ -79,7 +79,7 @@ def _download(path, url, probably_big, verbose, exception):
79
79
# - If we are on win32 fallback to powershell
80
80
# - Otherwise raise the error if appropriate
81
81
if probably_big or verbose :
82
- print ("downloading {}" .format (url ))
82
+ print ("downloading {}" .format (url ), file = sys . stderr )
83
83
84
84
try :
85
85
if probably_big or verbose :
@@ -115,20 +115,20 @@ def _download(path, url, probably_big, verbose, exception):
115
115
def verify (path , expected , verbose ):
116
116
"""Check if the sha256 sum of the given path is valid"""
117
117
if verbose :
118
- print ("verifying" , path )
118
+ print ("verifying" , path , file = sys . stderr )
119
119
with open (path , "rb" ) as source :
120
120
found = hashlib .sha256 (source .read ()).hexdigest ()
121
121
verified = found == expected
122
122
if not verified :
123
123
print ("invalid checksum:\n "
124
124
" found: {}\n "
125
- " expected: {}" .format (found , expected ))
125
+ " expected: {}" .format (found , expected ), file = sys . stderr )
126
126
return verified
127
127
128
128
129
129
def unpack (tarball , tarball_suffix , dst , verbose = False , match = None ):
130
130
"""Unpack the given tarball file"""
131
- print ("extracting" , tarball )
131
+ print ("extracting" , tarball , file = sys . stderr )
132
132
fname = os .path .basename (tarball ).replace (tarball_suffix , "" )
133
133
with contextlib .closing (tarfile .open (tarball )) as tar :
134
134
for member in tar .getnames ():
@@ -141,7 +141,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
141
141
142
142
dst_path = os .path .join (dst , name )
143
143
if verbose :
144
- print (" extracting" , member )
144
+ print (" extracting" , member , file = sys . stderr )
145
145
tar .extract (member , dst )
146
146
src_path = os .path .join (dst , member )
147
147
if os .path .isdir (src_path ) and os .path .exists (dst_path ):
@@ -153,7 +153,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
153
153
def run (args , verbose = False , exception = False , is_bootstrap = False , ** kwargs ):
154
154
"""Run a child program in a new process"""
155
155
if verbose :
156
- print ("running: " + ' ' .join (args ))
156
+ print ("running: " + ' ' .join (args ), file = sys . stderr )
157
157
sys .stdout .flush ()
158
158
# Ensure that the .exe is used on Windows just in case a Linux ELF has been
159
159
# compiled in the same directory.
@@ -193,8 +193,8 @@ def require(cmd, exit=True, exception=False):
193
193
if exception :
194
194
raise
195
195
elif exit :
196
- print ("error: unable to run `{}`: {}" .format (' ' .join (cmd ), exc ))
197
- print ("Please make sure it's installed and in the path." )
196
+ print ("error: unable to run `{}`: {}" .format (' ' .join (cmd ), exc ), file = sys . stderr )
197
+ print ("Please make sure it's installed and in the path." , file = sys . stderr )
198
198
sys .exit (1 )
199
199
return None
200
200
@@ -218,8 +218,8 @@ def default_build_triple(verbose):
218
218
219
219
if sys .platform == 'darwin' :
220
220
if verbose :
221
- print ("not using rustc detection as it is unreliable on macOS" )
222
- print ("falling back to auto-detect" )
221
+ print ("not using rustc detection as it is unreliable on macOS" , file = sys . stderr )
222
+ print ("falling back to auto-detect" , file = sys . stderr )
223
223
else :
224
224
try :
225
225
version = subprocess .check_output (["rustc" , "--version" , "--verbose" ],
@@ -228,12 +228,14 @@ def default_build_triple(verbose):
228
228
host = next (x for x in version .split ('\n ' ) if x .startswith ("host: " ))
229
229
triple = host .split ("host: " )[1 ]
230
230
if verbose :
231
- print ("detected default triple {} from pre-installed rustc" .format (triple ))
231
+ print ("detected default triple {} from pre-installed rustc" .format (triple ),
232
+ file = sys .stderr )
232
233
return triple
233
234
except Exception as e :
234
235
if verbose :
235
- print ("pre-installed rustc not detected: {}" .format (e ))
236
- print ("falling back to auto-detect" )
236
+ print ("pre-installed rustc not detected: {}" .format (e ),
237
+ file = sys .stderr )
238
+ print ("falling back to auto-detect" , file = sys .stderr )
237
239
238
240
required = not platform_is_win32 ()
239
241
ostype = require (["uname" , "-s" ], exit = required )
@@ -545,7 +547,7 @@ def get_answer():
545
547
546
548
answer = self ._should_fix_bins_and_dylibs = get_answer ()
547
549
if answer :
548
- print ("info: You seem to be using Nix." )
550
+ print ("info: You seem to be using Nix." , file = sys . stderr )
549
551
return answer
550
552
551
553
def fix_bin_or_dylib (self , fname ):
@@ -558,7 +560,7 @@ def fix_bin_or_dylib(self, fname):
558
560
Please see https://nixos.org/patchelf.html for more information
559
561
"""
560
562
assert self ._should_fix_bins_and_dylibs is True
561
- print ("attempting to patch" , fname )
563
+ print ("attempting to patch" , fname , file = sys . stderr )
562
564
563
565
# Only build `.nix-deps` once.
564
566
nix_deps_dir = self .nix_deps_dir
@@ -591,7 +593,7 @@ def fix_bin_or_dylib(self, fname):
591
593
"nix-build" , "-E" , nix_expr , "-o" , nix_deps_dir ,
592
594
])
593
595
except subprocess .CalledProcessError as reason :
594
- print ("warning: failed to call nix-build:" , reason )
596
+ print ("warning: failed to call nix-build:" , reason , file = sys . stderr )
595
597
return
596
598
self .nix_deps_dir = nix_deps_dir
597
599
@@ -611,7 +613,7 @@ def fix_bin_or_dylib(self, fname):
611
613
try :
612
614
subprocess .check_output ([patchelf ] + patchelf_args + [fname ])
613
615
except subprocess .CalledProcessError as reason :
614
- print ("warning: failed to call patchelf:" , reason )
616
+ print ("warning: failed to call patchelf:" , reason , file = sys . stderr )
615
617
return
616
618
617
619
def rustc_stamp (self ):
@@ -755,7 +757,7 @@ def build_bootstrap(self, color, verbose_count):
755
757
if "GITHUB_ACTIONS" in env :
756
758
print ("::group::Building bootstrap" )
757
759
else :
758
- print ("Building bootstrap" )
760
+ print ("Building bootstrap" , file = sys . stderr )
759
761
build_dir = os .path .join (self .build_dir , "bootstrap" )
760
762
if self .clean and os .path .exists (build_dir ):
761
763
shutil .rmtree (build_dir )
@@ -849,9 +851,12 @@ def check_vendored_status(self):
849
851
if 'SUDO_USER' in os .environ and not self .use_vendored_sources :
850
852
if os .getuid () == 0 :
851
853
self .use_vendored_sources = True
852
- print ('info: looks like you\' re trying to run this command as root' )
853
- print (' and so in order to preserve your $HOME this will now' )
854
- print (' use vendored sources by default.' )
854
+ print ('info: looks like you\' re trying to run this command as root' ,
855
+ file = sys .stderr )
856
+ print (' and so in order to preserve your $HOME this will now' ,
857
+ file = sys .stderr )
858
+ print (' use vendored sources by default.' ,
859
+ file = sys .stderr )
855
860
856
861
cargo_dir = os .path .join (self .rust_root , '.cargo' )
857
862
if self .use_vendored_sources :
@@ -861,14 +866,18 @@ def check_vendored_status(self):
861
866
"--sync ./src/tools/rust-analyzer/Cargo.toml " \
862
867
"--sync ./compiler/rustc_codegen_cranelift/Cargo.toml " \
863
868
"--sync ./src/bootstrap/Cargo.toml "
864
- print ('error: vendoring required, but vendor directory does not exist.' )
869
+ print ('error: vendoring required, but vendor directory does not exist.' ,
870
+ file = sys .stderr )
865
871
print (' Run `cargo vendor {}` to initialize the '
866
- 'vendor directory.' .format (sync_dirs ))
867
- print ('Alternatively, use the pre-vendored `rustc-src` dist component.' )
872
+ 'vendor directory.' .format (sync_dirs ),
873
+ file = sys .stderr )
874
+ print ('Alternatively, use the pre-vendored `rustc-src` dist component.' ,
875
+ file = sys .stderr )
868
876
raise Exception ("{} not found" .format (vendor_dir ))
869
877
870
878
if not os .path .exists (cargo_dir ):
871
- print ('error: vendoring required, but .cargo/config does not exist.' )
879
+ print ('error: vendoring required, but .cargo/config does not exist.' ,
880
+ file = sys .stderr )
872
881
raise Exception ("{} not found" .format (cargo_dir ))
873
882
else :
874
883
if os .path .exists (cargo_dir ):
@@ -978,7 +987,7 @@ def main():
978
987
print (
979
988
"info: Downloading and building bootstrap before processing --help command.\n "
980
989
" See src/bootstrap/README.md for help with common commands."
981
- )
990
+ , file = sys . stderr )
982
991
983
992
exit_code = 0
984
993
success_word = "successfully"
@@ -989,11 +998,12 @@ def main():
989
998
exit_code = error .code
990
999
else :
991
1000
exit_code = 1
992
- print (error )
1001
+ print (error , file = sys . stderr )
993
1002
success_word = "unsuccessfully"
994
1003
995
1004
if not help_triggered :
996
- print ("Build completed" , success_word , "in" , format_build_time (time () - start_time ))
1005
+ print ("Build completed" , success_word , "in" , format_build_time (time () - start_time ),
1006
+ file = sys .stderr )
997
1007
sys .exit (exit_code )
998
1008
999
1009
0 commit comments