authorbors <bors@rust-lang.org> 2025-06-11 14:49:22 UTC
committerbors <bors@rust-lang.org> 2025-06-11 14:49:22 UTC
logf77bb1b294a30efb73ff4845946a3aad0950cb83
treedf49f5b42bfeb97bcd873885352775097d3fb08c
parentbdb04d6c4fff0970bc2f1fad775bec807d9470ee
parent3a33dd6194c3b11e0f9d4bf41f70668aabdc80ec

Auto merge of #142344 - Kobzol:revert-142232, r=RalfJung

Revert "add `Cargo.lock` to CI-rustc allowed list for non-CI env" This reverts commit c3de813944873940b8e1a7734991f3c9f3f55156 (https://github.com/rust-lang/rust/pull/142232). r? `@RalfJung` Fixes: https://github.com/rust-lang/rust/issues/142338 Unfixes: https://github.com/rust-lang/rust/issues/141986

2 files changed, 21 insertions(+), 34 deletions(-)

src/bootstrap/src/core/config/config.rs+19-32
......@@ -52,39 +52,26 @@ use crate::utils::execution_context::ExecutionContext;
5252use crate::utils::helpers::exe;
5353use crate::{GitInfo, OnceLock, TargetSelection, check_ci_llvm, helpers, t};
5454
55/// Each path from this function is considered "allowed" in the `download-rustc="if-unchanged"` logic.
55/// Each path in this list is considered "allowed" in the `download-rustc="if-unchanged"` logic.
5656/// This means they can be modified and changes to these paths should never trigger a compiler build
5757/// when "if-unchanged" is set.
58pub fn rustc_if_unchanged_allowed_paths() -> Vec<&'static str> {
59 // NOTE: Paths must have the ":!" prefix to tell git to ignore changes in those paths during
60 // the diff check.
61 //
62 // WARNING: Be cautious when adding paths to this list. If a path that influences the compiler build
63 // is added here, it will cause bootstrap to skip necessary rebuilds, which may lead to risky results.
64 // For example, "src/bootstrap" should never be included in this list as it plays a crucial role in the
65 // final output/compiler, which can be significantly affected by changes made to the bootstrap sources.
66 let mut paths = vec![
67 ":!library",
68 ":!src/tools",
69 ":!src/librustdoc",
70 ":!src/rustdoc-json-types",
71 ":!tests",
72 ":!triagebot.toml",
73 ];
74
75 if !CiEnv::is_ci() {
76 // When a dependency is added/updated/removed in the library tree (or in some tools),
77 // `Cargo.lock` will be updated by `cargo`. This update will incorrectly invalidate the
78 // `download-rustc=if-unchanged` cache.
79 //
80 // To prevent this, add `Cargo.lock` to the list of allowed paths when not running on CI.
81 // This is generally safe because changes to dependencies typically involve modifying
82 // `Cargo.toml`, which would already invalidate the CI-rustc cache on non-allowed paths.
83 paths.push(":!Cargo.lock");
84 }
85
86 paths
87}
58///
59/// NOTE: Paths must have the ":!" prefix to tell git to ignore changes in those paths during
60/// the diff check.
61///
62/// WARNING: Be cautious when adding paths to this list. If a path that influences the compiler build
63/// is added here, it will cause bootstrap to skip necessary rebuilds, which may lead to risky results.
64/// For example, "src/bootstrap" should never be included in this list as it plays a crucial role in the
65/// final output/compiler, which can be significantly affected by changes made to the bootstrap sources.
66#[rustfmt::skip] // We don't want rustfmt to oneline this list
67pub const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[
68 ":!library",
69 ":!src/tools",
70 ":!src/librustdoc",
71 ":!src/rustdoc-json-types",
72 ":!tests",
73 ":!triagebot.toml",
74];
8875
8976/// Global configuration for the entire build and/or bootstrap.
9077///
......@@ -1516,7 +1503,7 @@ impl Config {
15161503 let commit = if self.rust_info.is_managed_git_subrepository() {
15171504 // Look for a version to compare to based on the current commit.
15181505 // Only commits merged by bors will have CI artifacts.
1519 let freshness = self.check_path_modifications(&rustc_if_unchanged_allowed_paths());
1506 let freshness = self.check_path_modifications(RUSTC_IF_UNCHANGED_ALLOWED_PATHS);
15201507 self.verbose(|| {
15211508 eprintln!("rustc freshness: {freshness:?}");
15221509 });
src/bootstrap/src/core/config/tests.rs+2-2
......@@ -11,7 +11,7 @@ use serde::Deserialize;
1111
1212use super::flags::Flags;
1313use super::toml::change_id::ChangeIdWrapper;
14use super::{Config, rustc_if_unchanged_allowed_paths};
14use super::{Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
1515use crate::ChangeId;
1616use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
1717use crate::core::build_steps::llvm;
......@@ -459,7 +459,7 @@ fn jobs_precedence() {
459459#[test]
460460fn check_rustc_if_unchanged_paths() {
461461 let config = parse("");
462 let normalised_allowed_paths: Vec<_> = rustc_if_unchanged_allowed_paths()
462 let normalised_allowed_paths: Vec<_> = RUSTC_IF_UNCHANGED_ALLOWED_PATHS
463463 .iter()
464464 .map(|t| {
465465 t.strip_prefix(":!").expect(&format!("{t} doesn't have ':!' prefix, but it should."))