diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 363a9c82699..3d2e3daf915 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1,5 +1,7 @@ use std::thread; +use build_helper::git::get_closest_merge_commit; + use super::*; use crate::Flags; use crate::core::build_steps::doc::DocumentationFormat; @@ -223,31 +225,30 @@ fn ci_rustc_if_unchanged_logic() { |&_| Ok(Default::default()), ); - let build = Build::new(config.clone()); - let builder = Builder::new(&build); - if config.rust_info.is_from_tarball() { return; } + let build = Build::new(config.clone()); + let builder = Builder::new(&build); + if config.out.exists() { fs::remove_dir_all(&config.out).unwrap(); } builder.run_step_descriptions(&Builder::get_step_descriptions(config.cmd.kind()), &[]); - let commit = helpers::get_closest_merge_base_commit( + let compiler_path = build.src.join("compiler"); + let library_path = build.src.join("compiler"); + + let commit = get_closest_merge_commit( Some(&builder.config.src), &builder.config.git_config(), - &builder.config.stage0_metadata.config.git_merge_commit_email, - &[], + &[compiler_path.clone(), library_path.clone()], ) .unwrap(); - let compiler_path = build.src.join("compiler"); - let library_path = build.src.join("library"); - - let has_changes = helpers::git(Some(&builder.src)) + let has_changes = !helpers::git(Some(&builder.src)) .args(["diff-index", "--quiet", &commit]) .arg("--") .args([compiler_path, library_path]) @@ -256,9 +257,7 @@ fn ci_rustc_if_unchanged_logic() { .unwrap() .success(); - assert!( - has_changes != config.out.join(config.build.to_string()).join("ci-rustc-sysroot").exists() - ); + assert!(has_changes == config.download_rustc_commit.is_none()); } mod defaults { diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index e3641254b19..76e3343e86f 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2422,8 +2422,9 @@ impl Config { ci_config_toml, ); - let disable_ci_rustc_if_incompatible = - env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE") + // Primarily used by CI runners to avoid handling download-rustc incompatible + // options one by one on shell scripts. + let disable_ci_rustc_if_incompatible = env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE") .is_some_and(|s| s == "1" || s == "true"); if disable_ci_rustc_if_incompatible && res.is_err() { diff --git a/src/ci/docker/host-x86_64/mingw-check/Dockerfile b/src/ci/docker/host-x86_64/mingw-check/Dockerfile index 97fe56fbfcb..467ca1dac67 100644 --- a/src/ci/docker/host-x86_64/mingw-check/Dockerfile +++ b/src/ci/docker/host-x86_64/mingw-check/Dockerfile @@ -55,7 +55,7 @@ ENV SCRIPT \ git config --global user.name \"dummy\" && \ git add ../compiler/rustc/src/main.rs && \ git commit -m \"test commit for rust.download-rustc=if-unchanged logic\" && \ - python3 ../x.py test bootstrap -- core::builder::tests::ci_rustc_if_unchanged_logic && \ + DISABLE_CI_RUSTC_IF_INCOMPATIBLE=0 python3 ../x.py test bootstrap -- core::builder::tests::ci_rustc_if_unchanged_logic && \ # Revert the dummy commit git reset --hard HEAD~1 && \ diff --git a/src/ci/run.sh b/src/ci/run.sh index 8a8d26f8302..457f36bdd20 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -52,7 +52,8 @@ if [ "$CI" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set change-id=99999999" fi -# If runner uses an incompatible option and `FORCE_CI_RUSTC` is not defined, switch to in-tree rustc. +# If runner uses an incompatible option and `FORCE_CI_RUSTC` is not defined, +# switch to in-tree rustc. if [ "$FORCE_CI_RUSTC" == "" ]; then DISABLE_CI_RUSTC_IF_INCOMPATIBLE=1 fi