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) -> &'static [ChangeInfo] {
39    if let Some(index) =
40        CONFIG_CHANGE_HISTORY.iter().position(|config| config.change_id == current_id)
41    {
42        // Skip the current_id and IDs before it
43        &CONFIG_CHANGE_HISTORY[index + 1..]
44    } else {
45        // If the current change-id is greater than the most recent one, return
46        // an empty list (it may be due to switching from a recent branch to an
47        // older one); otherwise, return the full list (assuming the user provided
48        // the incorrect change-id by accident).
49        if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id) {
50            if current_id > config.change_id {
51                return &[];
52            }
53        }
54
55        CONFIG_CHANGE_HISTORY
56    }
57}
58
59pub fn human_readable_changes(changes: &[ChangeInfo]) -> String {
60    let mut message = String::new();
61
62    for change in changes {
63        message.push_str(&format!("  [{}] {}\n", change.severity, change.summary));
64        message.push_str(&format!(
65            "    - PR Link https://github.com/rust-lang/rust/pull/{}\n",
66            change.change_id
67        ));
68    }
69
70    message
71}
72
73/// Keeps track of major changes made to the bootstrap configuration.
74///
75/// If you make any major changes (such as adding new values or changing default values),
76/// please ensure adding `ChangeInfo` to the end(because the list must be sorted by the merge date)
77/// of this list.
78pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
79    ChangeInfo {
80        change_id: 115898,
81        severity: ChangeSeverity::Info,
82        summary: "Implementation of this change-tracking system. Ignore this.",
83    },
84    ChangeInfo {
85        change_id: 116998,
86        severity: ChangeSeverity::Info,
87        summary: "Removed android-ndk r15 support in favor of android-ndk r25b.",
88    },
89    ChangeInfo {
90        change_id: 117435,
91        severity: ChangeSeverity::Info,
92        summary: "New option `rust.parallel-compiler` added to config.toml.",
93    },
94    ChangeInfo {
95        change_id: 116881,
96        severity: ChangeSeverity::Warning,
97        summary: "Default value of `download-ci-llvm` was changed for `codegen` profile.",
98    },
99    ChangeInfo {
100        change_id: 117813,
101        severity: ChangeSeverity::Info,
102        summary: "Use of the `if-available` value for `download-ci-llvm` is deprecated; prefer using the new `if-unchanged` value.",
103    },
104    ChangeInfo {
105        change_id: 116278,
106        severity: ChangeSeverity::Info,
107        summary: "The `rust.use-lld` configuration now has different options ('external'/true or 'self-contained'), and its behaviour has changed.",
108    },
109    ChangeInfo {
110        change_id: 118703,
111        severity: ChangeSeverity::Info,
112        summary: "Removed rust.run_dsymutil and dist.gpg_password_file config options, as they were unused.",
113    },
114    ChangeInfo {
115        change_id: 119124,
116        severity: ChangeSeverity::Warning,
117        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.",
118    },
119    ChangeInfo {
120        change_id: 119373,
121        severity: ChangeSeverity::Info,
122        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.",
123    },
124    ChangeInfo {
125        change_id: 102579,
126        severity: ChangeSeverity::Warning,
127        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.",
128    },
129    ChangeInfo {
130        change_id: 120348,
131        severity: ChangeSeverity::Info,
132        summary: "New option `target.<triple>.codegen-backends` added to config.toml.",
133    },
134    ChangeInfo {
135        change_id: 121203,
136        severity: ChangeSeverity::Info,
137        summary: "A new `rust.frame-pointers` option has been introduced and made the default in the compiler and codegen profiles.",
138    },
139    ChangeInfo {
140        change_id: 121278,
141        severity: ChangeSeverity::Warning,
142        summary: "The \"codegen\"/\"llvm\" profile has been removed and replaced with \"compiler\", use it instead for the same behavior.",
143    },
144    ChangeInfo {
145        change_id: 118724,
146        severity: ChangeSeverity::Info,
147        summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.",
148    },
149    ChangeInfo {
150        change_id: 121976,
151        severity: ChangeSeverity::Info,
152        summary: "A new `boostrap-cache-path` option has been introduced which can be utilized to modify the cache path for bootstrap.",
153    },
154    ChangeInfo {
155        change_id: 122108,
156        severity: ChangeSeverity::Info,
157        summary: "a new `target.*.runner` option is available to specify a wrapper executable required to run tests for a target",
158    },
159    ChangeInfo {
160        change_id: 117458,
161        severity: ChangeSeverity::Info,
162        summary: "New option `rust.llvm-bitcode-linker` that will build the llvm-bitcode-linker.",
163    },
164    ChangeInfo {
165        change_id: 121754,
166        severity: ChangeSeverity::Warning,
167        summary: "`rust.split-debuginfo` has been moved to `target.<triple>.split-debuginfo` and its default value is determined for each target individually.",
168    },
169    ChangeInfo {
170        change_id: 123711,
171        severity: ChangeSeverity::Warning,
172        summary: "The deprecated field `changelog-seen` has been removed. Using that field in `config.toml` from now on will result in breakage.",
173    },
174    ChangeInfo {
175        change_id: 124501,
176        severity: ChangeSeverity::Info,
177        summary: "New option `build.lldb` that will override the default lldb binary path used in debuginfo tests",
178    },
179    ChangeInfo {
180        change_id: 123337,
181        severity: ChangeSeverity::Info,
182        summary: r#"The compiler profile now defaults to rust.debuginfo-level = "line-tables-only""#,
183    },
184    ChangeInfo {
185        change_id: 124129,
186        severity: ChangeSeverity::Warning,
187        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.",
188    },
189    ChangeInfo {
190        change_id: 125535,
191        severity: ChangeSeverity::Warning,
192        summary: "Removed `dist.missing-tools` configuration as it was deprecated long time ago.",
193    },
194    ChangeInfo {
195        change_id: 126701,
196        severity: ChangeSeverity::Warning,
197        summary: "`llvm.lld` is enabled by default for the dist profile. If set to false, `lld` will not be included in the dist build.",
198    },
199    ChangeInfo {
200        change_id: 127913,
201        severity: ChangeSeverity::Warning,
202        summary: "`debug-logging` option has been removed from the default `tools` profile.",
203    },
204    ChangeInfo {
205        change_id: 127866,
206        severity: ChangeSeverity::Info,
207        summary: "the `wasm-component-ld` tool is now built as part of `build.extended` and can be a member of `build.tools`",
208    },
209    ChangeInfo {
210        change_id: 120593,
211        severity: ChangeSeverity::Info,
212        summary: "Removed android-ndk r25b support in favor of android-ndk r26d.",
213    },
214    ChangeInfo {
215        change_id: 125181,
216        severity: ChangeSeverity::Warning,
217        summary: "For tarball sources, default value for `rust.channel` will be taken from `src/ci/channel` file.",
218    },
219    ChangeInfo {
220        change_id: 125642,
221        severity: ChangeSeverity::Info,
222        summary: "New option `llvm.libzstd` to control whether llvm is built with zstd support.",
223    },
224    ChangeInfo {
225        change_id: 128841,
226        severity: ChangeSeverity::Warning,
227        summary: "./x test --rustc-args was renamed to --compiletest-rustc-args as it only applies there. ./x miri --rustc-args was also removed.",
228    },
229    ChangeInfo {
230        change_id: 129295,
231        severity: ChangeSeverity::Info,
232        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.",
233    },
234    ChangeInfo {
235        change_id: 129152,
236        severity: ChangeSeverity::Info,
237        summary: "New option `build.cargo-clippy` added for supporting the use of custom/external clippy.",
238    },
239    ChangeInfo {
240        change_id: 129925,
241        severity: ChangeSeverity::Warning,
242        summary: "Removed `rust.split-debuginfo` as it was deprecated long time ago.",
243    },
244    ChangeInfo {
245        change_id: 129176,
246        severity: ChangeSeverity::Info,
247        summary: "New option `llvm.enzyme` to control whether the llvm based autodiff tool (Enzyme) is built.",
248    },
249    ChangeInfo {
250        change_id: 129473,
251        severity: ChangeSeverity::Warning,
252        summary: "`download-ci-llvm = true` now checks if CI llvm is available and has become the default for the compiler profile",
253    },
254    ChangeInfo {
255        change_id: 130202,
256        severity: ChangeSeverity::Info,
257        summary: "'tools' and 'library' profiles switched `download-ci-llvm` option from `if-unchanged` to `true`.",
258    },
259    ChangeInfo {
260        change_id: 130110,
261        severity: ChangeSeverity::Info,
262        summary: "New option `dist.vendor` added to control whether bootstrap should vendor dependencies for dist tarball.",
263    },
264    ChangeInfo {
265        change_id: 130529,
266        severity: ChangeSeverity::Info,
267        summary: "If `llvm.download-ci-llvm` is not defined, it defaults to `true`.",
268    },
269    ChangeInfo {
270        change_id: 131075,
271        severity: ChangeSeverity::Info,
272        summary: "New option `./x setup editor` added, replacing `./x setup vscode` and adding support for vim, emacs and helix.",
273    },
274    ChangeInfo {
275        change_id: 131838,
276        severity: ChangeSeverity::Info,
277        summary: "Allow setting `--jobs` in config.toml with `build.jobs`.",
278    },
279    ChangeInfo {
280        change_id: 131181,
281        severity: ChangeSeverity::Info,
282        summary: "New option `build.compiletest-diff-tool` that adds support for a custom differ for compiletest",
283    },
284    ChangeInfo {
285        change_id: 131513,
286        severity: ChangeSeverity::Info,
287        summary: "New option `llvm.offload` to control whether the llvm offload runtime for GPU support is built. Implicitly enables the openmp runtime as dependency.",
288    },
289    ChangeInfo {
290        change_id: 132282,
291        severity: ChangeSeverity::Warning,
292        summary: "Deprecated `rust.parallel_compiler` as the compiler now always defaults to being parallel (with 1 thread)",
293    },
294    ChangeInfo {
295        change_id: 132494,
296        severity: ChangeSeverity::Info,
297        summary: "`download-rustc='if-unchanged'` is now a default option for library profile.",
298    },
299    ChangeInfo {
300        change_id: 133207,
301        severity: ChangeSeverity::Info,
302        summary: "`rust.llvm-tools` is now enabled by default when no `config.toml` is provided.",
303    },
304    ChangeInfo {
305        change_id: 133068,
306        severity: ChangeSeverity::Warning,
307        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.",
308    },
309    ChangeInfo {
310        change_id: 133853,
311        severity: ChangeSeverity::Info,
312        summary: "`build.vendor` is now enabled by default for dist/tarball sources when 'vendor' directory and '.cargo/config.toml' file are present.",
313    },
314    ChangeInfo {
315        change_id: 134809,
316        severity: ChangeSeverity::Warning,
317        summary: "compiletest now takes `--no-capture` instead of `--nocapture`; bootstrap now accepts `--no-capture` as an argument to test commands directly",
318    },
319    ChangeInfo {
320        change_id: 134650,
321        severity: ChangeSeverity::Warning,
322        summary: "Removed `rust.parallel-compiler` as it was deprecated in #132282 long time ago.",
323    },
324    ChangeInfo {
325        change_id: 135326,
326        severity: ChangeSeverity::Warning,
327        summary: "It is now possible to configure `optimized-compiler-builtins` for per target.",
328    },
329    ChangeInfo {
330        change_id: 135281,
331        severity: ChangeSeverity::Warning,
332        summary: "Some stamp names in the build artifacts may have changed slightly (e.g., from `llvm-finished-building` to `.llvm-stamp`).",
333    },
334    ChangeInfo {
335        change_id: 135729,
336        severity: ChangeSeverity::Info,
337        summary: "Change the compiler profile to default to rust.debug-assertions = true",
338    },
339    ChangeInfo {
340        change_id: 135832,
341        severity: ChangeSeverity::Info,
342        summary: "Rustdoc now respects the value of rust.lto.",
343    },
344    ChangeInfo {
345        change_id: 136941,
346        severity: ChangeSeverity::Info,
347        summary: "The llvm.ccache option has moved to build.ccache. llvm.ccache is now deprecated.",
348    },
349    ChangeInfo {
350        change_id: 137170,
351        severity: ChangeSeverity::Info,
352        summary: "It is now possible to configure `jemalloc` for each target",
353    },
354    ChangeInfo {
355        change_id: 137215,
356        severity: ChangeSeverity::Info,
357        summary: "Added `build.test-stage = 2` to 'tools' profile defaults",
358    },
359    ChangeInfo {
360        change_id: 137220,
361        severity: ChangeSeverity::Info,
362        summary: "`rust.channel` now supports \"auto-detect\" to load the channel from `src/ci/channel`",
363    },
364    ChangeInfo {
365        change_id: 137723,
366        severity: ChangeSeverity::Info,
367        summary: "The rust.description option has moved to build.description and rust.description is now deprecated.",
368    },
369    ChangeInfo {
370        change_id: 138051,
371        severity: ChangeSeverity::Info,
372        summary: "There is now a new `gcc` config section that can be used to download GCC from CI using `gcc.download-ci-gcc = true`",
373    },
374    ChangeInfo {
375        change_id: 126856,
376        severity: ChangeSeverity::Warning,
377        summary: "Removed `src/tools/rls` tool as it was deprecated long time ago.",
378    },
379    ChangeInfo {
380        change_id: 137147,
381        severity: ChangeSeverity::Info,
382        summary: "Added new option `build.exclude` which works the same way as `--exclude` flag on `x`.",
383    },
384    ChangeInfo {
385        change_id: 137081,
386        severity: ChangeSeverity::Warning,
387        summary: "The default configuration filename has changed from `config.toml` to `bootstrap.toml`. `config.toml` is deprecated but remains supported for backward compatibility.",
388    },
389    ChangeInfo {
390        change_id: 138986,
391        severity: ChangeSeverity::Info,
392        summary: "You can now use `change-id = \"ignore\"` to suppress `change-id ` warnings in the console.",
393    },
394    ChangeInfo {
395        change_id: 139386,
396        severity: ChangeSeverity::Info,
397        summary: "Added a new option `build.compiletest-use-stage0-libtest` to force `compiletest` to use the stage 0 libtest.",
398    },
399    ChangeInfo {
400        change_id: 138934,
401        severity: ChangeSeverity::Info,
402        summary: "Added new option `include` to create config extensions.",
403    },
404    ChangeInfo {
405        change_id: 140438,
406        severity: ChangeSeverity::Info,
407        summary: "Added a new option `rust.debug-assertions-tools` to control debug asssertions for tools.",
408    },
409    ChangeInfo {
410        change_id: 140732,
411        severity: ChangeSeverity::Info,
412        summary: "`./x run` now supports running in-tree `rustfmt`, e.g., `./x run rustfmt -- --check /path/to/file.rs`.",
413    },
414];