Skip to content

Commit 7f5964a

Browse files
committed
Add download-rustc = "if-unchanged"
This allows keeping the setting to a fixed value without having to toggle it when you want to work on the compiler instead of on tools.
1 parent 3538577 commit 7f5964a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Diff for: config.toml.example

+3-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ changelog-seen = 2
372372
# Whether to download the stage 1 and 2 compilers from CI.
373373
# This is mostly useful for tools; if you have changes to `compiler/` they will be ignored.
374374
#
375-
# FIXME: currently, this also uses the downloaded compiler for stage0, but that causes unnecessary rebuilds.
375+
# You can set this to "if-unchanged" to only download if `compiler/` has not been modified.
376+
#
377+
# FIXME(#82739): currently, this also uses the downloaded compiler for stage0, but that causes unnecessary rebuilds.
376378
#download-rustc = false
377379

378380
# Number of codegen units to use for each compiler invocation. A value of 0

Diff for: src/bootstrap/bootstrap.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,10 @@ def fix_bin_or_dylib(self, fname, rpath_libz=False):
638638
# Return the stage1 compiler to download, if any.
639639
def maybe_download_rustc(self):
640640
# 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":
642643
return None
644+
assert download_rustc == "true" or download_rustc == "if-unchanged", download_rustc
643645

644646
# Handle running from a directory other than the top level
645647
rev_parse = ["git", "rev-parse", "--show-toplevel"]
@@ -654,6 +656,8 @@ def maybe_download_rustc(self):
654656
# Warn if there were changes to the compiler since the ancestor commit.
655657
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler])
656658
if status != 0:
659+
if download_rustc == "if-unchanged":
660+
return None
657661
print("warning: `download-rustc` is enabled, but there are changes to compiler/")
658662

659663
return commit
@@ -1158,6 +1162,8 @@ def bootstrap(help_triggered):
11581162
env["RUSTC_BOOTSTRAP"] = '1'
11591163
if toml_path:
11601164
env["BOOTSTRAP_CONFIG"] = toml_path
1165+
if build.rustc_commit is not None:
1166+
env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1'
11611167
run(args, env=env, verbose=build.verbose)
11621168

11631169

Diff for: src/bootstrap/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ struct Rust {
510510
new_symbol_mangling: Option<bool>,
511511
profile_generate: Option<String>,
512512
profile_use: Option<String>,
513-
download_rustc: Option<bool>,
513+
download_rustc: Option<String>,
514514
}
515515

516516
/// TOML representation of how each build target is configured.
@@ -897,7 +897,7 @@ impl Config {
897897
config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config);
898898
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
899899
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
900-
config.download_rustc = rust.download_rustc.unwrap_or(false);
900+
config.download_rustc = env::var("BOOTSTRAP_DOWNLOAD_RUSTC").as_deref() == Ok("1");
901901
} else {
902902
config.rust_profile_use = flags.rust_profile_use;
903903
config.rust_profile_generate = flags.rust_profile_generate;

0 commit comments

Comments
 (0)