Skip to content

Streamline config in bootstrap #144807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f95edbe
move gcc config parsing to parse_inner
Shourya742 Jul 30, 2025
3f9bf57
move dist to parse_inner
Shourya742 Jul 30, 2025
924912c
move target parsing to parse_inner
Shourya742 Jul 30, 2025
89219ff
move install to parse_inner
Shourya742 Jul 30, 2025
3248ff1
move llvm parsing to parse_inner
Shourya742 Jul 30, 2025
ddd2a54
move rust config to parse_inner
Shourya742 Jul 30, 2025
ae05591
Force initializing ExecutionContext with verbosity and fail_fast mode
Shourya742 Jul 30, 2025
82756fd
Extract TOML config loading and src directory computation into separa…
Shourya742 Jul 30, 2025
f89ea08
Split TOML postprocessing into a separate function
Shourya742 Jul 30, 2025
cfc40de
Override some build TOML values by flags
Shourya742 Jul 30, 2025
8652d96
Fix logging of config skip values
Shourya742 Jul 30, 2025
58a38cd
Fix verbosity setting
Shourya742 Jul 30, 2025
222dfcc
add install default implementation
Shourya742 Aug 1, 2025
bbe7c08
add gcc and dist default implementation
Shourya742 Aug 1, 2025
38ddefa
add llvm default implementation
Shourya742 Aug 1, 2025
8b80cb0
add rust default implementation
Shourya742 Aug 1, 2025
d3d3b10
make llvm toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
c008a4b
make gcc toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
4d2a2c2
make dist toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
ad98550
make install toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
2c96132
make build toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
a75326b
move build config to the top of parse method
Shourya742 Aug 1, 2025
39d9cf7
move install config to the top of parse method
Shourya742 Aug 1, 2025
120d93e
move rust config to the top of parse method
Shourya742 Aug 1, 2025
f74f1a0
move llvm config to the top of parse method
Shourya742 Aug 1, 2025
7f20ad8
move dist and gcc config to the top of parse method
Shourya742 Aug 1, 2025
a2794f9
remove redundant _toml suffix and other misc changes
Shourya742 Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,327 changes: 908 additions & 419 deletions src/bootstrap/src/core/config/config.rs

Large diffs are not rendered by default.

33 changes: 3 additions & 30 deletions src/bootstrap/src/core/config/toml/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

use serde::{Deserialize, Deserializer};

use crate::core::config::Merge;
use crate::core::config::toml::ReplaceOpt;
use crate::core::config::{Merge, set};
use crate::{Config, HashSet, PathBuf, define_config, exit};
use crate::{HashSet, PathBuf, define_config, exit};

define_config! {
#[derive(Default)]
struct Dist {
sign_folder: Option<String> = "sign-folder",
upload_addr: Option<String> = "upload-addr",
Expand All @@ -22,31 +23,3 @@ define_config! {
vendor: Option<bool> = "vendor",
}
}

impl Config {
/// Applies distribution-related configuration from the `Dist` struct
/// to the global `Config` structure.
pub fn apply_dist_config(&mut self, toml_dist: Option<Dist>) {
if let Some(dist) = toml_dist {
let Dist {
sign_folder,
upload_addr,
src_tarball,
compression_formats,
compression_profile,
include_mingw_linker,
vendor,
} = dist;
self.dist_sign_folder = sign_folder.map(PathBuf::from);
self.dist_upload_addr = upload_addr;
self.dist_compression_formats = compression_formats;
set(&mut self.dist_compression_profile, compression_profile);
set(&mut self.rust_dist_src, src_tarball);
set(&mut self.dist_include_mingw_linker, include_mingw_linker);
self.dist_vendor = vendor.unwrap_or_else(|| {
// If we're building from git or tarball sources, enable it by default.
self.rust_info.is_managed_git_subrepository() || self.rust_info.is_from_tarball()
});
}
}
}
21 changes: 3 additions & 18 deletions src/bootstrap/src/core/config/toml/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,14 @@

use serde::{Deserialize, Deserializer};

use crate::core::config::Merge;
use crate::core::config::toml::ReplaceOpt;
use crate::core::config::{GccCiMode, Merge};
use crate::{Config, HashSet, PathBuf, define_config, exit};
use crate::{HashSet, PathBuf, define_config, exit};

define_config! {
/// TOML representation of how the GCC build is configured.
#[derive(Default)]
struct Gcc {
download_ci_gcc: Option<bool> = "download-ci-gcc",
}
}

impl Config {
/// Applies GCC-related configuration from the `TomlGcc` struct to the
/// global `Config` structure.
pub fn apply_gcc_config(&mut self, toml_gcc: Option<Gcc>) {
if let Some(gcc) = toml_gcc {
self.gcc_ci_mode = match gcc.download_ci_gcc {
Some(value) => match value {
true => GccCiMode::DownloadFromCi,
false => GccCiMode::BuildLocally,
},
None => GccCiMode::default(),
};
}
}
}
22 changes: 3 additions & 19 deletions src/bootstrap/src/core/config/toml/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

use serde::{Deserialize, Deserializer};

use crate::core::config::Merge;
use crate::core::config::toml::ReplaceOpt;
use crate::core::config::{Merge, set};
use crate::{Config, HashSet, PathBuf, define_config, exit};
use crate::{HashSet, PathBuf, define_config, exit};

define_config! {
/// TOML representation of various global install decisions.
#[derive(Default)]
struct Install {
prefix: Option<String> = "prefix",
sysconfdir: Option<String> = "sysconfdir",
Expand All @@ -24,20 +25,3 @@ define_config! {
datadir: Option<String> = "datadir",
}
}

impl Config {
/// Applies installation-related configuration from the `Install` struct
/// to the global `Config` structure.
pub fn apply_install_config(&mut self, toml_install: Option<Install>) {
if let Some(install) = toml_install {
let Install { prefix, sysconfdir, docdir, bindir, libdir, mandir, datadir } = install;
self.prefix = prefix.map(PathBuf::from);
self.sysconfdir = sysconfdir.map(PathBuf::from);
self.datadir = datadir.map(PathBuf::from);
self.docdir = docdir.map(PathBuf::from);
set(&mut self.bindir, bindir.map(PathBuf::from));
self.libdir = libdir.map(PathBuf::from);
self.mandir = mandir.map(PathBuf::from);
}
}
}
129 changes: 3 additions & 126 deletions src/bootstrap/src/core/config/toml/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

use serde::{Deserialize, Deserializer};

use crate::core::config::StringOrBool;
use crate::core::config::toml::{Merge, ReplaceOpt, TomlConfig};
use crate::core::config::{StringOrBool, set};
use crate::{Config, HashMap, HashSet, PathBuf, define_config, exit};
use crate::{HashMap, HashSet, PathBuf, define_config, exit};

define_config! {
/// TOML representation of how the LLVM build is configured.
#[derive(Default)]
struct Llvm {
optimize: Option<bool> = "optimize",
thin_lto: Option<bool> = "thin-lto",
Expand Down Expand Up @@ -144,127 +145,3 @@ pub fn check_incompatible_options_for_ci_llvm(

Ok(())
}

impl Config {
pub fn apply_llvm_config(&mut self, toml_llvm: Option<Llvm>) {
let mut llvm_tests = None;
let mut llvm_enzyme = None;
let mut llvm_offload = None;
let mut llvm_plugins = None;

if let Some(llvm) = toml_llvm {
let Llvm {
optimize: optimize_toml,
thin_lto,
release_debuginfo,
assertions: _,
tests,
enzyme,
plugins,
static_libstdcpp,
libzstd,
ninja,
targets,
experimental_targets,
link_jobs,
link_shared,
version_suffix,
clang_cl,
cflags,
cxxflags,
ldflags,
use_libcxx,
use_linker,
allow_old_toolchain,
offload,
polly,
clang,
enable_warnings,
download_ci_llvm,
build_config,
} = llvm;

set(&mut self.ninja_in_file, ninja);
llvm_tests = tests;
llvm_enzyme = enzyme;
llvm_offload = offload;
llvm_plugins = plugins;
set(&mut self.llvm_optimize, optimize_toml);
set(&mut self.llvm_thin_lto, thin_lto);
set(&mut self.llvm_release_debuginfo, release_debuginfo);
set(&mut self.llvm_static_stdcpp, static_libstdcpp);
set(&mut self.llvm_libzstd, libzstd);
if let Some(v) = link_shared {
self.llvm_link_shared.set(Some(v));
}
self.llvm_targets.clone_from(&targets);
self.llvm_experimental_targets.clone_from(&experimental_targets);
self.llvm_link_jobs = link_jobs;
self.llvm_version_suffix.clone_from(&version_suffix);
self.llvm_clang_cl.clone_from(&clang_cl);

self.llvm_cflags.clone_from(&cflags);
self.llvm_cxxflags.clone_from(&cxxflags);
self.llvm_ldflags.clone_from(&ldflags);
set(&mut self.llvm_use_libcxx, use_libcxx);
self.llvm_use_linker.clone_from(&use_linker);
self.llvm_allow_old_toolchain = allow_old_toolchain.unwrap_or(false);
self.llvm_offload = offload.unwrap_or(false);
self.llvm_polly = polly.unwrap_or(false);
self.llvm_clang = clang.unwrap_or(false);
self.llvm_enable_warnings = enable_warnings.unwrap_or(false);
self.llvm_build_config = build_config.clone().unwrap_or(Default::default());

self.llvm_from_ci = self.parse_download_ci_llvm(download_ci_llvm, self.llvm_assertions);

if self.llvm_from_ci {
let warn = |option: &str| {
println!(
"WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build."
);
println!(
"HELP: To use `{option}` for LLVM builds, set `download-ci-llvm` option to false."
);
};

if static_libstdcpp.is_some() {
warn("static-libstdcpp");
}

if link_shared.is_some() {
warn("link-shared");
}

// FIXME(#129153): instead of all the ad-hoc `download-ci-llvm` checks that follow,
// use the `builder-config` present in tarballs since #128822 to compare the local
// config to the ones used to build the LLVM artifacts on CI, and only notify users
// if they've chosen a different value.

if libzstd.is_some() {
println!(
"WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \
like almost all `llvm.*` options, will be ignored and set by the LLVM CI \
artifacts builder config."
);
println!(
"HELP: To use `llvm.libzstd` for LLVM/LLD builds, set `download-ci-llvm` option to false."
);
}
}

if !self.llvm_from_ci && self.llvm_thin_lto && link_shared.is_none() {
// If we're building with ThinLTO on, by default we want to link
// to LLVM shared, to avoid re-doing ThinLTO (which happens in
// the link step) with each stage.
self.llvm_link_shared.set(Some(true));
}
} else {
self.llvm_from_ci = self.parse_download_ci_llvm(None, false);
}

self.llvm_tests = llvm_tests.unwrap_or(false);
self.llvm_enzyme = llvm_enzyme.unwrap_or(false);
self.llvm_offload = llvm_offload.unwrap_or(false);
self.llvm_plugins = llvm_plugins.unwrap_or(false);
}
}
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/config/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! these raw TOML configurations from various sources (the main `bootstrap.toml`,
//! included files, profile defaults, and command-line overrides). This processed
//! TOML data then serves as an intermediate representation, which is further
//! transformed and applied to the final [`Config`] struct.
//! transformed and applied to the final `Config` struct.

use serde::Deserialize;
use serde_derive::Deserialize;
Expand Down
Loading
Loading