Skip to content

Commit 3a33dd6

Browse files
committed
Revert "add Cargo.lock to CI-rustc allowed list for non-CI env"
This reverts commit c3de813.
1 parent 2b0274c commit 3a33dd6

File tree

2 files changed

+21
-34
lines changed

2 files changed

+21
-34
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,39 +52,26 @@ use crate::utils::execution_context::ExecutionContext;
5252
use crate::utils::helpers::exe;
5353
use 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.
58-
pub 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
67+
pub 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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use serde::Deserialize;
1111

1212
use super::flags::Flags;
1313
use super::toml::change_id::ChangeIdWrapper;
14-
use super::{Config, rustc_if_unchanged_allowed_paths};
14+
use super::{Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
1515
use crate::ChangeId;
1616
use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
1717
use crate::core::build_steps::llvm;
@@ -459,7 +459,7 @@ fn jobs_precedence() {
459459
#[test]
460460
fn 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."))

0 commit comments

Comments
 (0)