@@ -39,23 +39,23 @@ def get(base, url, path, checksums, verbose=False):
3939 if os .path .exists (path ):
4040 if verify (path , sha256 , False ):
4141 if verbose :
42- print ("using already-download file" , path )
42+ print ("using already-download file" , path , file = sys . stderr )
4343 return
4444 else :
4545 if verbose :
4646 print ("ignoring already-download file" ,
47- path , "due to failed verification" )
47+ path , "due to failed verification" , file = sys . stderr )
4848 os .unlink (path )
4949 download (temp_path , "{}/{}" .format (base , url ), True , verbose )
5050 if not verify (temp_path , sha256 , verbose ):
5151 raise RuntimeError ("failed verification" )
5252 if verbose :
53- print ("moving {} to {}" .format (temp_path , path ))
53+ print ("moving {} to {}" .format (temp_path , path ), file = sys . stderr )
5454 shutil .move (temp_path , path )
5555 finally :
5656 if os .path .isfile (temp_path ):
5757 if verbose :
58- print ("removing" , temp_path )
58+ print ("removing" , temp_path , file = sys . stderr )
5959 os .unlink (temp_path )
6060
6161
@@ -65,7 +65,7 @@ def download(path, url, probably_big, verbose):
6565 _download (path , url , probably_big , verbose , True )
6666 return
6767 except RuntimeError :
68- print ("\n spurious failure, trying again" )
68+ print ("\n spurious failure, trying again" , file = sys . stderr )
6969 _download (path , url , probably_big , verbose , False )
7070
7171
@@ -76,7 +76,7 @@ def _download(path, url, probably_big, verbose, exception):
7676 # - If we are on win32 fallback to powershell
7777 # - Otherwise raise the error if appropriate
7878 if probably_big or verbose :
79- print ("downloading {}" .format (url ))
79+ print ("downloading {}" .format (url ), file = sys . stderr )
8080
8181 platform_is_win32 = sys .platform == 'win32'
8282 try :
@@ -113,20 +113,20 @@ def _download(path, url, probably_big, verbose, exception):
113113def verify (path , expected , verbose ):
114114 """Check if the sha256 sum of the given path is valid"""
115115 if verbose :
116- print ("verifying" , path )
116+ print ("verifying" , path , file = sys . stderr )
117117 with open (path , "rb" ) as source :
118118 found = hashlib .sha256 (source .read ()).hexdigest ()
119119 verified = found == expected
120120 if not verified :
121121 print ("invalid checksum:\n "
122122 " found: {}\n "
123- " expected: {}" .format (found , expected ))
123+ " expected: {}" .format (found , expected ), file = sys . stderr )
124124 return verified
125125
126126
127127def unpack (tarball , tarball_suffix , dst , verbose = False , match = None ):
128128 """Unpack the given tarball file"""
129- print ("extracting" , tarball )
129+ print ("extracting" , tarball , file = sys . stderr )
130130 fname = os .path .basename (tarball ).replace (tarball_suffix , "" )
131131 with contextlib .closing (tarfile .open (tarball )) as tar :
132132 for member in tar .getnames ():
@@ -139,7 +139,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
139139
140140 dst_path = os .path .join (dst , name )
141141 if verbose :
142- print (" extracting" , member )
142+ print (" extracting" , member , file = sys . stderr )
143143 tar .extract (member , dst )
144144 src_path = os .path .join (dst , member )
145145 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):
151151def run (args , verbose = False , exception = False , is_bootstrap = False , ** kwargs ):
152152 """Run a child program in a new process"""
153153 if verbose :
154- print ("running: " + ' ' .join (args ))
154+ print ("running: " + ' ' .join (args ), file = sys . stderr )
155155 sys .stdout .flush ()
156156 # Ensure that the .exe is used on Windows just in case a Linux ELF has been
157157 # compiled in the same directory.
@@ -187,8 +187,8 @@ def require(cmd, exit=True, exception=False):
187187 if exception :
188188 raise
189189 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 )
192192 sys .exit (1 )
193193 return None
194194
@@ -212,8 +212,8 @@ def default_build_triple(verbose):
212212
213213 if sys .platform == 'darwin' :
214214 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 )
217217 else :
218218 try :
219219 version = subprocess .check_output (["rustc" , "--version" , "--verbose" ],
@@ -222,12 +222,14 @@ def default_build_triple(verbose):
222222 host = next (x for x in version .split ('\n ' ) if x .startswith ("host: " ))
223223 triple = host .split ("host: " )[1 ]
224224 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 )
226227 return triple
227228 except Exception as e :
228229 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 )
231233
232234 required = sys .platform != 'win32'
233235 ostype = require (["uname" , "-s" ], exit = required )
@@ -522,7 +524,7 @@ def get_answer():
522524
523525 answer = self ._should_fix_bins_and_dylibs = get_answer ()
524526 if answer :
525- print ("info: You seem to be using Nix." )
527+ print ("info: You seem to be using Nix." , file = sys . stderr )
526528 return answer
527529
528530 def fix_bin_or_dylib (self , fname ):
@@ -535,7 +537,7 @@ def fix_bin_or_dylib(self, fname):
535537 Please see https://nixos.org/patchelf.html for more information
536538 """
537539 assert self ._should_fix_bins_and_dylibs is True
538- print ("attempting to patch" , fname )
540+ print ("attempting to patch" , fname , file = sys . stderr )
539541
540542 # Only build `.nix-deps` once.
541543 nix_deps_dir = self .nix_deps_dir
@@ -568,7 +570,7 @@ def fix_bin_or_dylib(self, fname):
568570 "nix-build" , "-E" , nix_expr , "-o" , nix_deps_dir ,
569571 ])
570572 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 )
572574 return
573575 self .nix_deps_dir = nix_deps_dir
574576
@@ -588,7 +590,7 @@ def fix_bin_or_dylib(self, fname):
588590 try :
589591 subprocess .check_output ([patchelf ] + patchelf_args + [fname ])
590592 except subprocess .CalledProcessError as reason :
591- print ("warning: failed to call patchelf:" , reason )
593+ print ("warning: failed to call patchelf:" , reason , file = sys . stderr )
592594 return
593595
594596 def rustc_stamp (self ):
@@ -732,7 +734,7 @@ def build_bootstrap(self, color, verbose_count):
732734 if "GITHUB_ACTIONS" in env :
733735 print ("::group::Building bootstrap" )
734736 else :
735- print ("Building bootstrap" )
737+ print ("Building bootstrap" , file = sys . stderr )
736738 build_dir = os .path .join (self .build_dir , "bootstrap" )
737739 if self .clean and os .path .exists (build_dir ):
738740 shutil .rmtree (build_dir )
@@ -826,9 +828,12 @@ def check_vendored_status(self):
826828 if 'SUDO_USER' in os .environ and not self .use_vendored_sources :
827829 if os .getuid () == 0 :
828830 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 )
832837
833838 cargo_dir = os .path .join (self .rust_root , '.cargo' )
834839 if self .use_vendored_sources :
@@ -838,14 +843,18 @@ def check_vendored_status(self):
838843 "--sync ./src/tools/rust-analyzer/Cargo.toml " \
839844 "--sync ./compiler/rustc_codegen_cranelift/Cargo.toml " \
840845 "--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 )
842848 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 )
845853 raise Exception ("{} not found" .format (vendor_dir ))
846854
847855 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 )
849858 raise Exception ("{} not found" .format (cargo_dir ))
850859 else :
851860 if os .path .exists (cargo_dir ):
@@ -955,7 +964,7 @@ def main():
955964 print (
956965 "info: Downloading and building bootstrap before processing --help command.\n "
957966 " See src/bootstrap/README.md for help with common commands."
958- )
967+ , file = sys . stderr )
959968
960969 exit_code = 0
961970 success_word = "successfully"
@@ -966,11 +975,12 @@ def main():
966975 exit_code = error .code
967976 else :
968977 exit_code = 1
969- print (error )
978+ print (error , file = sys . stderr )
970979 success_word = "unsuccessfully"
971980
972981 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 )
974984 sys .exit (exit_code )
975985
976986
0 commit comments