Skip to content

Commit 835f5f0

Browse files
committed
bootstrap: make rust.debug-assertions = true inhibit downloading CI rustc
Warn if `rust.download-rustc = true` is used with `rust.debug-assertions` as alt CI rustc is not currently built with debug assertions (not to be confused with LLVM assertions).
1 parent aafd56b commit 835f5f0

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

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

+42-4
Original file line numberDiff line numberDiff line change
@@ -1771,8 +1771,37 @@ impl Config {
17711771
std_features: std_features_toml,
17721772
} = rust;
17731773

1774-
config.download_rustc_commit =
1775-
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
1774+
// FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions
1775+
// enabled. We should not download a CI alt rustc if we need rustc to have debug
1776+
// assertions (e.g. for crashes test suite). This can be changed once something like
1777+
// [Enable debug assertions on alt
1778+
// builds](https://github.com/rust-lang/rust/pull/131077) lands.
1779+
//
1780+
// Note that `rust.debug = true` currently implies `rust.debug-assertions = true`!
1781+
//
1782+
// This relies also on the fact that the global default for `download-rustc` will be
1783+
// `false` if it's not explicitly set.
1784+
let debug_assertions_requested = matches!(rustc_debug_assertions_toml, Some(true))
1785+
|| (matches!(debug_toml, Some(true))
1786+
&& !matches!(rustc_debug_assertions_toml, Some(false)));
1787+
1788+
if debug_assertions_requested {
1789+
if let Some(ref opt) = download_rustc {
1790+
if opt.is_string_or_true() {
1791+
eprintln!(
1792+
"WARN: currently no CI rustc builds have rustc debug assertions \
1793+
enabled. Please either set `rust.debug-assertions` to `false` if you \
1794+
want to use download CI rustc or set `rust.download-rustc` to `false`."
1795+
);
1796+
}
1797+
}
1798+
}
1799+
1800+
config.download_rustc_commit = config.download_ci_rustc_commit(
1801+
download_rustc,
1802+
debug_assertions_requested,
1803+
config.llvm_assertions,
1804+
);
17761805

17771806
debug = debug_toml;
17781807
rustc_debug_assertions = rustc_debug_assertions_toml;
@@ -2778,6 +2807,7 @@ impl Config {
27782807
fn download_ci_rustc_commit(
27792808
&self,
27802809
download_rustc: Option<StringOrBool>,
2810+
debug_assertions_requested: bool,
27812811
llvm_assertions: bool,
27822812
) -> Option<String> {
27832813
if !is_download_ci_available(&self.build.triple, llvm_assertions) {
@@ -2786,9 +2816,9 @@ impl Config {
27862816

27872817
// If `download-rustc` is not set, default to rebuilding.
27882818
let if_unchanged = match download_rustc {
2789-
// Globally default for `download-rustc` to `false`, because some contributors don't use
2819+
// Globally default `download-rustc` to `false`, because some contributors don't use
27902820
// profiles for reasons such as:
2791-
// - They need to seemlessly switch between compiler/library work.
2821+
// - They need to seamlessly switch between compiler/library work.
27922822
// - They don't want to use compiler profile because they need to override too many
27932823
// things and it's easier to not use a profile.
27942824
None | Some(StringOrBool::Bool(false)) => return None,
@@ -2849,6 +2879,14 @@ impl Config {
28492879
return None;
28502880
}
28512881

2882+
if debug_assertions_requested {
2883+
eprintln!(
2884+
"WARN: `rust.debug-assertions = true` will prevent downloading CI rustc as alt CI \
2885+
rustc is not currently built with debug assertions."
2886+
);
2887+
return None;
2888+
}
2889+
28522890
Some(commit)
28532891
}
28542892

0 commit comments

Comments
 (0)