Skip to content

Commit d4f3673

Browse files
committed
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. Signed-off-by: onur-ozkan <[email protected]>
1 parent 8c3a94a commit d4f3673

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

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 {
@@ -2614,14 +2625,15 @@ impl Config {
26142625

26152626
/// Checks the CI rustc incompatible options by destructuring the `Rust` instance
26162627
/// and makes sure that no rust options from config.toml are missed.
2617-
fn check_incompatible_options_for_ci_rustc(rust: &Rust) {
2628+
fn check_incompatible_options_for_ci_rustc(rust: &Rust) -> Result<(), String> {
26182629
macro_rules! err {
26192630
($name:expr) => {
2620-
assert!(
2621-
$name.is_none(),
2622-
"ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.",
2623-
stringify!($name).replace("_", "-")
2624-
);
2631+
if $name.is_some() {
2632+
return Err(format!(
2633+
"ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.",
2634+
stringify!($name).replace("_", "-")
2635+
));
2636+
}
26252637
};
26262638
}
26272639

@@ -2717,6 +2729,8 @@ fn check_incompatible_options_for_ci_rustc(rust: &Rust) {
27172729
warn!(channel);
27182730
warn!(description);
27192731
warn!(incremental);
2732+
2733+
Ok(())
27202734
}
27212735

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

0 commit comments

Comments
 (0)