@@ -638,8 +638,10 @@ def fix_bin_or_dylib(self, fname, rpath_libz=False):
638
638
# Return the stage1 compiler to download, if any.
639
639
def maybe_download_rustc (self ):
640
640
# If `download-rustc` is not set, default to rebuilding.
641
- if self .get_toml ("download-rustc" , section = "rust" ) != "true" :
641
+ download_rustc = self .get_toml ("download-rustc" , section = "rust" )
642
+ if download_rustc is None or download_rustc == "false" :
642
643
return None
644
+ assert download_rustc == "true" or download_rustc == "if-unchanged" , download_rustc
643
645
644
646
# Handle running from a directory other than the top level
645
647
rev_parse = ["git" , "rev-parse" , "--show-toplevel" ]
@@ -654,6 +656,8 @@ def maybe_download_rustc(self):
654
656
# Warn if there were changes to the compiler since the ancestor commit.
655
657
status = subprocess .call (["git" , "diff-index" , "--quiet" , commit , "--" , compiler ])
656
658
if status != 0 :
659
+ if download_rustc == "if-unchanged" :
660
+ return None
657
661
print ("warning: `download-rustc` is enabled, but there are changes to compiler/" )
658
662
659
663
return commit
@@ -1158,6 +1162,8 @@ def bootstrap(help_triggered):
1158
1162
env ["RUSTC_BOOTSTRAP" ] = '1'
1159
1163
if toml_path :
1160
1164
env ["BOOTSTRAP_CONFIG" ] = toml_path
1165
+ if build .rustc_commit is not None :
1166
+ env ["BOOTSTRAP_DOWNLOAD_RUSTC" ] = '1'
1161
1167
run (args , env = env , verbose = build .verbose )
1162
1168
1163
1169
0 commit comments