Skip to content

Commit eb5e623

Browse files
committed
use if-unchanged only when ci rustc is available
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent b21949b commit eb5e623

File tree

2 files changed

+57
-9
lines changed

2 files changed

+57
-9
lines changed

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX;
2222
use crate::core::build_steps::llvm;
2323
pub use crate::core::config::flags::Subcommand;
2424
use crate::core::config::flags::{Color, Flags, Warnings};
25+
use crate::core::download::is_download_ci_available;
2526
use crate::utils::cache::{INTERNER, Interned};
2627
use crate::utils::channel::{self, GitInfo};
2728
use crate::utils::helpers::{self, exe, output, t};
@@ -1627,9 +1628,11 @@ impl Config {
16271628
config.mandir = mandir.map(PathBuf::from);
16281629
}
16291630

1631+
config.llvm_assertions =
1632+
toml.llvm.as_ref().map_or(false, |llvm| llvm.assertions.unwrap_or(false));
1633+
16301634
// Store off these values as options because if they're not provided
16311635
// we'll infer default values for them later
1632-
let mut llvm_assertions = None;
16331636
let mut llvm_tests = None;
16341637
let mut llvm_enzyme = None;
16351638
let mut llvm_plugins = None;
@@ -1712,7 +1715,8 @@ impl Config {
17121715
is_user_configured_rust_channel = channel.is_some();
17131716
set(&mut config.channel, channel.clone());
17141717

1715-
config.download_rustc_commit = config.download_ci_rustc_commit(download_rustc);
1718+
config.download_rustc_commit =
1719+
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
17161720

17171721
debug = debug_toml;
17181722
debug_assertions = debug_assertions_toml;
@@ -1848,7 +1852,7 @@ impl Config {
18481852
optimize: optimize_toml,
18491853
thin_lto,
18501854
release_debuginfo,
1851-
assertions,
1855+
assertions: _,
18521856
tests,
18531857
enzyme,
18541858
plugins,
@@ -1882,7 +1886,6 @@ impl Config {
18821886
Some(StringOrBool::Bool(false)) | None => {}
18831887
}
18841888
set(&mut config.ninja_in_file, ninja);
1885-
llvm_assertions = assertions;
18861889
llvm_tests = tests;
18871890
llvm_enzyme = enzyme;
18881891
llvm_plugins = plugins;
@@ -1911,8 +1914,8 @@ impl Config {
19111914
config.llvm_enable_warnings = enable_warnings.unwrap_or(false);
19121915
config.llvm_build_config = build_config.clone().unwrap_or(Default::default());
19131916

1914-
let asserts = llvm_assertions.unwrap_or(false);
1915-
config.llvm_from_ci = config.parse_download_ci_llvm(download_ci_llvm, asserts);
1917+
config.llvm_from_ci =
1918+
config.parse_download_ci_llvm(download_ci_llvm, config.llvm_assertions);
19161919

19171920
if config.llvm_from_ci {
19181921
let warn = |option: &str| {
@@ -2080,7 +2083,6 @@ impl Config {
20802083
// Now that we've reached the end of our configuration, infer the
20812084
// default values for all options that we haven't otherwise stored yet.
20822085

2083-
config.llvm_assertions = llvm_assertions.unwrap_or(false);
20842086
config.llvm_tests = llvm_tests.unwrap_or(false);
20852087
config.llvm_enzyme = llvm_enzyme.unwrap_or(false);
20862088
config.llvm_plugins = llvm_plugins.unwrap_or(false);
@@ -2711,12 +2713,18 @@ impl Config {
27112713
}
27122714

27132715
/// Returns the commit to download, or `None` if we shouldn't download CI artifacts.
2714-
fn download_ci_rustc_commit(&self, download_rustc: Option<StringOrBool>) -> Option<String> {
2716+
fn download_ci_rustc_commit(
2717+
&self,
2718+
download_rustc: Option<StringOrBool>,
2719+
llvm_assertions: bool,
2720+
) -> Option<String> {
27152721
// If `download-rustc` is not set, default to rebuilding.
27162722
let if_unchanged = match download_rustc {
27172723
None | Some(StringOrBool::Bool(false)) => return None,
27182724
Some(StringOrBool::Bool(true)) => false,
2719-
Some(StringOrBool::String(s)) if s == "if-unchanged" => true,
2725+
Some(StringOrBool::String(s)) if s == "if-unchanged" => {
2726+
is_download_ci_available(&self.build.triple, llvm_assertions)
2727+
}
27202728
Some(StringOrBool::String(other)) => {
27212729
panic!("unrecognized option for download-rustc: {other}")
27222730
}

src/bootstrap/src/core/download.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,43 @@ fn path_is_dylib(path: &Path) -> bool {
832832
// The .so is not necessarily the extension, it might be libLLVM.so.18.1
833833
path.to_str().map_or(false, |path| path.contains(".so"))
834834
}
835+
836+
/// Checks whether the CI rustc is available for the given target triple.
837+
pub(crate) fn is_download_ci_available(target_triple: &str, llvm_assertions: bool) -> bool {
838+
// All tier 1 targets and tier 2 targets with host tools.
839+
const SUPPORTED_PLATFORMS: &[&str] = &[
840+
"aarch64-apple-darwin",
841+
"aarch64-pc-windows-msvc",
842+
"aarch64-unknown-linux-gnu",
843+
"aarch64-unknown-linux-musl",
844+
"arm-unknown-linux-gnueabi",
845+
"arm-unknown-linux-gnueabihf",
846+
"armv7-unknown-linux-gnueabihf",
847+
"i686-pc-windows-gnu",
848+
"i686-pc-windows-msvc",
849+
"i686-unknown-linux-gnu",
850+
"loongarch64-unknown-linux-gnu",
851+
"powerpc-unknown-linux-gnu",
852+
"powerpc64-unknown-linux-gnu",
853+
"powerpc64le-unknown-linux-gnu",
854+
"riscv64gc-unknown-linux-gnu",
855+
"s390x-unknown-linux-gnu",
856+
"x86_64-apple-darwin",
857+
"x86_64-pc-windows-gnu",
858+
"x86_64-pc-windows-msvc",
859+
"x86_64-unknown-freebsd",
860+
"x86_64-unknown-illumos",
861+
"x86_64-unknown-linux-gnu",
862+
"x86_64-unknown-linux-musl",
863+
"x86_64-unknown-netbsd",
864+
];
865+
866+
const SUPPORTED_PLATFORMS_WITH_ASSERTIONS: &[&str] =
867+
&["x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"];
868+
869+
if llvm_assertions {
870+
SUPPORTED_PLATFORMS_WITH_ASSERTIONS.contains(&target_triple)
871+
} else {
872+
SUPPORTED_PLATFORMS.contains(&target_triple)
873+
}
874+
}

0 commit comments

Comments
 (0)