Add [gcc] download-ci-gcc option

This commit is contained in:
Jakub Beránek 2025-03-05 11:26:16 +01:00
parent 009aba0aa3
commit c68a5ec6c3
2 changed files with 32 additions and 1 deletions

View file

@ -167,6 +167,11 @@
# Tweaking how GCC is compiled
# =============================================================================
[gcc]
# Download GCC from CI instead of building it locally.
# Note that this will attempt to download GCC even if there are local
# modifications to the `src/gcc` submodule.
# Currently, this is only supported for the `x86_64-unknown-linux-gnu` target.
# download-ci-gcc = false
# =============================================================================
# General build configuration options

View file

@ -171,6 +171,17 @@ impl LldMode {
}
}
/// Determines how will GCC be provided.
#[derive(Default, Clone)]
pub enum GccCiMode {
/// Build GCC from the local `src/gcc` submodule.
#[default]
BuildLocally,
/// Try to download GCC from CI.
/// If it is not available on CI, it will be built locally instead.
DownloadFromCi,
}
/// Global configuration for the entire build and/or bootstrap.
///
/// This structure is parsed from `config.toml`, and some of the fields are inferred from `git` or build-time parameters.
@ -283,6 +294,9 @@ pub struct Config {
pub llvm_ldflags: Option<String>,
pub llvm_use_libcxx: bool,
// gcc codegen options
pub gcc_ci_mode: GccCiMode,
// rust codegen options
pub rust_optimize: RustOptimize,
pub rust_codegen_units: Option<u32>,
@ -999,7 +1013,9 @@ define_config! {
define_config! {
/// TOML representation of how the GCC build is configured.
struct Gcc {}
struct Gcc {
download_ci_gcc: Option<bool> = "download-ci-gcc",
}
}
define_config! {
@ -2143,6 +2159,16 @@ impl Config {
config.llvm_from_ci = config.parse_download_ci_llvm(None, false);
}
if let Some(gcc) = toml.gcc {
config.gcc_ci_mode = match gcc.download_ci_gcc {
Some(value) => match value {
true => GccCiMode::DownloadFromCi,
false => GccCiMode::BuildLocally,
},
None => GccCiMode::default(),
};
}
if let Some(t) = toml.target {
for (triple, cfg) in t {
let mut target = Target::from_triple(&triple);