Skip to content

Commit 727183f

Browse files
committed
Make download-rustc incompatible with rust.debug-assertions for now
Alt rustc builds currently do not have rustc debug assertions enabled.
1 parent 4d18ea5 commit 727183f

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

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

+25
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,29 @@ impl Config {
17671767
std_features: std_features_toml,
17681768
} = rust;
17691769

1770+
// Before something like [Enable debug assertions on alt
1771+
// builds](https://github.com/rust-lang/rust/pull/131077) lands, alt rustc builds do
1772+
// *not* have rustc debug assertions enabled. We must not download an CI alt rustc if we
1773+
// need rustc to have debug assertions (e.g. for crashes test suite).
1774+
//
1775+
// Note that `rust.debug = true` (currently) implies `rust.debug-assertions = true`!
1776+
//
1777+
// This relies also on the fact that global default for `download-rustc` will be `false`
1778+
// if it's not explicitly set.
1779+
if matches!(rustc_debug_assertions, Some(true))
1780+
|| (matches!(debug, Some(true)) && rustc_debug_assertions.is_none())
1781+
{
1782+
if let Some(ref opt) = download_rustc {
1783+
if opt.is_string_or_true() {
1784+
panic!(
1785+
"ERROR: currently no CI rustc builds have rustc debug assertions\
1786+
enabled. Please either set `rust.debug-assertions` to `false` or set \
1787+
`rust.download-rustc` to `false`."
1788+
);
1789+
}
1790+
}
1791+
}
1792+
17701793
config.download_rustc_commit =
17711794
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
17721795

@@ -2172,7 +2195,9 @@ impl Config {
21722195
config.rust_std_features = std_features.unwrap_or(default_std_features);
21732196

21742197
let default = debug == Some(true);
2198+
21752199
config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default);
2200+
21762201
config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions);
21772202
config.rust_overflow_checks = overflow_checks.unwrap_or(default);
21782203
config.rust_overflow_checks_std =

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

+65
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,68 @@ fn check_rustc_if_unchanged_paths() {
447447
assert!(config.src.join(p).exists(), "{p} doesn't exist.");
448448
}
449449
}
450+
451+
#[test]
452+
#[should_panic]
453+
fn download_rustc_xor_rustc_debug_assertions_both_true() {
454+
parse(
455+
r#"
456+
[rust]
457+
debug-assertions = true
458+
download-rustc = true
459+
"#,
460+
);
461+
}
462+
463+
#[test]
464+
#[should_panic]
465+
fn download_rustc_xor_rustc_debug_assertions_debug_download_unchanged() {
466+
parse(
467+
r#"
468+
[rust]
469+
debug-assertions = true
470+
download-rustc = 'if-unchanged'
471+
"#,
472+
);
473+
}
474+
475+
#[test]
476+
#[should_panic]
477+
fn download_rustc_xor_rustc_debug_assertions_debug_true() {
478+
parse(
479+
r#"
480+
[rust]
481+
debug = true
482+
download-rustc = true
483+
"#,
484+
);
485+
}
486+
487+
#[test]
488+
fn download_rustc_xor_rustc_debug_assertions_only_download_rustc() {
489+
let _ = parse(
490+
r#"
491+
[rust]
492+
download-rustc = true
493+
"#,
494+
);
495+
496+
let _ = parse(
497+
r#"
498+
[rust]
499+
download-rustc = 'if-unchanged'
500+
"#,
501+
);
502+
}
503+
504+
#[test]
505+
fn download_rustc_xor_rustc_debug_assertions_no_debug_assert_ok() {
506+
let _ = parse(
507+
r#"
508+
[rust]
509+
debug = true
510+
debug-assertions = false
511+
download-rustc = true
512+
"#,
513+
);
514+
}

0 commit comments

Comments
 (0)