Skip to content

Commit 041b8c4

Browse files
authored
Rollup merge of #128098 - onur-ozkan:incompatible-option-behaviour, r=Kobzol
make it possible to disable download-rustc if it's incompatible Primarily needed by CI runners to avoid handling download-rustc incompatible options one by one on shell scripts. This will significantly help to #122709.
2 parents c2ba4b1 + d4f3673 commit 041b8c4

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

Diff for: src/bootstrap/src/core/config/config.rs

+25-11
Original file line numberDiff line numberDiff line change
@@ -1570,11 +1570,22 @@ impl Config {
15701570
let mut is_user_configured_rust_channel = false;
15711571

15721572
if let Some(rust) = toml.rust {
1573-
config.download_rustc_commit =
1574-
config.download_ci_rustc_commit(rust.download_rustc.clone());
1575-
1576-
if config.download_rustc_commit.is_some() {
1577-
check_incompatible_options_for_ci_rustc(&rust);
1573+
if let Some(commit) = config.download_ci_rustc_commit(rust.download_rustc.clone()) {
1574+
// Primarily used by CI runners to avoid handling download-rustc incompatible
1575+
// options one by one on shell scripts.
1576+
let disable_ci_rustc_if_incompatible =
1577+
env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE")
1578+
.is_some_and(|s| s == "1" || s == "true");
1579+
1580+
if let Err(e) = check_incompatible_options_for_ci_rustc(&rust) {
1581+
if disable_ci_rustc_if_incompatible {
1582+
config.download_rustc_commit = None;
1583+
} else {
1584+
panic!("{}", e);
1585+
}
1586+
} else {
1587+
config.download_rustc_commit = Some(commit);
1588+
}
15781589
}
15791590

15801591
let Rust {
@@ -2612,14 +2623,15 @@ impl Config {
26122623

26132624
/// Checks the CI rustc incompatible options by destructuring the `Rust` instance
26142625
/// and makes sure that no rust options from config.toml are missed.
2615-
fn check_incompatible_options_for_ci_rustc(rust: &Rust) {
2626+
fn check_incompatible_options_for_ci_rustc(rust: &Rust) -> Result<(), String> {
26162627
macro_rules! err {
26172628
($name:expr) => {
2618-
assert!(
2619-
$name.is_none(),
2620-
"ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.",
2621-
stringify!($name).replace("_", "-")
2622-
);
2629+
if $name.is_some() {
2630+
return Err(format!(
2631+
"ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.",
2632+
stringify!($name).replace("_", "-")
2633+
));
2634+
}
26232635
};
26242636
}
26252637

@@ -2715,6 +2727,8 @@ fn check_incompatible_options_for_ci_rustc(rust: &Rust) {
27152727
warn!(channel);
27162728
warn!(description);
27172729
warn!(incremental);
2730+
2731+
Ok(())
27182732
}
27192733

27202734
fn set<T>(field: &mut T, val: Option<T>) {

0 commit comments

Comments
 (0)