bootstrap/utils/
change_tracker.rs

1//! This module facilitates the tracking system for major changes made to the bootstrap,
2//! with the goal of keeping developers synchronized with important modifications in
3//! the bootstrap.
4
5use std::fmt::Display;
6
7#[cfg(test)]
8mod tests;
9
10#[derive(Clone, Debug)]
11pub struct ChangeInfo {
12    /// Represents the ID of PR caused major change on bootstrap.
13    pub change_id: usize,
14    pub severity: ChangeSeverity,
15    /// Provides a short summary of the change that will guide developers
16    /// on "how to handle/behave" in response to the changes.
17    pub summary: &'static str,
18}
19
20#[derive(Clone, Debug)]
21pub enum ChangeSeverity {
22    /// Used when build configurations continue working as before.
23    Info,
24    /// Used when the default value of an option changes, or support for an option is removed entirely,
25    /// potentially requiring developers to update their build configurations.
26    Warning,
27}
28
29impl Display for ChangeSeverity {
30    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31        match self {
32            ChangeSeverity::Info => write!(f, "INFO"),
33            ChangeSeverity::Warning => write!(f, "WARNING"),
34        }
35    }
36}
37
38pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
39    if !CONFIG_CHANGE_HISTORY.iter().any(|config| config.change_id == current_id) {
40        // If the current change-id is greater than the most recent one, return
41        // an empty list (it may be due to switching from a recent branch to an
42        // older one); otherwise, return the full list (assuming the user provided
43        // the incorrect change-id by accident).
44        if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id) {
45            if current_id > config.change_id {
46                return Vec::new();
47            }
48        }
49
50        return CONFIG_CHANGE_HISTORY.to_vec();
51    }
52
53    let index =
54        CONFIG_CHANGE_HISTORY.iter().position(|config| config.change_id == current_id).unwrap();
55
56    CONFIG_CHANGE_HISTORY
57        .iter()
58        .skip(index + 1) // Skip the current_id and IDs before it
59        .cloned()
60        .collect()
61}
62
63pub fn human_readable_changes(changes: &[ChangeInfo]) -> String {
64    let mut message = String::new();
65
66    for change in changes {
67        message.push_str(&format!("  [{}] {}\n", change.severity, change.summary));
68        message.push_str(&format!(
69            "    - PR Link https://github.com/rust-lang/rust/pull/{}\n",
70            change.change_id
71        ));
72    }
73
74    message
75}
76
77/// Keeps track of major changes made to the bootstrap configuration.
78///
79/// If you make any major changes (such as adding new values or changing default values),
80/// please ensure adding `ChangeInfo` to the end(because the list must be sorted by the merge date)
81/// of this list.
82pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
83    ChangeInfo {
84        change_id: 115898,
85        severity: ChangeSeverity::Info,
86        summary: "Implementation of this change-tracking system. Ignore this.",
87    },
88    ChangeInfo {
89        change_id: 116998,
90        severity: ChangeSeverity::Info,
91        summary: "Removed android-ndk r15 support in favor of android-ndk r25b.",
92    },
93    ChangeInfo {
94        change_id: 117435,
95        severity: ChangeSeverity::Info,
96        summary: "New option `rust.parallel-compiler` added to config.toml.",
97    },
98    ChangeInfo {
99        change_id: 116881,
100        severity: ChangeSeverity::Warning,
101        summary: "Default value of `download-ci-llvm` was changed for `codegen` profile.",
102    },
103    ChangeInfo {
104        change_id: 117813,
105        severity: ChangeSeverity::Info,
106        summary: "Use of the `if-available` value for `download-ci-llvm` is deprecated; prefer using the new `if-unchanged` value.",
107    },
108    ChangeInfo {
109        change_id: 116278,
110        severity: ChangeSeverity::Info,
111        summary: "The `rust.use-lld` configuration now has different options ('external'/true or 'self-contained'), and its behaviour has changed.",
112    },
113    ChangeInfo {
114        change_id: 118703,
115        severity: ChangeSeverity::Info,
116        summary: "Removed rust.run_dsymutil and dist.gpg_password_file config options, as they were unused.",
117    },
118    ChangeInfo {
119        change_id: 119124,
120        severity: ChangeSeverity::Warning,
121        summary: "rust-analyzer-proc-macro-srv is no longer enabled by default. To build it, you must either enable it in the configuration or explicitly invoke it with x.py.",
122    },
123    ChangeInfo {
124        change_id: 119373,
125        severity: ChangeSeverity::Info,
126        summary: "The dist.missing-tools config option was deprecated, as it was unused. If you are using it, remove it from your config, it will be removed soon.",
127    },
128    ChangeInfo {
129        change_id: 102579,
130        severity: ChangeSeverity::Warning,
131        summary: "A new `optimized-compiler-builtins` option has been introduced. Whether to build llvm's `compiler-rt` from source is no longer implicitly controlled by git state. See the PR for more details.",
132    },
133    ChangeInfo {
134        change_id: 120348,
135        severity: ChangeSeverity::Info,
136        summary: "New option `target.<triple>.codegen-backends` added to config.toml.",
137    },
138    ChangeInfo {
139        change_id: 121203,
140        severity: ChangeSeverity::Info,
141        summary: "A new `rust.frame-pointers` option has been introduced and made the default in the compiler and codegen profiles.",
142    },
143    ChangeInfo {
144        change_id: 121278,
145        severity: ChangeSeverity::Warning,
146        summary: "The \"codegen\"/\"llvm\" profile has been removed and replaced with \"compiler\", use it instead for the same behavior.",
147    },
148    ChangeInfo {
149        change_id: 118724,
150        severity: ChangeSeverity::Info,
151        summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.",
152    },
153    ChangeInfo {
154        change_id: 121976,
155        severity: ChangeSeverity::Info,
156        summary: "A new `boostrap-cache-path` option has been introduced which can be utilized to modify the cache path for bootstrap.",
157    },
158    ChangeInfo {
159        change_id: 122108,
160        severity: ChangeSeverity::Info,
161        summary: "a new `target.*.runner` option is available to specify a wrapper executable required to run tests for a target",
162    },
163    ChangeInfo {
164        change_id: 117458,
165        severity: ChangeSeverity::Info,
166        summary: "New option `rust.llvm-bitcode-linker` that will build the llvm-bitcode-linker.",
167    },
168    ChangeInfo {
169        change_id: 121754,
170        severity: ChangeSeverity::Warning,
171        summary: "`rust.split-debuginfo` has been moved to `target.<triple>.split-debuginfo` and its default value is determined for each target individually.",
172    },
173    ChangeInfo {
174        change_id: 123711,
175        severity: ChangeSeverity::Warning,
176        summary: "The deprecated field `changelog-seen` has been removed. Using that field in `config.toml` from now on will result in breakage.",
177    },
178    ChangeInfo {
179        change_id: 124501,
180        severity: ChangeSeverity::Info,
181        summary: "New option `build.lldb` that will override the default lldb binary path used in debuginfo tests",
182    },
183    ChangeInfo {
184        change_id: 123337,
185        severity: ChangeSeverity::Info,
186        summary: r#"The compiler profile now defaults to rust.debuginfo-level = "line-tables-only""#,
187    },
188    ChangeInfo {
189        change_id: 124129,
190        severity: ChangeSeverity::Warning,
191        summary: "`rust.lld` has a new default value of `true` on `x86_64-unknown-linux-gnu`. Starting at stage1, `rust-lld` will thus be this target's default linker. No config changes should be necessary.",
192    },
193    ChangeInfo {
194        change_id: 125535,
195        severity: ChangeSeverity::Warning,
196        summary: "Removed `dist.missing-tools` configuration as it was deprecated long time ago.",
197    },
198    ChangeInfo {
199        change_id: 126701,
200        severity: ChangeSeverity::Warning,
201        summary: "`llvm.lld` is enabled by default for the dist profile. If set to false, `lld` will not be included in the dist build.",
202    },
203    ChangeInfo {
204        change_id: 127913,
205        severity: ChangeSeverity::Warning,
206        summary: "`debug-logging` option has been removed from the default `tools` profile.",
207    },
208    ChangeInfo {
209        change_id: 127866,
210        severity: ChangeSeverity::Info,
211        summary: "the `wasm-component-ld` tool is now built as part of `build.extended` and can be a member of `build.tools`",
212    },
213    ChangeInfo {
214        change_id: 120593,
215        severity: ChangeSeverity::Info,
216        summary: "Removed android-ndk r25b support in favor of android-ndk r26d.",
217    },
218    ChangeInfo {
219        change_id: 125181,
220        severity: ChangeSeverity::Warning,
221        summary: "For tarball sources, default value for `rust.channel` will be taken from `src/ci/channel` file.",
222    },
223    ChangeInfo {
224        change_id: 125642,
225        severity: ChangeSeverity::Info,
226        summary: "New option `llvm.libzstd` to control whether llvm is built with zstd support.",
227    },
228    ChangeInfo {
229        change_id: 128841,
230        severity: ChangeSeverity::Warning,
231        summary: "./x test --rustc-args was renamed to --compiletest-rustc-args as it only applies there. ./x miri --rustc-args was also removed.",
232    },
233    ChangeInfo {
234        change_id: 129295,
235        severity: ChangeSeverity::Info,
236        summary: "The `build.profiler` option now tries to use source code from `download-ci-llvm` if possible, instead of checking out the `src/llvm-project` submodule.",
237    },
238    ChangeInfo {
239        change_id: 129152,
240        severity: ChangeSeverity::Info,
241        summary: "New option `build.cargo-clippy` added for supporting the use of custom/external clippy.",
242    },
243    ChangeInfo {
244        change_id: 129925,
245        severity: ChangeSeverity::Warning,
246        summary: "Removed `rust.split-debuginfo` as it was deprecated long time ago.",
247    },
248    ChangeInfo {
249        change_id: 129176,
250        severity: ChangeSeverity::Info,
251        summary: "New option `llvm.enzyme` to control whether the llvm based autodiff tool (Enzyme) is built.",
252    },
253    ChangeInfo {
254        change_id: 129473,
255        severity: ChangeSeverity::Warning,
256        summary: "`download-ci-llvm = true` now checks if CI llvm is available and has become the default for the compiler profile",
257    },
258    ChangeInfo {
259        change_id: 130202,
260        severity: ChangeSeverity::Info,
261        summary: "'tools' and 'library' profiles switched `download-ci-llvm` option from `if-unchanged` to `true`.",
262    },
263    ChangeInfo {
264        change_id: 130110,
265        severity: ChangeSeverity::Info,
266        summary: "New option `dist.vendor` added to control whether bootstrap should vendor dependencies for dist tarball.",
267    },
268    ChangeInfo {
269        change_id: 130529,
270        severity: ChangeSeverity::Info,
271        summary: "If `llvm.download-ci-llvm` is not defined, it defaults to `true`.",
272    },
273    ChangeInfo {
274        change_id: 131075,
275        severity: ChangeSeverity::Info,
276        summary: "New option `./x setup editor` added, replacing `./x setup vscode` and adding support for vim, emacs and helix.",
277    },
278    ChangeInfo {
279        change_id: 131838,
280        severity: ChangeSeverity::Info,
281        summary: "Allow setting `--jobs` in config.toml with `build.jobs`.",
282    },
283    ChangeInfo {
284        change_id: 131181,
285        severity: ChangeSeverity::Info,
286        summary: "New option `build.compiletest-diff-tool` that adds support for a custom differ for compiletest",
287    },
288    ChangeInfo {
289        change_id: 131513,
290        severity: ChangeSeverity::Info,
291        summary: "New option `llvm.offload` to control whether the llvm offload runtime for GPU support is built. Implicitly enables the openmp runtime as dependency.",
292    },
293    ChangeInfo {
294        change_id: 132282,
295        severity: ChangeSeverity::Warning,
296        summary: "Deprecated `rust.parallel_compiler` as the compiler now always defaults to being parallel (with 1 thread)",
297    },
298    ChangeInfo {
299        change_id: 132494,
300        severity: ChangeSeverity::Info,
301        summary: "`download-rustc='if-unchanged'` is now a default option for library profile.",
302    },
303    ChangeInfo {
304        change_id: 133207,
305        severity: ChangeSeverity::Info,
306        summary: "`rust.llvm-tools` is now enabled by default when no `config.toml` is provided.",
307    },
308    ChangeInfo {
309        change_id: 133068,
310        severity: ChangeSeverity::Warning,
311        summary: "Revert `rust.download-rustc` global default to `false` and only use `rust.download-rustc = \"if-unchanged\"` default for library and tools profile. As alt CI rustc is built without debug assertions, `rust.debug-assertions = true` will now inhibit downloading CI rustc.",
312    },
313    ChangeInfo {
314        change_id: 133853,
315        severity: ChangeSeverity::Info,
316        summary: "`build.vendor` is now enabled by default for dist/tarball sources when 'vendor' directory and '.cargo/config.toml' file are present.",
317    },
318    ChangeInfo {
319        change_id: 134809,
320        severity: ChangeSeverity::Warning,
321        summary: "compiletest now takes `--no-capture` instead of `--nocapture`; bootstrap now accepts `--no-capture` as an argument to test commands directly",
322    },
323    ChangeInfo {
324        change_id: 134650,
325        severity: ChangeSeverity::Warning,
326        summary: "Removed `rust.parallel-compiler` as it was deprecated in #132282 long time ago.",
327    },
328    ChangeInfo {
329        change_id: 135326,
330        severity: ChangeSeverity::Warning,
331        summary: "It is now possible to configure `optimized-compiler-builtins` for per target.",
332    },
333    ChangeInfo {
334        change_id: 135281,
335        severity: ChangeSeverity::Warning,
336        summary: "Some stamp names in the build artifacts may have changed slightly (e.g., from `llvm-finished-building` to `.llvm-stamp`).",
337    },
338    ChangeInfo {
339        change_id: 135729,
340        severity: ChangeSeverity::Info,
341        summary: "Change the compiler profile to default to rust.debug-assertions = true",
342    },
343    ChangeInfo {
344        change_id: 135832,
345        severity: ChangeSeverity::Info,
346        summary: "Rustdoc now respects the value of rust.lto.",
347    },
348    ChangeInfo {
349        change_id: 136941,
350        severity: ChangeSeverity::Info,
351        summary: "The llvm.ccache option has moved to build.ccache. llvm.ccache is now deprecated.",
352    },
353];