Skip to content

Commit 335a3c4

Browse files
authored
Rollup merge of #83368 - jyn514:download-if-unchanged, r=Mark-Simulacrum
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. This sets `BOOTSTRAP_DOWNLOAD_RUSTC` in bootstrap.py so rustbuild doesn't have to try and replicate its logic. Helps with #81930. r? `@Mark-Simulacrum` cc `@camelid`
2 parents 39eee17 + 580a740 commit 335a3c4

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

config.toml.example

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

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

src/bootstrap/bootstrap.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,10 @@ def fix_bin_or_dylib(self, fname, rpath_libz=False):
644644
# If `download-rustc` is set, download the most recent commit with CI artifacts
645645
def maybe_download_ci_toolchain(self):
646646
# If `download-rustc` is not set, default to rebuilding.
647-
if self.get_toml("download-rustc", section="rust") != "true":
647+
download_rustc = self.get_toml("download-rustc", section="rust")
648+
if download_rustc is None or download_rustc == "false":
648649
return None
650+
assert download_rustc == "true" or download_rustc == "if-unchanged", download_rustc
649651

650652
# Handle running from a directory other than the top level
651653
rev_parse = ["git", "rev-parse", "--show-toplevel"]
@@ -660,6 +662,8 @@ def maybe_download_ci_toolchain(self):
660662
# Warn if there were changes to the compiler since the ancestor commit.
661663
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler])
662664
if status != 0:
665+
if download_rustc == "if-unchanged":
666+
return None
663667
print("warning: `download-rustc` is enabled, but there are changes to compiler/")
664668

665669
if self.verbose:
@@ -1175,6 +1179,8 @@ def bootstrap(help_triggered):
11751179
env["RUSTC_BOOTSTRAP"] = '1'
11761180
if toml_path:
11771181
env["BOOTSTRAP_CONFIG"] = toml_path
1182+
if build.rustc_commit is not None:
1183+
env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1'
11781184
run(args, env=env, verbose=build.verbose)
11791185

11801186

src/bootstrap/config.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ struct Rust {
510510
new_symbol_mangling: Option<bool>,
511511
profile_generate: Option<String>,
512512
profile_use: Option<String>,
513-
download_rustc: Option<bool>,
513+
// ignored; this is set from an env var set by bootstrap.py
514+
download_rustc: Option<StringOrBool>,
514515
}
515516

516517
/// TOML representation of how each build target is configured.
@@ -852,7 +853,7 @@ impl Config {
852853
config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config);
853854
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
854855
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
855-
config.download_rustc = rust.download_rustc.unwrap_or(false);
856+
config.download_rustc = env::var("BOOTSTRAP_DOWNLOAD_RUSTC").as_deref() == Ok("1");
856857
} else {
857858
config.rust_profile_use = flags.rust_profile_use;
858859
config.rust_profile_generate = flags.rust_profile_generate;

0 commit comments

Comments
 (0)