Skip to content

Commit

Permalink
Make download-rustc incompatible with rust.debug-assertions for now
Browse files Browse the repository at this point in the history
Alt rustc builds currently do not have rustc debug assertions enabled.
  • Loading branch information
jieyouxu committed Nov 17, 2024
1 parent 4d18ea5 commit 9f10635
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,29 @@ impl Config {
std_features: std_features_toml,
} = rust;

// Before something like [Enable debug assertions on alt
// builds](https://github.com/rust-lang/rust/pull/131077) lands, alt rustc builds do
// *not* have rustc debug assertions enabled. We must not download an CI alt rustc if we
// need rustc to have debug assertions (e.g. for crashes test suite).
//
// Note that `rust.debug = true` (currently) implies `rust.debug-assertions = true`!
//
// This relies also on the fact that global default for `download-rustc` will be `false`
// if it's not explicitly set.
if matches!(rustc_debug_assertions, Some(true))
|| (matches!(debug, Some(true)) && rustc_debug_assertions.is_none())
{
if let Some(ref opt) = download_rustc {
if opt.is_string_or_true() {
panic!(
"ERROR: currently no CI rustc builds have rustc debug assertions\
enabled. Please either set `rust.debug-assertions` to `false` or set \
`rust.download-rustc` to `false`."
);
}
}
}

config.download_rustc_commit =
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);

Expand Down
65 changes: 65 additions & 0 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,68 @@ fn check_rustc_if_unchanged_paths() {
assert!(config.src.join(p).exists(), "{p} doesn't exist.");
}
}

#[test]
#[should_panic]
fn download_rustc_xor_rustc_debug_assertions_both_true() {
parse(
r#"
[rust]
debug-assertions = true
download-rustc = true
"#,
);
}

#[test]
#[should_panic]
fn download_rustc_xor_rustc_debug_assertions_debug_download_unchanged() {
parse(
r#"
[rust]
debug-assertions = true
download-rustc = 'if-unchanged'
"#,
);
}

#[test]
#[should_panic]
fn download_rustc_xor_rustc_debug_assertions_debug_true() {
parse(
r#"
[rust]
debug = true
download-rustc = true
"#,
);
}

#[test]
fn download_rustc_xor_rustc_debug_assertions_only_download_rustc() {
let _ = parse(
r#"
[rust]
download-rustc = true
"#,
);

let _ = parse(
r#"
[rust]
download-rustc = 'if-unchanged'
"#,
);
}

#[test]
fn download_rustc_xor_rustc_debug_assertions_no_debug_assert_ok() {
let _ = parse(
r#"
[rust]
debug = true
debug-assertions = false
download-rustc = true
"#,
);
}
2 changes: 1 addition & 1 deletion src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,6 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
ChangeInfo {
change_id: 133068,
severity: ChangeSeverity::Info,
summary: "Reverted `download-rustc` defaults; global default is now `false`, and only use `'if-unchanged'` default for library and tools profile.",
summary: "Reverted `download-rustc` defaults; global default is now `false`, and only use `'if-unchanged'` default for library and tools profile. Also fixed that `rust.debug-assertions = true` is incompatible with `rust.download-rustc = true | 'if-unchanged'`",
},
];

0 comments on commit 9f10635

Please sign in to comment.