From 5cf6b8bdee5d93f3e26a4a682cf517f8c6482120 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 28 Oct 2024 18:22:33 +0300 Subject: [PATCH] force-recompile library changes on download-rustc="if-unchanged" This makes download-rustc="if-unchanged" more functional and useful for library developers. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/compile.rs | 1 - src/bootstrap/src/core/config/config.rs | 37 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index e13d4ccc61824..99ddf58104ce8 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -153,7 +153,6 @@ impl Step for Std { // NOTE: the beta compiler may generate different artifacts than the downloaded compiler, so // its artifacts can't be reused. && compiler.stage != 0 - // This check is specific to testing std itself; see `test::Std` for more details. && !self.force_recompile { let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false }); diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 139ca7eb52e7b..8115aea033d93 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2767,25 +2767,32 @@ impl Config { } }; - let files_to_track = - &["compiler", "library", "src/version", "src/stage0", "src/ci/channel"]; + let mut files_to_track = vec!["compiler", "src/version", "src/stage0", "src/ci/channel"]; + + // In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, ignore + // these changes to speed up the build process for library developers. This provides consistent + // functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"` + // options. + if CiEnv::is_ci() { + files_to_track.push("library"); + } // Look for a version to compare to based on the current commit. // Only commits merged by bors will have CI artifacts. - let commit = match self.last_modified_commit(files_to_track, "download-rustc", if_unchanged) - { - Some(commit) => commit, - None => { - if if_unchanged { - return None; + let commit = + match self.last_modified_commit(&files_to_track, "download-rustc", if_unchanged) { + Some(commit) => commit, + None => { + if if_unchanged { + return None; + } + println!("ERROR: could not find commit hash for downloading rustc"); + println!("HELP: maybe your repository history is too shallow?"); + println!("HELP: consider disabling `download-rustc`"); + println!("HELP: or fetch enough history to include one upstream commit"); + crate::exit!(1); } - println!("ERROR: could not find commit hash for downloading rustc"); - println!("HELP: maybe your repository history is too shallow?"); - println!("HELP: consider disabling `download-rustc`"); - println!("HELP: or fetch enough history to include one upstream commit"); - crate::exit!(1); - } - }; + }; if CiEnv::is_ci() && { let head_sha =