From f95edbee8ba8aa25571496b0e1270f88a193c09d Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 11:34:04 +0530 Subject: [PATCH 01/27] move gcc config parsing to parse_inner --- src/bootstrap/src/core/config/config.rs | 10 +++++++++- src/bootstrap/src/core/config/toml/gcc.rs | 20 ++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 6055876c47579..54a73f934706a 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -979,7 +979,15 @@ impl Config { config.apply_llvm_config(toml.llvm); - config.apply_gcc_config(toml.gcc); + 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(), + }; + } match ccache { Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()), diff --git a/src/bootstrap/src/core/config/toml/gcc.rs b/src/bootstrap/src/core/config/toml/gcc.rs index bb817c2aaef8b..de061309c8040 100644 --- a/src/bootstrap/src/core/config/toml/gcc.rs +++ b/src/bootstrap/src/core/config/toml/gcc.rs @@ -6,9 +6,9 @@ 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. @@ -16,19 +16,3 @@ define_config! { download_ci_gcc: Option = "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) { - 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(), - }; - } - } -} From 3f9bf57cf2350867e9bbb66e515801d5cc735492 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 11:36:32 +0530 Subject: [PATCH 02/27] move dist to parse_inner --- src/bootstrap/src/core/config/config.rs | 24 +++++++++++++++- src/bootstrap/src/core/config/toml/dist.rs | 32 ++-------------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 54a73f934706a..62c528538c48d 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -37,6 +37,7 @@ use crate::core::config::target_selection::TargetSelectionList; use crate::core::config::toml::TomlConfig; use crate::core::config::toml::build::{Build, Tool}; use crate::core::config::toml::change_id::ChangeId; +use crate::core::config::toml::dist::Dist; use crate::core::config::toml::rust::{ LldMode, RustOptimize, check_incompatible_options_for_ci_rustc, }; @@ -1013,7 +1014,28 @@ impl Config { Some(ci_llvm_bin.join(exe("FileCheck", config.host_target))); } - config.apply_dist_config(toml.dist); + if let Some(dist) = toml.dist { + let Dist { + sign_folder, + upload_addr, + src_tarball, + compression_formats, + compression_profile, + include_mingw_linker, + vendor, + } = dist; + config.dist_sign_folder = sign_folder.map(PathBuf::from); + config.dist_upload_addr = upload_addr; + config.dist_compression_formats = compression_formats; + set(&mut config.dist_compression_profile, compression_profile); + set(&mut config.rust_dist_src, src_tarball); + set(&mut config.dist_include_mingw_linker, include_mingw_linker); + config.dist_vendor = vendor.unwrap_or_else(|| { + // If we're building from git or tarball sources, enable it by default. + config.rust_info.is_managed_git_subrepository() + || config.rust_info.is_from_tarball() + }); + } config.initial_rustfmt = if let Some(r) = rustfmt { Some(r) diff --git a/src/bootstrap/src/core/config/toml/dist.rs b/src/bootstrap/src/core/config/toml/dist.rs index b1429ef18617e..4ab18762bb054 100644 --- a/src/bootstrap/src/core/config/toml/dist.rs +++ b/src/bootstrap/src/core/config/toml/dist.rs @@ -7,9 +7,9 @@ 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! { struct Dist { @@ -22,31 +22,3 @@ define_config! { vendor: Option = "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) { - 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() - }); - } - } -} From 924912c5322274419383cbb6e7209bfe82b3e7bd Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 11:46:00 +0530 Subject: [PATCH 03/27] move target parsing to parse_inner --- src/bootstrap/src/core/config/config.rs | 65 +++++++++++++++++- src/bootstrap/src/core/config/toml/target.rs | 70 +------------------- 2 files changed, 64 insertions(+), 71 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 62c528538c48d..8a6d90fa0b5ab 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -39,7 +39,7 @@ use crate::core::config::toml::build::{Build, Tool}; use crate::core::config::toml::change_id::ChangeId; use crate::core::config::toml::dist::Dist; use crate::core::config::toml::rust::{ - LldMode, RustOptimize, check_incompatible_options_for_ci_rustc, + LldMode, RustOptimize, check_incompatible_options_for_ci_rustc, validate_codegen_backends, }; use crate::core::config::toml::target::Target; use crate::core::config::{ @@ -956,7 +956,68 @@ impl Config { config.rust_profile_use = flags_rust_profile_use; config.rust_profile_generate = flags_rust_profile_generate; - config.apply_target_config(toml.target); + if let Some(t) = toml.target { + for (triple, cfg) in t { + let mut target = Target::from_triple(&triple); + + if let Some(ref s) = cfg.llvm_config { + if config.download_rustc_commit.is_some() + && triple == *config.host_target.triple + { + panic!( + "setting llvm_config for the host is incompatible with download-rustc" + ); + } + target.llvm_config = Some(config.src.join(s)); + } + if let Some(patches) = cfg.llvm_has_rust_patches { + assert!( + config.submodules == Some(false) || cfg.llvm_config.is_some(), + "use of `llvm-has-rust-patches` is restricted to cases where either submodules are disabled or llvm-config been provided" + ); + target.llvm_has_rust_patches = Some(patches); + } + if let Some(ref s) = cfg.llvm_filecheck { + target.llvm_filecheck = Some(config.src.join(s)); + } + target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| { + v.parse().unwrap_or_else(|_| { + panic!("failed to parse target.{triple}.llvm-libunwind") + }) + }); + if let Some(s) = cfg.no_std { + target.no_std = s; + } + target.cc = cfg.cc.map(PathBuf::from); + target.cxx = cfg.cxx.map(PathBuf::from); + target.ar = cfg.ar.map(PathBuf::from); + target.ranlib = cfg.ranlib.map(PathBuf::from); + target.linker = cfg.linker.map(PathBuf::from); + target.crt_static = cfg.crt_static; + target.musl_root = cfg.musl_root.map(PathBuf::from); + target.musl_libdir = cfg.musl_libdir.map(PathBuf::from); + target.wasi_root = cfg.wasi_root.map(PathBuf::from); + target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from); + target.runner = cfg.runner; + target.sanitizers = cfg.sanitizers; + target.profiler = cfg.profiler; + target.rpath = cfg.rpath; + target.optimized_compiler_builtins = cfg.optimized_compiler_builtins; + target.jemalloc = cfg.jemalloc; + if let Some(backends) = cfg.codegen_backends { + target.codegen_backends = + Some(validate_codegen_backends(backends, &format!("target.{triple}"))) + } + + target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| { + v.parse().unwrap_or_else(|_| { + panic!("invalid value for target.{triple}.split-debuginfo") + }) + }); + + config.target_config.insert(TargetSelection::from_user(&triple), target); + } + } config.apply_rust_config(toml.rust, flags_warnings); config.reproducible_artifacts = flags_reproducible_artifact; diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 9dedadff3a19d..0c9d2bd0ab5f2 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -12,13 +12,10 @@ //! applies it to the global [`Config`], ensuring proper path resolution, validation, //! and integration with other build settings. -use std::collections::HashMap; - use serde::{Deserialize, Deserializer}; -use crate::core::config::toml::rust::parse_codegen_backends; use crate::core::config::{LlvmLibunwind, Merge, ReplaceOpt, SplitDebuginfo, StringOrBool}; -use crate::{CodegenBackendKind, Config, HashSet, PathBuf, TargetSelection, define_config, exit}; +use crate::{HashSet, PathBuf, define_config, exit}; define_config! { /// TOML representation of how each build target is configured. @@ -93,68 +90,3 @@ impl Target { target } } - -impl Config { - pub fn apply_target_config(&mut self, toml_target: Option>) { - if let Some(t) = toml_target { - for (triple, cfg) in t { - let mut target = Target::from_triple(&triple); - - if let Some(ref s) = cfg.llvm_config { - if self.download_rustc_commit.is_some() && triple == *self.host_target.triple { - panic!( - "setting llvm_config for the host is incompatible with download-rustc" - ); - } - target.llvm_config = Some(self.src.join(s)); - } - if let Some(patches) = cfg.llvm_has_rust_patches { - assert!( - self.submodules == Some(false) || cfg.llvm_config.is_some(), - "use of `llvm-has-rust-patches` is restricted to cases where either submodules are disabled or llvm-config been provided" - ); - target.llvm_has_rust_patches = Some(patches); - } - if let Some(ref s) = cfg.llvm_filecheck { - target.llvm_filecheck = Some(self.src.join(s)); - } - target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| { - v.parse().unwrap_or_else(|_| { - panic!("failed to parse target.{triple}.llvm-libunwind") - }) - }); - if let Some(s) = cfg.no_std { - target.no_std = s; - } - target.cc = cfg.cc.map(PathBuf::from); - target.cxx = cfg.cxx.map(PathBuf::from); - target.ar = cfg.ar.map(PathBuf::from); - target.ranlib = cfg.ranlib.map(PathBuf::from); - target.linker = cfg.linker.map(PathBuf::from); - target.crt_static = cfg.crt_static; - target.musl_root = cfg.musl_root.map(PathBuf::from); - target.musl_libdir = cfg.musl_libdir.map(PathBuf::from); - target.wasi_root = cfg.wasi_root.map(PathBuf::from); - target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from); - target.runner = cfg.runner; - target.sanitizers = cfg.sanitizers; - target.profiler = cfg.profiler; - target.rpath = cfg.rpath; - target.optimized_compiler_builtins = cfg.optimized_compiler_builtins; - target.jemalloc = cfg.jemalloc; - if let Some(backends) = cfg.codegen_backends { - target.codegen_backends = - Some(parse_codegen_backends(backends, &format!("target.{triple}"))) - } - - target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| { - v.parse().unwrap_or_else(|_| { - panic!("invalid value for target.{triple}.split-debuginfo") - }) - }); - - self.target_config.insert(TargetSelection::from_user(&triple), target); - } - } - } -} From 89219ffc0e870398b38b398001190ab7d6082119 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 12:01:44 +0530 Subject: [PATCH 04/27] move install to parse_inner --- src/bootstrap/src/core/config/config.rs | 12 ++++++++++- src/bootstrap/src/core/config/toml/install.rs | 21 ++----------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 8a6d90fa0b5ab..a7cdc84977a2d 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -38,6 +38,7 @@ use crate::core::config::toml::TomlConfig; use crate::core::config::toml::build::{Build, Tool}; use crate::core::config::toml::change_id::ChangeId; use crate::core::config::toml::dist::Dist; +use crate::core::config::toml::install::Install; use crate::core::config::toml::rust::{ LldMode, RustOptimize, check_incompatible_options_for_ci_rustc, validate_codegen_backends, }; @@ -906,7 +907,16 @@ impl Config { // Verbose flag is a good default for `rust.verbose-tests`. config.verbose_tests = config.is_verbose(); - config.apply_install_config(toml.install); + if let Some(install) = toml.install { + let Install { prefix, sysconfdir, docdir, bindir, libdir, mandir, datadir } = install; + config.prefix = prefix.map(PathBuf::from); + config.sysconfdir = sysconfdir.map(PathBuf::from); + config.datadir = datadir.map(PathBuf::from); + config.docdir = docdir.map(PathBuf::from); + set(&mut config.bindir, bindir.map(PathBuf::from)); + config.libdir = libdir.map(PathBuf::from); + config.mandir = mandir.map(PathBuf::from); + } let file_content = t!(fs::read_to_string(config.src.join("src/ci/channel"))); let ci_channel = file_content.trim_end(); diff --git a/src/bootstrap/src/core/config/toml/install.rs b/src/bootstrap/src/core/config/toml/install.rs index 6b9ab87a0b663..da31c0cc878c0 100644 --- a/src/bootstrap/src/core/config/toml/install.rs +++ b/src/bootstrap/src/core/config/toml/install.rs @@ -8,9 +8,9 @@ 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. @@ -24,20 +24,3 @@ define_config! { datadir: Option = "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) { - 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); - } - } -} From 3248ff1f06927116f23262eeef0bbd04e7dfc737 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 12:24:30 +0530 Subject: [PATCH 05/27] move llvm parsing to parse_inner --- src/bootstrap/src/core/config/config.rs | 122 +++++++++++++++++++- src/bootstrap/src/core/config/toml/llvm.rs | 128 +-------------------- 2 files changed, 123 insertions(+), 127 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index a7cdc84977a2d..bb1185f859ab9 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -39,6 +39,7 @@ use crate::core::config::toml::build::{Build, Tool}; use crate::core::config::toml::change_id::ChangeId; use crate::core::config::toml::dist::Dist; use crate::core::config::toml::install::Install; +use crate::core::config::toml::llvm::Llvm; use crate::core::config::toml::rust::{ LldMode, RustOptimize, check_incompatible_options_for_ci_rustc, validate_codegen_backends, }; @@ -1049,7 +1050,126 @@ impl Config { config.channel = channel; } - config.apply_llvm_config(toml.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 config.ninja_in_file, ninja); + llvm_tests = tests; + llvm_enzyme = enzyme; + llvm_offload = offload; + llvm_plugins = plugins; + set(&mut config.llvm_optimize, optimize_toml); + set(&mut config.llvm_thin_lto, thin_lto); + set(&mut config.llvm_release_debuginfo, release_debuginfo); + set(&mut config.llvm_static_stdcpp, static_libstdcpp); + set(&mut config.llvm_libzstd, libzstd); + if let Some(v) = link_shared { + config.llvm_link_shared.set(Some(v)); + } + config.llvm_targets.clone_from(&targets); + config.llvm_experimental_targets.clone_from(&experimental_targets); + config.llvm_link_jobs = link_jobs; + config.llvm_version_suffix.clone_from(&version_suffix); + config.llvm_clang_cl.clone_from(&clang_cl); + + config.llvm_cflags.clone_from(&cflags); + config.llvm_cxxflags.clone_from(&cxxflags); + config.llvm_ldflags.clone_from(&ldflags); + set(&mut config.llvm_use_libcxx, use_libcxx); + config.llvm_use_linker.clone_from(&use_linker); + config.llvm_allow_old_toolchain = allow_old_toolchain.unwrap_or(false); + config.llvm_offload = offload.unwrap_or(false); + config.llvm_polly = polly.unwrap_or(false); + config.llvm_clang = clang.unwrap_or(false); + config.llvm_enable_warnings = enable_warnings.unwrap_or(false); + config.llvm_build_config = build_config.clone().unwrap_or(Default::default()); + + config.llvm_from_ci = + config.parse_download_ci_llvm(download_ci_llvm, config.llvm_assertions); + + if config.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 !config.llvm_from_ci && config.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. + config.llvm_link_shared.set(Some(true)); + } + } else { + config.llvm_from_ci = config.parse_download_ci_llvm(None, false); + } + + config.llvm_tests = llvm_tests.unwrap_or(false); + config.llvm_enzyme = llvm_enzyme.unwrap_or(false); + config.llvm_offload = llvm_offload.unwrap_or(false); + config.llvm_plugins = llvm_plugins.unwrap_or(false); if let Some(gcc) = toml.gcc { config.gcc_ci_mode = match gcc.download_ci_gcc { diff --git a/src/bootstrap/src/core/config/toml/llvm.rs b/src/bootstrap/src/core/config/toml/llvm.rs index 1f0cecd145c77..0ab290b9bd1e3 100644 --- a/src/bootstrap/src/core/config/toml/llvm.rs +++ b/src/bootstrap/src/core/config/toml/llvm.rs @@ -3,9 +3,9 @@ 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. @@ -144,127 +144,3 @@ pub fn check_incompatible_options_for_ci_llvm( Ok(()) } - -impl Config { - pub fn apply_llvm_config(&mut self, toml_llvm: Option) { - 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); - } -} From ddd2a547b2115684c77e1735cca2122d20075e98 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 12:31:06 +0530 Subject: [PATCH 06/27] move rust config to parse_inner --- src/bootstrap/src/core/config/config.rs | 250 +++++++++++++++++++- src/bootstrap/src/core/config/toml/rust.rs | 262 +-------------------- 2 files changed, 251 insertions(+), 261 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index bb1185f859ab9..b66a9db1336c0 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -32,7 +32,7 @@ use tracing::{instrument, span}; use crate::core::build_steps::llvm; use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS; pub use crate::core::config::flags::Subcommand; -use crate::core::config::flags::{Color, Flags}; +use crate::core::config::flags::{Color, Flags, Warnings}; use crate::core::config::target_selection::TargetSelectionList; use crate::core::config::toml::TomlConfig; use crate::core::config::toml::build::{Build, Tool}; @@ -41,7 +41,8 @@ use crate::core::config::toml::dist::Dist; use crate::core::config::toml::install::Install; use crate::core::config::toml::llvm::Llvm; use crate::core::config::toml::rust::{ - LldMode, RustOptimize, check_incompatible_options_for_ci_rustc, validate_codegen_backends, + LldMode, Rust, RustOptimize, check_incompatible_options_for_ci_rustc, + default_lld_opt_in_targets, validate_codegen_backends, }; use crate::core::config::toml::target::Target; use crate::core::config::{ @@ -1029,7 +1030,250 @@ impl Config { config.target_config.insert(TargetSelection::from_user(&triple), target); } } - config.apply_rust_config(toml.rust, flags_warnings); + let mut debug = None; + let mut rustc_debug_assertions = None; + let mut std_debug_assertions = None; + let mut tools_debug_assertions = None; + let mut overflow_checks = None; + let mut overflow_checks_std = None; + let mut debug_logging = None; + let mut debuginfo_level = None; + let mut debuginfo_level_rustc = None; + let mut debuginfo_level_std = None; + let mut debuginfo_level_tools = None; + let mut debuginfo_level_tests = None; + let mut optimize = None; + let mut lld_enabled = None; + let mut std_features = None; + + if let Some(rust) = toml.rust { + let Rust { + optimize: optimize_toml, + debug: debug_toml, + codegen_units, + codegen_units_std, + rustc_debug_assertions: rustc_debug_assertions_toml, + std_debug_assertions: std_debug_assertions_toml, + tools_debug_assertions: tools_debug_assertions_toml, + overflow_checks: overflow_checks_toml, + overflow_checks_std: overflow_checks_std_toml, + debug_logging: debug_logging_toml, + debuginfo_level: debuginfo_level_toml, + debuginfo_level_rustc: debuginfo_level_rustc_toml, + debuginfo_level_std: debuginfo_level_std_toml, + debuginfo_level_tools: debuginfo_level_tools_toml, + debuginfo_level_tests: debuginfo_level_tests_toml, + backtrace, + incremental, + randomize_layout, + default_linker, + channel: _, // already handled above + musl_root, + rpath, + verbose_tests, + optimize_tests, + codegen_tests, + omit_git_hash: _, // already handled above + dist_src, + save_toolstates, + codegen_backends, + lld: lld_enabled_toml, + llvm_tools, + llvm_bitcode_linker, + deny_warnings, + backtrace_on_ice, + verify_llvm_ir, + thin_lto_import_instr_limit, + remap_debuginfo, + jemalloc, + test_compare_mode, + llvm_libunwind, + control_flow_guard, + ehcont_guard, + new_symbol_mangling, + profile_generate, + profile_use, + download_rustc, + lto, + validate_mir_opts, + frame_pointers, + stack_protector, + strip, + lld_mode, + std_features: std_features_toml, + } = rust; + + // FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions + // enabled. We should not download a CI alt rustc if we need rustc to have debug + // assertions (e.g. for crashes test suite). This can be changed once something like + // [Enable debug assertions on alt + // builds](https://github.com/rust-lang/rust/pull/131077) lands. + // + // Note that `rust.debug = true` currently implies `rust.debug-assertions = true`! + // + // This relies also on the fact that the global default for `download-rustc` will be + // `false` if it's not explicitly set. + let debug_assertions_requested = matches!(rustc_debug_assertions_toml, Some(true)) + || (matches!(debug_toml, Some(true)) + && !matches!(rustc_debug_assertions_toml, Some(false))); + + if debug_assertions_requested + && let Some(ref opt) = download_rustc + && opt.is_string_or_true() + { + eprintln!( + "WARN: currently no CI rustc builds have rustc debug assertions \ + enabled. Please either set `rust.debug-assertions` to `false` if you \ + want to use download CI rustc or set `rust.download-rustc` to `false`." + ); + } + + config.download_rustc_commit = config.download_ci_rustc_commit( + download_rustc, + debug_assertions_requested, + config.llvm_assertions, + ); + + debug = debug_toml; + rustc_debug_assertions = rustc_debug_assertions_toml; + std_debug_assertions = std_debug_assertions_toml; + tools_debug_assertions = tools_debug_assertions_toml; + overflow_checks = overflow_checks_toml; + overflow_checks_std = overflow_checks_std_toml; + debug_logging = debug_logging_toml; + debuginfo_level = debuginfo_level_toml; + debuginfo_level_rustc = debuginfo_level_rustc_toml; + debuginfo_level_std = debuginfo_level_std_toml; + debuginfo_level_tools = debuginfo_level_tools_toml; + debuginfo_level_tests = debuginfo_level_tests_toml; + lld_enabled = lld_enabled_toml; + std_features = std_features_toml; + + if optimize_toml.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { + eprintln!( + "WARNING: setting `optimize` to `false` is known to cause errors and \ + should be considered unsupported. Refer to `bootstrap.example.toml` \ + for more details." + ); + } + + optimize = optimize_toml; + config.rust_new_symbol_mangling = new_symbol_mangling; + set(&mut config.rust_optimize_tests, optimize_tests); + set(&mut config.codegen_tests, codegen_tests); + set(&mut config.rust_rpath, rpath); + set(&mut config.rust_strip, strip); + set(&mut config.rust_frame_pointers, frame_pointers); + config.rust_stack_protector = stack_protector; + set(&mut config.jemalloc, jemalloc); + set(&mut config.test_compare_mode, test_compare_mode); + set(&mut config.backtrace, backtrace); + set(&mut config.rust_dist_src, dist_src); + set(&mut config.verbose_tests, verbose_tests); + // in the case "false" is set explicitly, do not overwrite the command line args + if let Some(true) = incremental { + config.incremental = true; + } + set(&mut config.lld_mode, lld_mode); + set(&mut config.llvm_bitcode_linker_enabled, llvm_bitcode_linker); + + config.rust_randomize_layout = randomize_layout.unwrap_or_default(); + config.llvm_tools_enabled = llvm_tools.unwrap_or(true); + + config.llvm_enzyme = config.channel == "dev" || config.channel == "nightly"; + config.rustc_default_linker = default_linker; + config.musl_root = musl_root.map(PathBuf::from); + config.save_toolstates = save_toolstates.map(PathBuf::from); + set( + &mut config.deny_warnings, + match flags_warnings { + Warnings::Deny => Some(true), + Warnings::Warn => Some(false), + Warnings::Default => deny_warnings, + }, + ); + set(&mut config.backtrace_on_ice, backtrace_on_ice); + set(&mut config.rust_verify_llvm_ir, verify_llvm_ir); + config.rust_thin_lto_import_instr_limit = thin_lto_import_instr_limit; + set(&mut config.rust_remap_debuginfo, remap_debuginfo); + set(&mut config.control_flow_guard, control_flow_guard); + set(&mut config.ehcont_guard, ehcont_guard); + config.llvm_libunwind_default = + llvm_libunwind.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); + set( + &mut config.rust_codegen_backends, + codegen_backends.map(|backends| validate_codegen_backends(backends, "rust")), + ); + + config.rust_codegen_units = codegen_units.map(threads_from_config); + config.rust_codegen_units_std = codegen_units_std.map(threads_from_config); + + if config.rust_profile_use.is_none() { + config.rust_profile_use = profile_use; + } + + if config.rust_profile_generate.is_none() { + config.rust_profile_generate = profile_generate; + } + + config.rust_lto = + lto.as_deref().map(|value| RustcLto::from_str(value).unwrap()).unwrap_or_default(); + config.rust_validate_mir_opts = validate_mir_opts; + } + + config.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true)); + + // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will + // build our internal lld and use it as the default linker, by setting the `rust.lld` config + // to true by default: + // - on the `x86_64-unknown-linux-gnu` target + // - when building our in-tree llvm (i.e. the target has not set an `llvm-config`), so that + // we're also able to build the corresponding lld + // - or when using an external llvm that's downloaded from CI, which also contains our prebuilt + // lld + // - otherwise, we'd be using an external llvm, and lld would not necessarily available and + // thus, disabled + // - similarly, lld will not be built nor used by default when explicitly asked not to, e.g. + // when the config sets `rust.lld = false` + if default_lld_opt_in_targets().contains(&config.host_target.triple.to_string()) + && config.hosts == [config.host_target] + { + let no_llvm_config = config + .target_config + .get(&config.host_target) + .is_none_or(|target_config| target_config.llvm_config.is_none()); + let enable_lld = config.llvm_from_ci || no_llvm_config; + // Prefer the config setting in case an explicit opt-out is needed. + config.lld_enabled = lld_enabled.unwrap_or(enable_lld); + } else { + set(&mut config.lld_enabled, lld_enabled); + } + + let default_std_features = BTreeSet::from([String::from("panic-unwind")]); + config.rust_std_features = std_features.unwrap_or(default_std_features); + + let default = debug == Some(true); + config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default); + config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions); + config.tools_debug_assertions = + tools_debug_assertions.unwrap_or(config.rustc_debug_assertions); + config.rust_overflow_checks = overflow_checks.unwrap_or(default); + config.rust_overflow_checks_std = + overflow_checks_std.unwrap_or(config.rust_overflow_checks); + + config.rust_debug_logging = debug_logging.unwrap_or(config.rustc_debug_assertions); + + let with_defaults = |debuginfo_level_specific: Option<_>| { + debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) { + DebuginfoLevel::Limited + } else { + DebuginfoLevel::None + }) + }; + config.rust_debuginfo_level_rustc = with_defaults(debuginfo_level_rustc); + config.rust_debuginfo_level_std = with_defaults(debuginfo_level_std); + config.rust_debuginfo_level_tools = with_defaults(debuginfo_level_tools); + config.rust_debuginfo_level_tests = debuginfo_level_tests.unwrap_or(DebuginfoLevel::None); config.reproducible_artifacts = flags_reproducible_artifact; config.description = description; diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 03da993a17dd2..4bd1eac683ce1 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -1,19 +1,12 @@ //! This module defines the `Rust` struct, which represents the `[rust]` table //! in the `bootstrap.toml` configuration file. -use std::str::FromStr; - use serde::{Deserialize, Deserializer}; use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX; use crate::core::config::toml::TomlConfig; -use crate::core::config::{ - DebuginfoLevel, Merge, ReplaceOpt, RustcLto, StringOrBool, set, threads_from_config, -}; -use crate::flags::Warnings; -use crate::{ - BTreeSet, CodegenBackendKind, Config, HashSet, PathBuf, TargetSelection, define_config, exit, -}; +use crate::core::config::{DebuginfoLevel, Merge, ReplaceOpt, StringOrBool}; +use crate::{BTreeSet, HashSet, PathBuf, TargetSelection, define_config, exit}; define_config! { /// TOML representation of how the Rust build is configured. @@ -424,7 +417,7 @@ pub(crate) fn parse_codegen_backends( } #[cfg(not(test))] -fn default_lld_opt_in_targets() -> Vec { +pub fn default_lld_opt_in_targets() -> Vec { vec!["x86_64-unknown-linux-gnu".to_string()] } @@ -434,7 +427,7 @@ thread_local! { } #[cfg(test)] -fn default_lld_opt_in_targets() -> Vec { +pub fn default_lld_opt_in_targets() -> Vec { TEST_LLD_OPT_IN_TARGETS.with(|cell| cell.borrow().clone()).unwrap_or_default() } @@ -447,250 +440,3 @@ pub fn with_lld_opt_in_targets(targets: Vec, f: impl FnOnce() -> R) - result }) } - -impl Config { - pub fn apply_rust_config(&mut self, toml_rust: Option, warnings: Warnings) { - let mut debug = None; - let mut rustc_debug_assertions = None; - let mut std_debug_assertions = None; - let mut tools_debug_assertions = None; - let mut overflow_checks = None; - let mut overflow_checks_std = None; - let mut debug_logging = None; - let mut debuginfo_level = None; - let mut debuginfo_level_rustc = None; - let mut debuginfo_level_std = None; - let mut debuginfo_level_tools = None; - let mut debuginfo_level_tests = None; - let mut optimize = None; - let mut lld_enabled = None; - let mut std_features = None; - - if let Some(rust) = toml_rust { - let Rust { - optimize: optimize_toml, - debug: debug_toml, - codegen_units, - codegen_units_std, - rustc_debug_assertions: rustc_debug_assertions_toml, - std_debug_assertions: std_debug_assertions_toml, - tools_debug_assertions: tools_debug_assertions_toml, - overflow_checks: overflow_checks_toml, - overflow_checks_std: overflow_checks_std_toml, - debug_logging: debug_logging_toml, - debuginfo_level: debuginfo_level_toml, - debuginfo_level_rustc: debuginfo_level_rustc_toml, - debuginfo_level_std: debuginfo_level_std_toml, - debuginfo_level_tools: debuginfo_level_tools_toml, - debuginfo_level_tests: debuginfo_level_tests_toml, - backtrace, - incremental, - randomize_layout, - default_linker, - channel: _, // already handled above - musl_root, - rpath, - verbose_tests, - optimize_tests, - codegen_tests, - omit_git_hash: _, // already handled above - dist_src, - save_toolstates, - codegen_backends, - lld: lld_enabled_toml, - llvm_tools, - llvm_bitcode_linker, - deny_warnings, - backtrace_on_ice, - verify_llvm_ir, - thin_lto_import_instr_limit, - remap_debuginfo, - jemalloc, - test_compare_mode, - llvm_libunwind, - control_flow_guard, - ehcont_guard, - new_symbol_mangling, - profile_generate, - profile_use, - download_rustc, - lto, - validate_mir_opts, - frame_pointers, - stack_protector, - strip, - lld_mode, - std_features: std_features_toml, - } = rust; - - // FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions - // enabled. We should not download a CI alt rustc if we need rustc to have debug - // assertions (e.g. for crashes test suite). This can be changed once something like - // [Enable debug assertions on alt - // builds](https://github.com/rust-lang/rust/pull/131077) lands. - // - // Note that `rust.debug = true` currently implies `rust.debug-assertions = true`! - // - // This relies also on the fact that the global default for `download-rustc` will be - // `false` if it's not explicitly set. - let debug_assertions_requested = matches!(rustc_debug_assertions_toml, Some(true)) - || (matches!(debug_toml, Some(true)) - && !matches!(rustc_debug_assertions_toml, Some(false))); - - if debug_assertions_requested - && let Some(ref opt) = download_rustc - && opt.is_string_or_true() - { - eprintln!( - "WARN: currently no CI rustc builds have rustc debug assertions \ - enabled. Please either set `rust.debug-assertions` to `false` if you \ - want to use download CI rustc or set `rust.download-rustc` to `false`." - ); - } - - self.download_rustc_commit = self.download_ci_rustc_commit( - download_rustc, - debug_assertions_requested, - self.llvm_assertions, - ); - - debug = debug_toml; - rustc_debug_assertions = rustc_debug_assertions_toml; - std_debug_assertions = std_debug_assertions_toml; - tools_debug_assertions = tools_debug_assertions_toml; - overflow_checks = overflow_checks_toml; - overflow_checks_std = overflow_checks_std_toml; - debug_logging = debug_logging_toml; - debuginfo_level = debuginfo_level_toml; - debuginfo_level_rustc = debuginfo_level_rustc_toml; - debuginfo_level_std = debuginfo_level_std_toml; - debuginfo_level_tools = debuginfo_level_tools_toml; - debuginfo_level_tests = debuginfo_level_tests_toml; - lld_enabled = lld_enabled_toml; - std_features = std_features_toml; - - if optimize_toml.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { - eprintln!( - "WARNING: setting `optimize` to `false` is known to cause errors and \ - should be considered unsupported. Refer to `bootstrap.example.toml` \ - for more details." - ); - } - - optimize = optimize_toml; - self.rust_new_symbol_mangling = new_symbol_mangling; - set(&mut self.rust_optimize_tests, optimize_tests); - set(&mut self.codegen_tests, codegen_tests); - set(&mut self.rust_rpath, rpath); - set(&mut self.rust_strip, strip); - set(&mut self.rust_frame_pointers, frame_pointers); - self.rust_stack_protector = stack_protector; - set(&mut self.jemalloc, jemalloc); - set(&mut self.test_compare_mode, test_compare_mode); - set(&mut self.backtrace, backtrace); - set(&mut self.rust_dist_src, dist_src); - set(&mut self.verbose_tests, verbose_tests); - // in the case "false" is set explicitly, do not overwrite the command line args - if let Some(true) = incremental { - self.incremental = true; - } - set(&mut self.lld_mode, lld_mode); - set(&mut self.llvm_bitcode_linker_enabled, llvm_bitcode_linker); - - self.rust_randomize_layout = randomize_layout.unwrap_or_default(); - self.llvm_tools_enabled = llvm_tools.unwrap_or(true); - - self.llvm_enzyme = self.channel == "dev" || self.channel == "nightly"; - self.rustc_default_linker = default_linker; - self.musl_root = musl_root.map(PathBuf::from); - self.save_toolstates = save_toolstates.map(PathBuf::from); - set( - &mut self.deny_warnings, - match warnings { - Warnings::Deny => Some(true), - Warnings::Warn => Some(false), - Warnings::Default => deny_warnings, - }, - ); - set(&mut self.backtrace_on_ice, backtrace_on_ice); - set(&mut self.rust_verify_llvm_ir, verify_llvm_ir); - self.rust_thin_lto_import_instr_limit = thin_lto_import_instr_limit; - set(&mut self.rust_remap_debuginfo, remap_debuginfo); - set(&mut self.control_flow_guard, control_flow_guard); - set(&mut self.ehcont_guard, ehcont_guard); - self.llvm_libunwind_default = - llvm_libunwind.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); - set( - &mut self.rust_codegen_backends, - codegen_backends.map(|backends| parse_codegen_backends(backends, "rust")), - ); - - self.rust_codegen_units = codegen_units.map(threads_from_config); - self.rust_codegen_units_std = codegen_units_std.map(threads_from_config); - - if self.rust_profile_use.is_none() { - self.rust_profile_use = profile_use; - } - - if self.rust_profile_generate.is_none() { - self.rust_profile_generate = profile_generate; - } - - self.rust_lto = - lto.as_deref().map(|value| RustcLto::from_str(value).unwrap()).unwrap_or_default(); - self.rust_validate_mir_opts = validate_mir_opts; - } - - self.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true)); - - // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will - // build our internal lld and use it as the default linker, by setting the `rust.lld` config - // to true by default: - // - on the `x86_64-unknown-linux-gnu` target - // - when building our in-tree llvm (i.e. the target has not set an `llvm-config`), so that - // we're also able to build the corresponding lld - // - or when using an external llvm that's downloaded from CI, which also contains our prebuilt - // lld - // - otherwise, we'd be using an external llvm, and lld would not necessarily available and - // thus, disabled - // - similarly, lld will not be built nor used by default when explicitly asked not to, e.g. - // when the config sets `rust.lld = false` - if default_lld_opt_in_targets().contains(&self.host_target.triple.to_string()) - && self.hosts == [self.host_target] - { - let no_llvm_config = self - .target_config - .get(&self.host_target) - .is_none_or(|target_config| target_config.llvm_config.is_none()); - let enable_lld = self.llvm_from_ci || no_llvm_config; - // Prefer the config setting in case an explicit opt-out is needed. - self.lld_enabled = lld_enabled.unwrap_or(enable_lld); - } else { - set(&mut self.lld_enabled, lld_enabled); - } - - let default_std_features = BTreeSet::from([String::from("panic-unwind")]); - self.rust_std_features = std_features.unwrap_or(default_std_features); - - let default = debug == Some(true); - self.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default); - self.std_debug_assertions = std_debug_assertions.unwrap_or(self.rustc_debug_assertions); - self.tools_debug_assertions = tools_debug_assertions.unwrap_or(self.rustc_debug_assertions); - self.rust_overflow_checks = overflow_checks.unwrap_or(default); - self.rust_overflow_checks_std = overflow_checks_std.unwrap_or(self.rust_overflow_checks); - - self.rust_debug_logging = debug_logging.unwrap_or(self.rustc_debug_assertions); - - let with_defaults = |debuginfo_level_specific: Option<_>| { - debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) { - DebuginfoLevel::Limited - } else { - DebuginfoLevel::None - }) - }; - self.rust_debuginfo_level_rustc = with_defaults(debuginfo_level_rustc); - self.rust_debuginfo_level_std = with_defaults(debuginfo_level_std); - self.rust_debuginfo_level_tools = with_defaults(debuginfo_level_tools); - self.rust_debuginfo_level_tests = debuginfo_level_tests.unwrap_or(DebuginfoLevel::None); - } -} From ae05591ade894daf8ac1974f001111b5520fcecf Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 15:30:03 +0530 Subject: [PATCH 07/27] Force initializing ExecutionContext with verbosity and fail_fast mode --- src/bootstrap/src/core/config/config.rs | 4 +--- src/bootstrap/src/utils/exec.rs | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index b66a9db1336c0..1dd62d9b75631 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -454,9 +454,7 @@ impl Config { } = flags; let mut config = Config::default_opts(); - let mut exec_ctx = ExecutionContext::new(); - exec_ctx.set_verbose(flags_verbose); - exec_ctx.set_fail_fast(flags_cmd.fail_fast()); + let exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast()); config.exec_ctx = exec_ctx; diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index 209ff39397313..26582214c9307 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -550,7 +550,7 @@ impl Default for CommandOutput { #[derive(Clone, Default)] pub struct ExecutionContext { dry_run: DryRun, - verbose: u8, + verbosity: u8, pub fail_fast: bool, delayed_failures: Arc>>, command_cache: Arc, @@ -603,8 +603,8 @@ impl CommandCache { } impl ExecutionContext { - pub fn new() -> Self { - ExecutionContext::default() + pub fn new(verbosity: u8, fail_fast: bool) -> Self { + Self { verbosity, fail_fast, ..Default::default() } } pub fn dry_run(&self) -> bool { @@ -629,7 +629,7 @@ impl ExecutionContext { } pub fn is_verbose(&self) -> bool { - self.verbose > 0 + self.verbosity > 0 } pub fn fail_fast(&self) -> bool { @@ -641,7 +641,7 @@ impl ExecutionContext { } pub fn set_verbose(&mut self, value: u8) { - self.verbose = value; + self.verbosity = value; } pub fn set_fail_fast(&mut self, value: bool) { From 82756fd5f3b8abfef1838aac86f97ba96ca9612f Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 15:37:21 +0530 Subject: [PATCH 08/27] Extract TOML config loading and src directory computation into separate functions --- src/bootstrap/src/core/config/config.rs | 206 ++++++++++++++---------- 1 file changed, 117 insertions(+), 89 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 1dd62d9b75631..61787162a7e76 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -453,11 +453,21 @@ impl Config { skip_std_check_if_no_download_rustc: flags_skip_std_check_if_no_download_rustc, } = flags; + // First initialize the bare minimum that we need for further operation - source directory + // and execution context. let mut config = Config::default_opts(); let exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast()); config.exec_ctx = exec_ctx; + if let Some(src) = compute_src_directory(flags_src, &config.exec_ctx) { + config.src = src; + } + + // Now load the TOML config, as soon as possible + let (mut toml, toml_path) = load_toml_config(&config.src, flags_config, &get_toml); + config.config = toml_path.clone(); + // Set flags. config.paths = std::mem::take(&mut flags_paths); @@ -501,53 +511,6 @@ impl Config { // Infer the rest of the configuration. - if let Some(src) = flags_src { - config.src = src - } else { - // Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary, - // running on a completely different machine from where it was compiled. - let mut cmd = helpers::git(None); - // NOTE: we cannot support running from outside the repository because the only other path we have available - // is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally. - // We still support running outside the repository if we find we aren't in a git directory. - - // NOTE: We get a relative path from git to work around an issue on MSYS/mingw. If we used an absolute path, - // and end up using MSYS's git rather than git-for-windows, we would get a unix-y MSYS path. But as bootstrap - // has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path. - cmd.arg("rev-parse").arg("--show-cdup"); - // Discard stderr because we expect this to fail when building from a tarball. - let output = cmd.allow_failure().run_capture_stdout(&config); - if output.is_success() { - let git_root_relative = output.stdout(); - // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes, - // and to resolve any relative components. - let git_root = env::current_dir() - .unwrap() - .join(PathBuf::from(git_root_relative.trim())) - .canonicalize() - .unwrap(); - let s = git_root.to_str().unwrap(); - - // Bootstrap is quite bad at handling /? in front of paths - let git_root = match s.strip_prefix("\\\\?\\") { - Some(p) => PathBuf::from(p), - None => git_root, - }; - // If this doesn't have at least `stage0`, we guessed wrong. This can happen when, - // for example, the build directory is inside of another unrelated git directory. - // In that case keep the original `CARGO_MANIFEST_DIR` handling. - // - // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside - // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1. - if git_root.join("src").join("stage0").exists() { - config.src = git_root; - } - } else { - // We're building from a tarball, not git sources. - // We don't support pre-downloaded bootstrap in this case. - } - } - if cfg!(test) { // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. config.out = Path::new( @@ -560,47 +523,6 @@ impl Config { config.stage0_metadata = build_helper::stage0_parser::parse_stage0_file(); - // Locate the configuration file using the following priority (first match wins): - // 1. `--config ` (explicit flag) - // 2. `RUST_BOOTSTRAP_CONFIG` environment variable - // 3. `./bootstrap.toml` (local file) - // 4. `/bootstrap.toml` - // 5. `./config.toml` (fallback for backward compatibility) - // 6. `/config.toml` - let toml_path = flags_config - .clone() - .or_else(|| env::var_os("RUST_BOOTSTRAP_CONFIG").map(PathBuf::from)); - let using_default_path = toml_path.is_none(); - let mut toml_path = toml_path.unwrap_or_else(|| PathBuf::from("bootstrap.toml")); - - if using_default_path && !toml_path.exists() { - toml_path = config.src.join(PathBuf::from("bootstrap.toml")); - if !toml_path.exists() { - toml_path = PathBuf::from("config.toml"); - if !toml_path.exists() { - toml_path = config.src.join(PathBuf::from("config.toml")); - } - } - } - - // Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path, - // but not if `bootstrap.toml` hasn't been created. - let mut toml = if !using_default_path || toml_path.exists() { - config.config = Some(if cfg!(not(test)) { - toml_path = toml_path.canonicalize().unwrap(); - toml_path.clone() - } else { - toml_path.clone() - }); - get_toml(&toml_path).unwrap_or_else(|e| { - eprintln!("ERROR: Failed to parse '{}': {e}", toml_path.display()); - exit!(2); - }) - } else { - config.config = None; - TomlConfig::default() - }; - if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the // same ones used to call the tests (if custom ones are not defined in the toml). If we @@ -622,7 +544,12 @@ impl Config { // This must be handled before applying the `profile` since `include`s should always take // precedence over `profile`s. for include_path in toml.include.clone().unwrap_or_default().iter().rev() { - let include_path = toml_path.parent().unwrap().join(include_path); + let include_path = toml_path + .as_ref() + .expect("include found in default TOML config") + .parent() + .unwrap() + .join(include_path); let included_toml = get_toml(&include_path).unwrap_or_else(|e| { eprintln!("ERROR: Failed to parse '{}': {e}", include_path.display()); @@ -2309,3 +2236,104 @@ impl AsRef for Config { &self.exec_ctx } } + +fn compute_src_directory(src_dir: Option, exec_ctx: &ExecutionContext) -> Option { + if let Some(src) = src_dir { + return Some(src); + } else { + // Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary, + // running on a completely different machine from where it was compiled. + let mut cmd = helpers::git(None); + // NOTE: we cannot support running from outside the repository because the only other path we have available + // is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally. + // We still support running outside the repository if we find we aren't in a git directory. + + // NOTE: We get a relative path from git to work around an issue on MSYS/mingw. If we used an absolute path, + // and end up using MSYS's git rather than git-for-windows, we would get a unix-y MSYS path. But as bootstrap + // has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path. + cmd.arg("rev-parse").arg("--show-cdup"); + // Discard stderr because we expect this to fail when building from a tarball. + let output = cmd.allow_failure().run_capture_stdout(exec_ctx); + if output.is_success() { + let git_root_relative = output.stdout(); + // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes, + // and to resolve any relative components. + let git_root = env::current_dir() + .unwrap() + .join(PathBuf::from(git_root_relative.trim())) + .canonicalize() + .unwrap(); + let s = git_root.to_str().unwrap(); + + // Bootstrap is quite bad at handling /? in front of paths + let git_root = match s.strip_prefix("\\\\?\\") { + Some(p) => PathBuf::from(p), + None => git_root, + }; + // If this doesn't have at least `stage0`, we guessed wrong. This can happen when, + // for example, the build directory is inside of another unrelated git directory. + // In that case keep the original `CARGO_MANIFEST_DIR` handling. + // + // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside + // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1. + if git_root.join("src").join("stage0").exists() { + return Some(git_root); + } + } else { + // We're building from a tarball, not git sources. + // We don't support pre-downloaded bootstrap in this case. + } + }; + None +} + +/// Loads bootstrap TOML config and returns the config together with a path from where +/// it was loaded. +/// `src` is the source root directory, and `config_path` is an optionally provided path to the +/// config. +fn load_toml_config( + src: &Path, + config_path: Option, + get_toml: &impl Fn(&Path) -> Result, +) -> (TomlConfig, Option) { + // Locate the configuration file using the following priority (first match wins): + // 1. `--config ` (explicit flag) + // 2. `RUST_BOOTSTRAP_CONFIG` environment variable + // 3. `./bootstrap.toml` (local file) + // 4. `/bootstrap.toml` + // 5. `./config.toml` (fallback for backward compatibility) + // 6. `/config.toml` + let toml_path = config_path.or_else(|| env::var_os("RUST_BOOTSTRAP_CONFIG").map(PathBuf::from)); + let using_default_path = toml_path.is_none(); + let mut toml_path = toml_path.unwrap_or_else(|| PathBuf::from("bootstrap.toml")); + + if using_default_path && !toml_path.exists() { + toml_path = src.join(PathBuf::from("bootstrap.toml")); + if !toml_path.exists() { + toml_path = PathBuf::from("config.toml"); + if !toml_path.exists() { + toml_path = src.join(PathBuf::from("config.toml")); + } + } + } + + // Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path, + // but not if `bootstrap.toml` hasn't been created. + if !using_default_path || toml_path.exists() { + let path = Some(if cfg!(not(test)) { + toml_path = toml_path.canonicalize().unwrap(); + toml_path.clone() + } else { + toml_path.clone() + }); + ( + get_toml(&toml_path).unwrap_or_else(|e| { + eprintln!("ERROR: Failed to parse '{}': {e}", toml_path.display()); + exit!(2); + }), + path, + ) + } else { + (TomlConfig::default(), None) + } +} From f89ea086c43b745d0b655967bd469b2891834967 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 16:21:20 +0530 Subject: [PATCH 09/27] Split TOML postprocessing into a separate function --- src/bootstrap/src/core/config/config.rs | 213 +++++++++++++----------- 1 file changed, 114 insertions(+), 99 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 61787162a7e76..99b99f4660a2b 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -468,6 +468,15 @@ impl Config { let (mut toml, toml_path) = load_toml_config(&config.src, flags_config, &get_toml); config.config = toml_path.clone(); + postprocess_toml( + &mut toml, + &config.src, + toml_path, + config.exec_ctx(), + &flags_set, + &get_toml, + ); + // Set flags. config.paths = std::mem::take(&mut flags_paths); @@ -534,105 +543,6 @@ impl Config { build.cargo = build.cargo.take().or(std::env::var_os("CARGO").map(|p| p.into())); } - if config.git_info(false, &config.src).is_from_tarball() && toml.profile.is_none() { - toml.profile = Some("dist".into()); - } - - // Reverse the list to ensure the last added config extension remains the most dominant. - // For example, given ["a.toml", "b.toml"], "b.toml" should take precedence over "a.toml". - // - // This must be handled before applying the `profile` since `include`s should always take - // precedence over `profile`s. - for include_path in toml.include.clone().unwrap_or_default().iter().rev() { - let include_path = toml_path - .as_ref() - .expect("include found in default TOML config") - .parent() - .unwrap() - .join(include_path); - - let included_toml = get_toml(&include_path).unwrap_or_else(|e| { - eprintln!("ERROR: Failed to parse '{}': {e}", include_path.display()); - exit!(2); - }); - toml.merge( - Some(include_path), - &mut Default::default(), - included_toml, - ReplaceOpt::IgnoreDuplicate, - ); - } - - if let Some(include) = &toml.profile { - // Allows creating alias for profile names, allowing - // profiles to be renamed while maintaining back compatibility - // Keep in sync with `profile_aliases` in bootstrap.py - let profile_aliases = HashMap::from([("user", "dist")]); - let include = match profile_aliases.get(include.as_str()) { - Some(alias) => alias, - None => include.as_str(), - }; - let mut include_path = config.src.clone(); - include_path.push("src"); - include_path.push("bootstrap"); - include_path.push("defaults"); - include_path.push(format!("bootstrap.{include}.toml")); - let included_toml = get_toml(&include_path).unwrap_or_else(|e| { - eprintln!( - "ERROR: Failed to parse default config profile at '{}': {e}", - include_path.display() - ); - exit!(2); - }); - toml.merge( - Some(include_path), - &mut Default::default(), - included_toml, - ReplaceOpt::IgnoreDuplicate, - ); - } - - let mut override_toml = TomlConfig::default(); - for option in flags_set.iter() { - fn get_table(option: &str) -> Result { - toml::from_str(option).and_then(|table: toml::Value| TomlConfig::deserialize(table)) - } - - let mut err = match get_table(option) { - Ok(v) => { - override_toml.merge( - None, - &mut Default::default(), - v, - ReplaceOpt::ErrorOnDuplicate, - ); - continue; - } - Err(e) => e, - }; - // We want to be able to set string values without quotes, - // like in `configure.py`. Try adding quotes around the right hand side - if let Some((key, value)) = option.split_once('=') - && !value.contains('"') - { - match get_table(&format!(r#"{key}="{value}""#)) { - Ok(v) => { - override_toml.merge( - None, - &mut Default::default(), - v, - ReplaceOpt::ErrorOnDuplicate, - ); - continue; - } - Err(e) => err = e, - } - } - eprintln!("failed to parse override `{option}`: `{err}"); - exit!(2) - } - toml.merge(None, &mut Default::default(), override_toml, ReplaceOpt::Override); - config.change_id = toml.change_id.inner; let Build { @@ -2337,3 +2247,108 @@ fn load_toml_config( (TomlConfig::default(), None) } } + +fn postprocess_toml( + toml: &mut TomlConfig, + src_dir: &Path, + toml_path: Option, + exec_ctx: &ExecutionContext, + override_set: &[String], + get_toml: &impl Fn(&Path) -> Result, +) { + let git_info = GitInfo::new(false, src_dir, exec_ctx); + + if git_info.is_from_tarball() && toml.profile.is_none() { + toml.profile = Some("dist".into()); + } + + // Reverse the list to ensure the last added config extension remains the most dominant. + // For example, given ["a.toml", "b.toml"], "b.toml" should take precedence over "a.toml". + // + // This must be handled before applying the `profile` since `include`s should always take + // precedence over `profile`s. + for include_path in toml.include.clone().unwrap_or_default().iter().rev() { + let include_path = toml_path + .as_ref() + .expect("include found in default TOML config") + .parent() + .unwrap() + .join(include_path); + + let included_toml = get_toml(&include_path).unwrap_or_else(|e| { + eprintln!("ERROR: Failed to parse '{}': {e}", include_path.display()); + exit!(2); + }); + toml.merge( + Some(include_path), + &mut Default::default(), + included_toml, + ReplaceOpt::IgnoreDuplicate, + ); + } + + if let Some(include) = &toml.profile { + // Allows creating alias for profile names, allowing + // profiles to be renamed while maintaining back compatibility + // Keep in sync with `profile_aliases` in bootstrap.py + let profile_aliases = HashMap::from([("user", "dist")]); + let include = match profile_aliases.get(include.as_str()) { + Some(alias) => alias, + None => include.as_str(), + }; + let mut include_path = PathBuf::from(src_dir); + include_path.push("src"); + include_path.push("bootstrap"); + include_path.push("defaults"); + include_path.push(format!("bootstrap.{include}.toml")); + let included_toml = get_toml(&include_path).unwrap_or_else(|e| { + eprintln!( + "ERROR: Failed to parse default config profile at '{}': {e}", + include_path.display() + ); + exit!(2); + }); + toml.merge( + Some(include_path.into()), + &mut Default::default(), + included_toml, + ReplaceOpt::IgnoreDuplicate, + ); + } + + let mut override_toml = TomlConfig::default(); + for option in override_set.iter() { + fn get_table(option: &str) -> Result { + toml::from_str(option).and_then(|table: toml::Value| TomlConfig::deserialize(table)) + } + + let mut err = match get_table(option) { + Ok(v) => { + override_toml.merge(None, &mut Default::default(), v, ReplaceOpt::ErrorOnDuplicate); + continue; + } + Err(e) => e, + }; + // We want to be able to set string values without quotes, + // like in `configure.py`. Try adding quotes around the right hand side + if let Some((key, value)) = option.split_once('=') + && !value.contains('"') + { + match get_table(&format!(r#"{key}="{value}""#)) { + Ok(v) => { + override_toml.merge( + None, + &mut Default::default(), + v, + ReplaceOpt::ErrorOnDuplicate, + ); + continue; + } + Err(e) => err = e, + } + } + eprintln!("failed to parse override `{option}`: `{err}"); + exit!(2) + } + toml.merge(None, &mut Default::default(), override_toml, ReplaceOpt::Override); +} From cfc40de9c504c9e05bd9905e3f99011199026ac8 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 16:48:14 +0530 Subject: [PATCH 10/27] Override some build TOML values by flags --- src/bootstrap/src/core/config/config.rs | 276 +++++++++++++----------- 1 file changed, 149 insertions(+), 127 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 99b99f4660a2b..49359afbed623 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -477,61 +477,6 @@ impl Config { &get_toml, ); - // Set flags. - config.paths = std::mem::take(&mut flags_paths); - - #[cfg(feature = "tracing")] - span!( - target: "CONFIG_HANDLING", - tracing::Level::TRACE, - "collecting paths and path exclusions", - "flags.paths" = ?flags_paths, - "flags.skip" = ?flags_skip, - "flags.exclude" = ?flags_exclude - ); - - #[cfg(feature = "tracing")] - span!( - target: "CONFIG_HANDLING", - tracing::Level::TRACE, - "normalizing and combining `flag.skip`/`flag.exclude` paths", - "config.skip" = ?config.skip, - ); - - config.include_default_paths = flags_include_default_paths; - config.rustc_error_format = flags_rustc_error_format; - config.json_output = flags_json_output; - config.compile_time_deps = flags_compile_time_deps; - config.on_fail = flags_on_fail; - config.cmd = flags_cmd; - config.incremental = flags_incremental; - config.set_dry_run(if flags_dry_run { DryRun::UserSelected } else { DryRun::Disabled }); - config.dump_bootstrap_shims = flags_dump_bootstrap_shims; - config.keep_stage = flags_keep_stage; - config.keep_stage_std = flags_keep_stage_std; - config.color = flags_color; - config.free_args = std::mem::take(&mut flags_free_args); - config.llvm_profile_use = flags_llvm_profile_use; - config.llvm_profile_generate = flags_llvm_profile_generate; - config.enable_bolt_settings = flags_enable_bolt_settings; - config.bypass_bootstrap_lock = flags_bypass_bootstrap_lock; - config.is_running_on_ci = flags_ci.unwrap_or(CiEnv::is_ci()); - config.skip_std_check_if_no_download_rustc = flags_skip_std_check_if_no_download_rustc; - - // Infer the rest of the configuration. - - if cfg!(test) { - // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. - config.out = Path::new( - &env::var_os("CARGO_TARGET_DIR").expect("cargo test directly is not supported"), - ) - .parent() - .unwrap() - .to_path_buf(); - } - - config.stage0_metadata = build_helper::stage0_parser::parse_stage0_file(); - if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the // same ones used to call the tests (if custom ones are not defined in the toml). If we @@ -543,11 +488,11 @@ impl Config { build.cargo = build.cargo.take().or(std::env::var_os("CARGO").map(|p| p.into())); } - config.change_id = toml.change_id.inner; - + // Now override TOML values with flags, to make sure that we won't later override flags with + // TOML values by accident instead, because flags have higher priority. let Build { description, - build, + mut build, host, target, build_dir, @@ -594,7 +539,7 @@ impl Config { metrics: _, android_ndk, optimized_compiler_builtins, - jobs, + mut jobs, compiletest_diff_tool, compiletest_allow_stage0, compiletest_use_stage0_libtest, @@ -602,6 +547,90 @@ impl Config { ccache, exclude, } = toml.build.unwrap_or_default(); + jobs = flags_jobs.or(jobs); + build = flags_build.or(build); + let build_dir = flags_build_dir.or(build_dir.map(PathBuf::from)); + let host = if let Some(TargetSelectionList(hosts)) = flags_host { + Some(hosts) + } else if let Some(file_host) = host { + Some(file_host.iter().map(|h| TargetSelection::from_user(h)).collect()) + } else { + None + }; + let target = if let Some(TargetSelectionList(targets)) = flags_target { + Some(targets) + } else if let Some(file_target) = target { + Some(file_target.iter().map(|h| TargetSelection::from_user(h)).collect()) + } else { + None + }; + + if let Some(rustc) = &rustc { + if !flags_skip_stage0_validation { + check_stage0_version(&rustc, "rustc", &config.src, config.exec_ctx()); + } + } + if let Some(cargo) = &cargo { + if !flags_skip_stage0_validation { + check_stage0_version(&cargo, "cargo", &config.src, config.exec_ctx()); + } + } + + #[cfg(feature = "tracing")] + span!( + target: "CONFIG_HANDLING", + tracing::Level::TRACE, + "collecting paths and path exclusions", + "flags.paths" = ?flags_paths, + "flags.skip" = ?flags_skip, + "flags.exclude" = ?flags_exclude + ); + + #[cfg(feature = "tracing")] + span!( + target: "CONFIG_HANDLING", + tracing::Level::TRACE, + "normalizing and combining `flag.skip`/`flag.exclude` paths", + "config.skip" = ?config.skip, + ); + + // Set flags. + config.paths = std::mem::take(&mut flags_paths); + config.include_default_paths = flags_include_default_paths; + config.rustc_error_format = flags_rustc_error_format; + config.json_output = flags_json_output; + config.compile_time_deps = flags_compile_time_deps; + config.on_fail = flags_on_fail; + config.cmd = flags_cmd; + config.incremental = flags_incremental; + config.set_dry_run(if flags_dry_run { DryRun::UserSelected } else { DryRun::Disabled }); + config.dump_bootstrap_shims = flags_dump_bootstrap_shims; + config.keep_stage = flags_keep_stage; + config.keep_stage_std = flags_keep_stage_std; + config.color = flags_color; + config.free_args = std::mem::take(&mut flags_free_args); + config.llvm_profile_use = flags_llvm_profile_use; + config.llvm_profile_generate = flags_llvm_profile_generate; + config.enable_bolt_settings = flags_enable_bolt_settings; + config.bypass_bootstrap_lock = flags_bypass_bootstrap_lock; + config.is_running_on_ci = flags_ci.unwrap_or(CiEnv::is_ci()); + config.skip_std_check_if_no_download_rustc = flags_skip_std_check_if_no_download_rustc; + + // Infer the rest of the configuration. + + if cfg!(test) { + // Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly. + config.out = Path::new( + &env::var_os("CARGO_TARGET_DIR").expect("cargo test directly is not supported"), + ) + .parent() + .unwrap() + .to_path_buf(); + } + + config.stage0_metadata = build_helper::stage0_parser::parse_stage0_file(); + + config.change_id = toml.change_id.inner; let mut paths: Vec = flags_skip.into_iter().chain(flags_exclude).collect(); @@ -623,15 +652,12 @@ impl Config { }) .collect(); - config.jobs = Some(threads_from_config(flags_jobs.unwrap_or(jobs.unwrap_or(0)))); - - if let Some(flags_build) = flags_build { - config.host_target = TargetSelection::from_user(&flags_build); - } else if let Some(file_build) = build { - config.host_target = TargetSelection::from_user(&file_build); - }; + config.jobs = Some(threads_from_config(jobs.unwrap_or(0))); + if let Some(build) = build { + config.host_target = TargetSelection::from_user(&build); + } - set(&mut config.out, flags_build_dir.or_else(|| build_dir.map(PathBuf::from))); + set(&mut config.out, build_dir); // NOTE: Bootstrap spawns various commands with different working directories. // To avoid writing to random places on the file system, `config.out` needs to be an absolute path. if !config.out.is_absolute() { @@ -651,9 +677,6 @@ impl Config { toml.llvm.as_ref().is_some_and(|llvm| llvm.assertions.unwrap_or(false)); config.initial_rustc = if let Some(rustc) = rustc { - if !flags_skip_stage0_validation { - config.check_stage0_version(&rustc, "rustc"); - } rustc } else { let dwn_ctx = DownloadContext::from(&config); @@ -678,9 +701,6 @@ impl Config { config.initial_cargo_clippy = cargo_clippy; config.initial_cargo = if let Some(cargo) = cargo { - if !flags_skip_stage0_validation { - config.check_stage0_version(&cargo, "cargo"); - } cargo } else { let dwn_ctx = DownloadContext::from(&config); @@ -695,17 +715,9 @@ impl Config { config.out = dir; } - config.hosts = if let Some(TargetSelectionList(arg_host)) = flags_host { - arg_host - } else if let Some(file_host) = host { - file_host.iter().map(|h| TargetSelection::from_user(h)).collect() - } else { - vec![config.host_target] - }; - config.targets = if let Some(TargetSelectionList(arg_target)) = flags_target { - arg_target - } else if let Some(file_target) = target { - file_target.iter().map(|h| TargetSelection::from_user(h)).collect() + config.hosts = if let Some(hosts) = host { hosts } else { vec![config.host_target] }; + config.targets = if let Some(targets) = target { + targets } else { // If target is *not* configured, then default to the host // toolchains. @@ -1812,49 +1824,6 @@ impl Config { } } - #[cfg(test)] - pub fn check_stage0_version(&self, _program_path: &Path, _component_name: &'static str) {} - - /// check rustc/cargo version is same or lower with 1 apart from the building one - #[cfg(not(test))] - pub fn check_stage0_version(&self, program_path: &Path, component_name: &'static str) { - use build_helper::util::fail; - - if self.dry_run() { - return; - } - - let stage0_output = - command(program_path).arg("--version").run_capture_stdout(self).stdout(); - let mut stage0_output = stage0_output.lines().next().unwrap().split(' '); - - let stage0_name = stage0_output.next().unwrap(); - if stage0_name != component_name { - fail(&format!( - "Expected to find {component_name} at {} but it claims to be {stage0_name}", - program_path.display() - )); - } - - let stage0_version = - semver::Version::parse(stage0_output.next().unwrap().split('-').next().unwrap().trim()) - .unwrap(); - let source_version = semver::Version::parse( - fs::read_to_string(self.src.join("src/version")).unwrap().trim(), - ) - .unwrap(); - if !(source_version == stage0_version - || (source_version.major == stage0_version.major - && (source_version.minor == stage0_version.minor - || source_version.minor == stage0_version.minor + 1))) - { - let prev_version = format!("{}.{}.x", source_version.major, source_version.minor - 1); - fail(&format!( - "Unexpected {component_name} version: {stage0_version}, we should use {prev_version}/{source_version} to build source with {source_version}" - )); - } - } - /// Returns the commit to download, or `None` if we shouldn't download CI artifacts. pub fn download_ci_rustc_commit( &self, @@ -2352,3 +2321,56 @@ fn postprocess_toml( } toml.merge(None, &mut Default::default(), override_toml, ReplaceOpt::Override); } + +#[cfg(test)] +pub fn check_stage0_version( + _program_path: &Path, + _component_name: &'static str, + _src_dir: &Path, + _exec_ctx: &ExecutionContext, +) { +} + +/// check rustc/cargo version is same or lower with 1 apart from the building one +#[cfg(not(test))] +pub fn check_stage0_version( + program_path: &Path, + component_name: &'static str, + src_dir: &Path, + exec_ctx: &ExecutionContext, +) { + use build_helper::util::fail; + + if exec_ctx.dry_run() { + return; + } + + let stage0_output = + command(program_path).arg("--version").run_capture_stdout(exec_ctx).stdout(); + let mut stage0_output = stage0_output.lines().next().unwrap().split(' '); + + let stage0_name = stage0_output.next().unwrap(); + if stage0_name != component_name { + fail(&format!( + "Expected to find {component_name} at {} but it claims to be {stage0_name}", + program_path.display() + )); + } + + let stage0_version = + semver::Version::parse(stage0_output.next().unwrap().split('-').next().unwrap().trim()) + .unwrap(); + let source_version = + semver::Version::parse(fs::read_to_string(src_dir.join("src/version")).unwrap().trim()) + .unwrap(); + if !(source_version == stage0_version + || (source_version.major == stage0_version.major + && (source_version.minor == stage0_version.minor + || source_version.minor == stage0_version.minor + 1))) + { + let prev_version = format!("{}.{}.x", source_version.major, source_version.minor - 1); + fail(&format!( + "Unexpected {component_name} version: {stage0_version}, we should use {prev_version}/{source_version} to build source with {source_version}" + )); + } +} From 8652d96ff7b58ec491de45d0767b211f631dfbee Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 16:56:38 +0530 Subject: [PATCH 11/27] Fix logging of config skip values --- src/bootstrap/src/core/config/config.rs | 55 ++++++++++++------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 49359afbed623..c3cc920d331d0 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -446,13 +446,23 @@ impl Config { enable_bolt_settings: flags_enable_bolt_settings, skip_stage0_validation: flags_skip_stage0_validation, reproducible_artifact: flags_reproducible_artifact, - paths: mut flags_paths, + paths: flags_paths, set: flags_set, - free_args: mut flags_free_args, + free_args: flags_free_args, ci: flags_ci, skip_std_check_if_no_download_rustc: flags_skip_std_check_if_no_download_rustc, } = flags; + #[cfg(feature = "tracing")] + span!( + target: "CONFIG_HANDLING", + tracing::Level::TRACE, + "collecting paths and path exclusions", + "flags.paths" = ?flags_paths, + "flags.skip" = ?flags_skip, + "flags.exclude" = ?flags_exclude + ); + // First initialize the bare minimum that we need for further operation - source directory // and execution context. let mut config = Config::default_opts(); @@ -576,26 +586,13 @@ impl Config { } } - #[cfg(feature = "tracing")] - span!( - target: "CONFIG_HANDLING", - tracing::Level::TRACE, - "collecting paths and path exclusions", - "flags.paths" = ?flags_paths, - "flags.skip" = ?flags_skip, - "flags.exclude" = ?flags_exclude - ); - - #[cfg(feature = "tracing")] - span!( - target: "CONFIG_HANDLING", - tracing::Level::TRACE, - "normalizing and combining `flag.skip`/`flag.exclude` paths", - "config.skip" = ?config.skip, - ); + let mut paths: Vec = flags_skip.into_iter().chain(flags_exclude).collect(); + if let Some(exclude) = exclude { + paths.extend(exclude); + } - // Set flags. - config.paths = std::mem::take(&mut flags_paths); + // Set config values based on flags. + config.paths = flags_paths; config.include_default_paths = flags_include_default_paths; config.rustc_error_format = flags_rustc_error_format; config.json_output = flags_json_output; @@ -608,7 +605,7 @@ impl Config { config.keep_stage = flags_keep_stage; config.keep_stage_std = flags_keep_stage_std; config.color = flags_color; - config.free_args = std::mem::take(&mut flags_free_args); + config.free_args = flags_free_args; config.llvm_profile_use = flags_llvm_profile_use; config.llvm_profile_generate = flags_llvm_profile_generate; config.enable_bolt_settings = flags_enable_bolt_settings; @@ -632,12 +629,6 @@ impl Config { config.change_id = toml.change_id.inner; - let mut paths: Vec = flags_skip.into_iter().chain(flags_exclude).collect(); - - if let Some(exclude) = exclude { - paths.extend(exclude); - } - config.skip = paths .into_iter() .map(|p| { @@ -652,6 +643,14 @@ impl Config { }) .collect(); + #[cfg(feature = "tracing")] + span!( + target: "CONFIG_HANDLING", + tracing::Level::TRACE, + "normalizing and combining `flag.skip`/`flag.exclude` paths", + "config.skip" = ?config.skip, + ); + config.jobs = Some(threads_from_config(jobs.unwrap_or(0))); if let Some(build) = build { config.host_target = TargetSelection::from_user(&build); From 58a38cd7deba18d4b449214cab5cad36d3b4cceb Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Wed, 30 Jul 2025 17:08:52 +0530 Subject: [PATCH 12/27] Fix verbosity setting --- src/bootstrap/src/core/config/config.rs | 12 +++++++----- src/bootstrap/src/lib.rs | 2 +- src/bootstrap/src/utils/exec.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index c3cc920d331d0..d9cc215683ead 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -93,7 +93,6 @@ pub struct Config { pub ccache: Option, /// Call Build::ninja() instead of this. pub ninja_in_file: bool, - pub verbose: usize, pub submodules: Option, pub compiler_docs: bool, pub library_docs_private_items: bool, @@ -528,7 +527,7 @@ impl Config { extended, tools, tool, - verbose, + verbose: build_verbose, sanitizers, profiler, cargo_native_static, @@ -586,6 +585,12 @@ impl Config { } } + // Prefer CLI verbosity flags if set (`flags_verbose` > 0), otherwise take the value from + // TOML. + config + .exec_ctx + .set_verbosity(cmp::max(build_verbose.unwrap_or_default() as u8, flags_verbose)); + let mut paths: Vec = flags_skip.into_iter().chain(flags_exclude).collect(); if let Some(exclude) = exclude { paths.extend(exclude); @@ -741,7 +746,6 @@ impl Config { set(&mut config.extended, extended); config.tools = tools; set(&mut config.tool, tool); - set(&mut config.verbose, verbose); set(&mut config.sanitizers, sanitizers); set(&mut config.profiler, profiler); set(&mut config.cargo_native_static, cargo_native_static); @@ -750,8 +754,6 @@ impl Config { set(&mut config.print_step_timings, print_step_timings); set(&mut config.print_step_rusage, print_step_rusage); - config.verbose = cmp::max(config.verbose, flags_verbose as usize); - // Verbose flag is a good default for `rust.verbose-tests`. config.verbose_tests = config.is_verbose(); diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 011b52df97bbd..254b8658b668a 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -515,7 +515,7 @@ impl Build { local_rebuild: config.local_rebuild, fail_fast: config.cmd.fail_fast(), doc_tests: config.cmd.doc_tests(), - verbosity: config.verbose, + verbosity: config.exec_ctx.verbosity as usize, host_target: config.host_target, hosts: config.hosts.clone(), diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index 26582214c9307..7527dff9cd843 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -550,7 +550,7 @@ impl Default for CommandOutput { #[derive(Clone, Default)] pub struct ExecutionContext { dry_run: DryRun, - verbosity: u8, + pub verbosity: u8, pub fail_fast: bool, delayed_failures: Arc>>, command_cache: Arc, @@ -640,7 +640,7 @@ impl ExecutionContext { self.dry_run = value; } - pub fn set_verbose(&mut self, value: u8) { + pub fn set_verbosity(&mut self, value: u8) { self.verbosity = value; } From 222dfcc02fdadc854335fd2a1cc8961203933a94 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 14:04:41 +0530 Subject: [PATCH 13/27] add install default implementation --- src/bootstrap/src/core/config/config.rs | 35 +++++++++++++------ src/bootstrap/src/core/config/toml/install.rs | 1 + 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index d9cc215683ead..c97e675f577c1 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -757,16 +757,31 @@ impl Config { // Verbose flag is a good default for `rust.verbose-tests`. config.verbose_tests = config.is_verbose(); - if let Some(install) = toml.install { - let Install { prefix, sysconfdir, docdir, bindir, libdir, mandir, datadir } = install; - config.prefix = prefix.map(PathBuf::from); - config.sysconfdir = sysconfdir.map(PathBuf::from); - config.datadir = datadir.map(PathBuf::from); - config.docdir = docdir.map(PathBuf::from); - set(&mut config.bindir, bindir.map(PathBuf::from)); - config.libdir = libdir.map(PathBuf::from); - config.mandir = mandir.map(PathBuf::from); - } + let Install { + prefix: install_prefix, + sysconfdir: install_sysconfdir, + docdir: install_docdir, + bindir: install_bindir, + libdir: install_libdir, + mandir: install_mandir, + datadir: install_datadir, + } = toml.install.unwrap_or_default(); + + let install_prefix = install_prefix.map(PathBuf::from); + let install_sysconfdir = install_sysconfdir.map(PathBuf::from); + let install_docdir = install_docdir.map(PathBuf::from); + let install_bindir = install_bindir.map(PathBuf::from); + let install_libdir = install_libdir.map(PathBuf::from); + let install_mandir = install_mandir.map(PathBuf::from); + let install_datadir = install_datadir.map(PathBuf::from); + + config.prefix = install_prefix; + config.sysconfdir = install_sysconfdir; + config.datadir = install_datadir; + config.docdir = install_docdir; + set(&mut config.bindir, install_bindir); + config.libdir = install_libdir; + config.mandir = install_mandir; let file_content = t!(fs::read_to_string(config.src.join("src/ci/channel"))); let ci_channel = file_content.trim_end(); diff --git a/src/bootstrap/src/core/config/toml/install.rs b/src/bootstrap/src/core/config/toml/install.rs index da31c0cc878c0..60fa958bd82f8 100644 --- a/src/bootstrap/src/core/config/toml/install.rs +++ b/src/bootstrap/src/core/config/toml/install.rs @@ -14,6 +14,7 @@ use crate::{HashSet, PathBuf, define_config, exit}; define_config! { /// TOML representation of various global install decisions. + #[derive(Default)] struct Install { prefix: Option = "prefix", sysconfdir: Option = "sysconfdir", From bbe7c087622b0490306bbf7d5eb342dad57f5243 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 14:28:17 +0530 Subject: [PATCH 14/27] add gcc and dist default implementation --- src/bootstrap/src/core/config/config.rs | 62 +++++++++++----------- src/bootstrap/src/core/config/toml/dist.rs | 1 + src/bootstrap/src/core/config/toml/gcc.rs | 1 + 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index c97e675f577c1..47c228d3cc3f4 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -38,6 +38,7 @@ use crate::core::config::toml::TomlConfig; use crate::core::config::toml::build::{Build, Tool}; use crate::core::config::toml::change_id::ChangeId; use crate::core::config::toml::dist::Dist; +use crate::core::config::toml::gcc::Gcc; use crate::core::config::toml::install::Install; use crate::core::config::toml::llvm::Llvm; use crate::core::config::toml::rust::{ @@ -774,7 +775,6 @@ impl Config { let install_libdir = install_libdir.map(PathBuf::from); let install_mandir = install_mandir.map(PathBuf::from); let install_datadir = install_datadir.map(PathBuf::from); - config.prefix = install_prefix; config.sysconfdir = install_sysconfdir; config.datadir = install_datadir; @@ -1278,15 +1278,15 @@ impl Config { config.llvm_offload = llvm_offload.unwrap_or(false); config.llvm_plugins = llvm_plugins.unwrap_or(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(), - }; - } + let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default(); + + config.gcc_ci_mode = match gcc_download_ci_gcc { + Some(value) => match value { + true => GccCiMode::DownloadFromCi, + false => GccCiMode::BuildLocally, + }, + None => GccCiMode::default(), + }; match ccache { Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()), @@ -1312,28 +1312,26 @@ impl Config { Some(ci_llvm_bin.join(exe("FileCheck", config.host_target))); } - if let Some(dist) = toml.dist { - let Dist { - sign_folder, - upload_addr, - src_tarball, - compression_formats, - compression_profile, - include_mingw_linker, - vendor, - } = dist; - config.dist_sign_folder = sign_folder.map(PathBuf::from); - config.dist_upload_addr = upload_addr; - config.dist_compression_formats = compression_formats; - set(&mut config.dist_compression_profile, compression_profile); - set(&mut config.rust_dist_src, src_tarball); - set(&mut config.dist_include_mingw_linker, include_mingw_linker); - config.dist_vendor = vendor.unwrap_or_else(|| { - // If we're building from git or tarball sources, enable it by default. - config.rust_info.is_managed_git_subrepository() - || config.rust_info.is_from_tarball() - }); - } + let Dist { + sign_folder: dist_sign_folder, + upload_addr: dist_upload_addr, + src_tarball: dist_src_tarball, + compression_formats: dist_compression_formats, + compression_profile: dist_compression_profile, + include_mingw_linker: dist_include_mingw_linker, + vendor: dist_vendor, + } = toml.dist.unwrap_or_default(); + + config.dist_sign_folder = dist_sign_folder.map(PathBuf::from); + config.dist_upload_addr = dist_upload_addr; + config.dist_compression_formats = dist_compression_formats; + set(&mut config.dist_compression_profile, dist_compression_profile); + set(&mut config.rust_dist_src, dist_src_tarball); + set(&mut config.dist_include_mingw_linker, dist_include_mingw_linker); + config.dist_vendor = dist_vendor.unwrap_or_else(|| { + // If we're building from git or tarball sources, enable it by default. + config.rust_info.is_managed_git_subrepository() || config.rust_info.is_from_tarball() + }); config.initial_rustfmt = if let Some(r) = rustfmt { Some(r) diff --git a/src/bootstrap/src/core/config/toml/dist.rs b/src/bootstrap/src/core/config/toml/dist.rs index 4ab18762bb054..934d64d889919 100644 --- a/src/bootstrap/src/core/config/toml/dist.rs +++ b/src/bootstrap/src/core/config/toml/dist.rs @@ -12,6 +12,7 @@ use crate::core::config::toml::ReplaceOpt; use crate::{HashSet, PathBuf, define_config, exit}; define_config! { + #[derive(Default)] struct Dist { sign_folder: Option = "sign-folder", upload_addr: Option = "upload-addr", diff --git a/src/bootstrap/src/core/config/toml/gcc.rs b/src/bootstrap/src/core/config/toml/gcc.rs index de061309c8040..9ea697edf159e 100644 --- a/src/bootstrap/src/core/config/toml/gcc.rs +++ b/src/bootstrap/src/core/config/toml/gcc.rs @@ -12,6 +12,7 @@ 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 = "download-ci-gcc", } From 38ddefa15db96befe1ba5b2a2e02501e886d4417 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 14:51:14 +0530 Subject: [PATCH 15/27] add llvm default implementation --- src/bootstrap/src/core/config/config.rs | 207 ++++++++++----------- src/bootstrap/src/core/config/toml/llvm.rs | 1 + 2 files changed, 97 insertions(+), 111 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 47c228d3cc3f4..66f21ba89e50d 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1157,126 +1157,111 @@ impl Config { config.channel = channel; } - 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 config.ninja_in_file, ninja); - llvm_tests = tests; - llvm_enzyme = enzyme; - llvm_offload = offload; - llvm_plugins = plugins; - set(&mut config.llvm_optimize, optimize_toml); - set(&mut config.llvm_thin_lto, thin_lto); - set(&mut config.llvm_release_debuginfo, release_debuginfo); - set(&mut config.llvm_static_stdcpp, static_libstdcpp); - set(&mut config.llvm_libzstd, libzstd); - if let Some(v) = link_shared { - config.llvm_link_shared.set(Some(v)); - } - config.llvm_targets.clone_from(&targets); - config.llvm_experimental_targets.clone_from(&experimental_targets); - config.llvm_link_jobs = link_jobs; - config.llvm_version_suffix.clone_from(&version_suffix); - config.llvm_clang_cl.clone_from(&clang_cl); - - config.llvm_cflags.clone_from(&cflags); - config.llvm_cxxflags.clone_from(&cxxflags); - config.llvm_ldflags.clone_from(&ldflags); - set(&mut config.llvm_use_libcxx, use_libcxx); - config.llvm_use_linker.clone_from(&use_linker); - config.llvm_allow_old_toolchain = allow_old_toolchain.unwrap_or(false); - config.llvm_offload = offload.unwrap_or(false); - config.llvm_polly = polly.unwrap_or(false); - config.llvm_clang = clang.unwrap_or(false); - config.llvm_enable_warnings = enable_warnings.unwrap_or(false); - config.llvm_build_config = build_config.clone().unwrap_or(Default::default()); - - config.llvm_from_ci = - config.parse_download_ci_llvm(download_ci_llvm, config.llvm_assertions); - - if config.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." - ); - }; + let Llvm { + optimize: optimize_toml, + thin_lto, + release_debuginfo, + assertions: _, + tests: llvm_tests, + enzyme: llvm_enzyme, + plugins: llvm_plugin, + 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: llvm_offload, + polly, + clang, + enable_warnings, + download_ci_llvm, + build_config, + } = toml.llvm.unwrap_or_default(); + + set(&mut config.ninja_in_file, ninja); + set(&mut config.llvm_optimize, optimize_toml); + set(&mut config.llvm_thin_lto, thin_lto); + set(&mut config.llvm_release_debuginfo, release_debuginfo); + set(&mut config.llvm_static_stdcpp, static_libstdcpp); + set(&mut config.llvm_libzstd, libzstd); + if let Some(v) = link_shared { + config.llvm_link_shared.set(Some(v)); + } + config.llvm_targets.clone_from(&targets); + config.llvm_experimental_targets.clone_from(&experimental_targets); + config.llvm_link_jobs = link_jobs; + config.llvm_version_suffix.clone_from(&version_suffix); + config.llvm_clang_cl.clone_from(&clang_cl); + config.llvm_tests = llvm_tests.unwrap_or_default(); + config.llvm_enzyme = llvm_enzyme.unwrap_or_default(); + config.llvm_plugins = llvm_plugin.unwrap_or_default(); + + config.llvm_cflags.clone_from(&cflags); + config.llvm_cxxflags.clone_from(&cxxflags); + config.llvm_ldflags.clone_from(&ldflags); + set(&mut config.llvm_use_libcxx, use_libcxx); + config.llvm_use_linker.clone_from(&use_linker); + config.llvm_allow_old_toolchain = allow_old_toolchain.unwrap_or(false); + config.llvm_offload = llvm_offload.unwrap_or(false); + config.llvm_polly = polly.unwrap_or(false); + config.llvm_clang = clang.unwrap_or(false); + config.llvm_enable_warnings = enable_warnings.unwrap_or(false); + config.llvm_build_config = build_config.clone().unwrap_or(Default::default()); - if static_libstdcpp.is_some() { - warn("static-libstdcpp"); - } + config.llvm_from_ci = + config.parse_download_ci_llvm(download_ci_llvm, config.llvm_assertions); - if link_shared.is_some() { - warn("link-shared"); - } + if config.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." + ); + }; - // 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 static_libstdcpp.is_some() { + warn("static-libstdcpp"); + } - 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 link_shared.is_some() { + warn("link-shared"); } - if !config.llvm_from_ci && config.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. - config.llvm_link_shared.set(Some(true)); + // 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." + ); } - } else { - config.llvm_from_ci = config.parse_download_ci_llvm(None, false); } - config.llvm_tests = llvm_tests.unwrap_or(false); - config.llvm_enzyme = llvm_enzyme.unwrap_or(false); - config.llvm_offload = llvm_offload.unwrap_or(false); - config.llvm_plugins = llvm_plugins.unwrap_or(false); + if !config.llvm_from_ci && config.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. + config.llvm_link_shared.set(Some(true)); + } let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default(); diff --git a/src/bootstrap/src/core/config/toml/llvm.rs b/src/bootstrap/src/core/config/toml/llvm.rs index 0ab290b9bd1e3..9751837a88794 100644 --- a/src/bootstrap/src/core/config/toml/llvm.rs +++ b/src/bootstrap/src/core/config/toml/llvm.rs @@ -9,6 +9,7 @@ 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 = "optimize", thin_lto: Option = "thin-lto", From 8b80cb0ac72d2d577e4b934e6c19376a6104527d Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 15:22:14 +0530 Subject: [PATCH 16/27] add rust default implementation --- src/bootstrap/src/core/config/config.rs | 374 ++++++++++----------- src/bootstrap/src/core/config/toml/rust.rs | 1 + 2 files changed, 175 insertions(+), 200 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 66f21ba89e50d..b4163d70e3b8d 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -893,198 +893,167 @@ impl Config { config.target_config.insert(TargetSelection::from_user(&triple), target); } } - let mut debug = None; - let mut rustc_debug_assertions = None; - let mut std_debug_assertions = None; - let mut tools_debug_assertions = None; - let mut overflow_checks = None; - let mut overflow_checks_std = None; - let mut debug_logging = None; - let mut debuginfo_level = None; - let mut debuginfo_level_rustc = None; - let mut debuginfo_level_std = None; - let mut debuginfo_level_tools = None; - let mut debuginfo_level_tests = None; - let mut optimize = None; - let mut lld_enabled = None; - let mut std_features = None; - - if let Some(rust) = toml.rust { - let Rust { - optimize: optimize_toml, - debug: debug_toml, - codegen_units, - codegen_units_std, - rustc_debug_assertions: rustc_debug_assertions_toml, - std_debug_assertions: std_debug_assertions_toml, - tools_debug_assertions: tools_debug_assertions_toml, - overflow_checks: overflow_checks_toml, - overflow_checks_std: overflow_checks_std_toml, - debug_logging: debug_logging_toml, - debuginfo_level: debuginfo_level_toml, - debuginfo_level_rustc: debuginfo_level_rustc_toml, - debuginfo_level_std: debuginfo_level_std_toml, - debuginfo_level_tools: debuginfo_level_tools_toml, - debuginfo_level_tests: debuginfo_level_tests_toml, - backtrace, - incremental, - randomize_layout, - default_linker, - channel: _, // already handled above - musl_root, - rpath, - verbose_tests, - optimize_tests, - codegen_tests, - omit_git_hash: _, // already handled above - dist_src, - save_toolstates, - codegen_backends, - lld: lld_enabled_toml, - llvm_tools, - llvm_bitcode_linker, - deny_warnings, - backtrace_on_ice, - verify_llvm_ir, - thin_lto_import_instr_limit, - remap_debuginfo, - jemalloc, - test_compare_mode, - llvm_libunwind, - control_flow_guard, - ehcont_guard, - new_symbol_mangling, - profile_generate, - profile_use, - download_rustc, - lto, - validate_mir_opts, - frame_pointers, - stack_protector, - strip, - lld_mode, - std_features: std_features_toml, - } = rust; - - // FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions - // enabled. We should not download a CI alt rustc if we need rustc to have debug - // assertions (e.g. for crashes test suite). This can be changed once something like - // [Enable debug assertions on alt - // builds](https://github.com/rust-lang/rust/pull/131077) lands. - // - // Note that `rust.debug = true` currently implies `rust.debug-assertions = true`! - // - // This relies also on the fact that the global default for `download-rustc` will be - // `false` if it's not explicitly set. - let debug_assertions_requested = matches!(rustc_debug_assertions_toml, Some(true)) - || (matches!(debug_toml, Some(true)) - && !matches!(rustc_debug_assertions_toml, Some(false))); - - if debug_assertions_requested - && let Some(ref opt) = download_rustc - && opt.is_string_or_true() - { - eprintln!( - "WARN: currently no CI rustc builds have rustc debug assertions \ - enabled. Please either set `rust.debug-assertions` to `false` if you \ - want to use download CI rustc or set `rust.download-rustc` to `false`." - ); - } - config.download_rustc_commit = config.download_ci_rustc_commit( - download_rustc, - debug_assertions_requested, - config.llvm_assertions, + let Rust { + optimize: rust_optimize_toml, + debug: rust_debug_toml, + codegen_units: rust_codegen_units_toml, + codegen_units_std: rust_codegen_units_std_toml, + rustc_debug_assertions: rust_rustc_debug_assertions_toml, + std_debug_assertions: rust_std_debug_assertions_toml, + tools_debug_assertions: rust_tools_debug_assertions_toml, + overflow_checks: rust_overflow_checks_toml, + overflow_checks_std: rust_overflow_checks_std_toml, + debug_logging: rust_debug_logging_toml, + debuginfo_level: rust_debuginfo_level_toml, + debuginfo_level_rustc: rust_debuginfo_level_rustc_toml, + debuginfo_level_std: rust_debuginfo_level_std_toml, + debuginfo_level_tools: rust_debuginfo_level_tools_toml, + debuginfo_level_tests: rust_debuginfo_level_tests_toml, + backtrace: rust_backtrace_toml, + incremental: rust_incremental_toml, + randomize_layout: rust_randomize_layout_toml, + default_linker: rust_default_linker_toml, + channel: _, // already handled above + musl_root: rust_musl_root_toml, + rpath: rust_rpath_toml, + verbose_tests: rust_verbose_tests_toml, + optimize_tests: rust_optimize_tests_toml, + codegen_tests: rust_codegen_tests_toml, + omit_git_hash: _, // already handled above + dist_src: rust_dist_src_toml, + save_toolstates: rust_save_toolstates_toml, + codegen_backends: rust_codegen_backends_toml, + lld: rust_lld_enabled_toml, + llvm_tools: rust_llvm_tools_toml, + llvm_bitcode_linker: rust_llvm_bitcode_linker_toml, + deny_warnings: rust_deny_warnings_toml, + backtrace_on_ice: rust_backtrace_on_ice_toml, + verify_llvm_ir: rust_verify_llvm_ir_toml, + thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_toml, + remap_debuginfo: rust_remap_debuginfo_toml, + jemalloc: rust_jemalloc_toml, + test_compare_mode: rust_test_compare_mode_toml, + llvm_libunwind: rust_llvm_libunwind_toml, + control_flow_guard: rust_control_flow_guard_toml, + ehcont_guard: rust_ehcont_guard_toml, + new_symbol_mangling: rust_new_symbol_mangling_toml, + profile_generate: rust_profile_generate_toml, + profile_use: rust_profile_use_toml, + download_rustc: rust_download_rustc_toml, + lto: rust_lto_toml, + validate_mir_opts: rust_validate_mir_opts_toml, + frame_pointers: rust_frame_pointers_toml, + stack_protector: rust_stack_protector_toml, + strip: rust_strip_toml, + lld_mode: rust_lld_mode_toml, + std_features: rust_std_features_toml, + } = toml.rust.unwrap_or_default(); + + // FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions + // enabled. We should not download a CI alt rustc if we need rustc to have debug + // assertions (e.g. for crashes test suite). This can be changed once something like + // [Enable debug assertions on alt + // builds](https://github.com/rust-lang/rust/pull/131077) lands. + // + // Note that `rust.debug = true` currently implies `rust.debug-assertions = true`! + // + // This relies also on the fact that the global default for `download-rustc` will be + // `false` if it's not explicitly set. + let debug_assertions_requested = matches!(rust_rustc_debug_assertions_toml, Some(true)) + || (matches!(rust_debug_toml, Some(true)) + && !matches!(rust_rustc_debug_assertions_toml, Some(false))); + + if debug_assertions_requested + && let Some(ref opt) = rust_download_rustc_toml + && opt.is_string_or_true() + { + eprintln!( + "WARN: currently no CI rustc builds have rustc debug assertions \ + enabled. Please either set `rust.debug-assertions` to `false` if you \ + want to use download CI rustc or set `rust.download-rustc` to `false`." ); + } - debug = debug_toml; - rustc_debug_assertions = rustc_debug_assertions_toml; - std_debug_assertions = std_debug_assertions_toml; - tools_debug_assertions = tools_debug_assertions_toml; - overflow_checks = overflow_checks_toml; - overflow_checks_std = overflow_checks_std_toml; - debug_logging = debug_logging_toml; - debuginfo_level = debuginfo_level_toml; - debuginfo_level_rustc = debuginfo_level_rustc_toml; - debuginfo_level_std = debuginfo_level_std_toml; - debuginfo_level_tools = debuginfo_level_tools_toml; - debuginfo_level_tests = debuginfo_level_tests_toml; - lld_enabled = lld_enabled_toml; - std_features = std_features_toml; - - if optimize_toml.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { - eprintln!( - "WARNING: setting `optimize` to `false` is known to cause errors and \ - should be considered unsupported. Refer to `bootstrap.example.toml` \ - for more details." - ); - } + config.download_rustc_commit = config.download_ci_rustc_commit( + rust_download_rustc_toml, + debug_assertions_requested, + config.llvm_assertions, + ); - optimize = optimize_toml; - config.rust_new_symbol_mangling = new_symbol_mangling; - set(&mut config.rust_optimize_tests, optimize_tests); - set(&mut config.codegen_tests, codegen_tests); - set(&mut config.rust_rpath, rpath); - set(&mut config.rust_strip, strip); - set(&mut config.rust_frame_pointers, frame_pointers); - config.rust_stack_protector = stack_protector; - set(&mut config.jemalloc, jemalloc); - set(&mut config.test_compare_mode, test_compare_mode); - set(&mut config.backtrace, backtrace); - set(&mut config.rust_dist_src, dist_src); - set(&mut config.verbose_tests, verbose_tests); - // in the case "false" is set explicitly, do not overwrite the command line args - if let Some(true) = incremental { - config.incremental = true; - } - set(&mut config.lld_mode, lld_mode); - set(&mut config.llvm_bitcode_linker_enabled, llvm_bitcode_linker); - - config.rust_randomize_layout = randomize_layout.unwrap_or_default(); - config.llvm_tools_enabled = llvm_tools.unwrap_or(true); - - config.llvm_enzyme = config.channel == "dev" || config.channel == "nightly"; - config.rustc_default_linker = default_linker; - config.musl_root = musl_root.map(PathBuf::from); - config.save_toolstates = save_toolstates.map(PathBuf::from); - set( - &mut config.deny_warnings, - match flags_warnings { - Warnings::Deny => Some(true), - Warnings::Warn => Some(false), - Warnings::Default => deny_warnings, - }, - ); - set(&mut config.backtrace_on_ice, backtrace_on_ice); - set(&mut config.rust_verify_llvm_ir, verify_llvm_ir); - config.rust_thin_lto_import_instr_limit = thin_lto_import_instr_limit; - set(&mut config.rust_remap_debuginfo, remap_debuginfo); - set(&mut config.control_flow_guard, control_flow_guard); - set(&mut config.ehcont_guard, ehcont_guard); - config.llvm_libunwind_default = - llvm_libunwind.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); - set( - &mut config.rust_codegen_backends, - codegen_backends.map(|backends| validate_codegen_backends(backends, "rust")), + if rust_optimize_toml.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { + eprintln!( + "WARNING: setting `optimize` to `false` is known to cause errors and \ + should be considered unsupported. Refer to `bootstrap.example.toml` \ + for more details." ); + } - config.rust_codegen_units = codegen_units.map(threads_from_config); - config.rust_codegen_units_std = codegen_units_std.map(threads_from_config); + config.rust_new_symbol_mangling = rust_new_symbol_mangling_toml; + set(&mut config.rust_optimize_tests, rust_optimize_tests_toml); + set(&mut config.codegen_tests, rust_codegen_tests_toml); + set(&mut config.rust_rpath, rust_rpath_toml); + set(&mut config.rust_strip, rust_strip_toml); + set(&mut config.rust_frame_pointers, rust_frame_pointers_toml); + config.rust_stack_protector = rust_stack_protector_toml; + set(&mut config.jemalloc, rust_jemalloc_toml); + set(&mut config.test_compare_mode, rust_test_compare_mode_toml); + set(&mut config.backtrace, rust_backtrace_toml); + set(&mut config.rust_dist_src, rust_dist_src_toml); + set(&mut config.verbose_tests, rust_verbose_tests_toml); + // in the case "false" is set explicitly, do not overwrite the command line args + if let Some(true) = rust_incremental_toml { + config.incremental = true; + } + set(&mut config.lld_mode, rust_lld_mode_toml); + set(&mut config.llvm_bitcode_linker_enabled, rust_llvm_bitcode_linker_toml); + + config.rust_randomize_layout = rust_randomize_layout_toml.unwrap_or_default(); + config.llvm_tools_enabled = rust_llvm_tools_toml.unwrap_or(true); + + config.llvm_enzyme = config.channel == "dev" || config.channel == "nightly"; + config.rustc_default_linker = rust_default_linker_toml; + config.musl_root = rust_musl_root_toml.map(PathBuf::from); + config.save_toolstates = rust_save_toolstates_toml.map(PathBuf::from); + set( + &mut config.deny_warnings, + match flags_warnings { + Warnings::Deny => Some(true), + Warnings::Warn => Some(false), + Warnings::Default => rust_deny_warnings_toml, + }, + ); + set(&mut config.backtrace_on_ice, rust_backtrace_on_ice_toml); + set(&mut config.rust_verify_llvm_ir, rust_verify_llvm_ir_toml); + config.rust_thin_lto_import_instr_limit = rust_thin_lto_import_instr_limit_toml; + set(&mut config.rust_remap_debuginfo, rust_remap_debuginfo_toml); + set(&mut config.control_flow_guard, rust_control_flow_guard_toml); + set(&mut config.ehcont_guard, rust_ehcont_guard_toml); + config.llvm_libunwind_default = rust_llvm_libunwind_toml + .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); + set( + &mut config.rust_codegen_backends, + rust_codegen_backends_toml.map(|backends| validate_codegen_backends(backends, "rust")), + ); - if config.rust_profile_use.is_none() { - config.rust_profile_use = profile_use; - } + config.rust_codegen_units = rust_codegen_units_toml.map(threads_from_config); + config.rust_codegen_units_std = rust_codegen_units_std_toml.map(threads_from_config); - if config.rust_profile_generate.is_none() { - config.rust_profile_generate = profile_generate; - } + if config.rust_profile_use.is_none() { + config.rust_profile_use = rust_profile_use_toml; + } - config.rust_lto = - lto.as_deref().map(|value| RustcLto::from_str(value).unwrap()).unwrap_or_default(); - config.rust_validate_mir_opts = validate_mir_opts; + if config.rust_profile_generate.is_none() { + config.rust_profile_generate = rust_profile_generate_toml; } - config.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true)); + config.rust_lto = rust_lto_toml + .as_deref() + .map(|value| RustcLto::from_str(value).unwrap()) + .unwrap_or_default(); + config.rust_validate_mir_opts = rust_validate_mir_opts_toml; + + config.rust_optimize = rust_optimize_toml.unwrap_or(RustOptimize::Bool(true)); // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will // build our internal lld and use it as the default linker, by setting the `rust.lld` config @@ -1107,36 +1076,41 @@ impl Config { .is_none_or(|target_config| target_config.llvm_config.is_none()); let enable_lld = config.llvm_from_ci || no_llvm_config; // Prefer the config setting in case an explicit opt-out is needed. - config.lld_enabled = lld_enabled.unwrap_or(enable_lld); + config.lld_enabled = rust_lld_enabled_toml.unwrap_or(enable_lld); } else { - set(&mut config.lld_enabled, lld_enabled); + set(&mut config.lld_enabled, rust_lld_enabled_toml); } let default_std_features = BTreeSet::from([String::from("panic-unwind")]); - config.rust_std_features = std_features.unwrap_or(default_std_features); + config.rust_std_features = rust_std_features_toml.unwrap_or(default_std_features); - let default = debug == Some(true); - config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default); - config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions); + let default = rust_debug_toml == Some(true); + config.rustc_debug_assertions = rust_rustc_debug_assertions_toml.unwrap_or(default); + config.std_debug_assertions = + rust_std_debug_assertions_toml.unwrap_or(config.rustc_debug_assertions); config.tools_debug_assertions = - tools_debug_assertions.unwrap_or(config.rustc_debug_assertions); - config.rust_overflow_checks = overflow_checks.unwrap_or(default); + rust_tools_debug_assertions_toml.unwrap_or(config.rustc_debug_assertions); + config.rust_overflow_checks = rust_overflow_checks_toml.unwrap_or(default); config.rust_overflow_checks_std = - overflow_checks_std.unwrap_or(config.rust_overflow_checks); + rust_overflow_checks_std_toml.unwrap_or(config.rust_overflow_checks); - config.rust_debug_logging = debug_logging.unwrap_or(config.rustc_debug_assertions); + config.rust_debug_logging = + rust_debug_logging_toml.unwrap_or(config.rustc_debug_assertions); let with_defaults = |debuginfo_level_specific: Option<_>| { - debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) { - DebuginfoLevel::Limited - } else { - DebuginfoLevel::None - }) + debuginfo_level_specific.or(rust_debuginfo_level_toml).unwrap_or( + if rust_debug_toml == Some(true) { + DebuginfoLevel::Limited + } else { + DebuginfoLevel::None + }, + ) }; - config.rust_debuginfo_level_rustc = with_defaults(debuginfo_level_rustc); - config.rust_debuginfo_level_std = with_defaults(debuginfo_level_std); - config.rust_debuginfo_level_tools = with_defaults(debuginfo_level_tools); - config.rust_debuginfo_level_tests = debuginfo_level_tests.unwrap_or(DebuginfoLevel::None); + config.rust_debuginfo_level_rustc = with_defaults(rust_debuginfo_level_rustc_toml); + config.rust_debuginfo_level_std = with_defaults(rust_debuginfo_level_std_toml); + config.rust_debuginfo_level_tools = with_defaults(rust_debuginfo_level_tools_toml); + config.rust_debuginfo_level_tests = + rust_debuginfo_level_tests_toml.unwrap_or(DebuginfoLevel::None); config.reproducible_artifacts = flags_reproducible_artifact; config.description = description; diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 4bd1eac683ce1..fd154200bc7a1 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -10,6 +10,7 @@ use crate::{BTreeSet, HashSet, PathBuf, TargetSelection, define_config, exit}; define_config! { /// TOML representation of how the Rust build is configured. + #[derive(Default)] struct Rust { optimize: Option = "optimize", debug: Option = "debug", From d3d3b10e828773371cae6b85e2deab1f13df215c Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 15:34:29 +0530 Subject: [PATCH 17/27] make llvm toml fields follow a specific naming convention --- src/bootstrap/src/core/config/config.rs | 118 ++++++++++++------------ 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index b4163d70e3b8d..3f373a667899c 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1132,68 +1132,68 @@ impl Config { } let Llvm { - optimize: optimize_toml, - thin_lto, - release_debuginfo, + optimize: llvm_optimize_toml, + thin_lto: llvm_thin_lto_toml, + release_debuginfo: llvm_release_debuginfo_toml, assertions: _, - tests: llvm_tests, - enzyme: llvm_enzyme, - plugins: llvm_plugin, - 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: llvm_offload, - polly, - clang, - enable_warnings, - download_ci_llvm, - build_config, + tests: llvm_tests_toml, + enzyme: llvm_enzyme_toml, + plugins: llvm_plugin_toml, + static_libstdcpp: llvm_static_libstdcpp_toml, + libzstd: llvm_libzstd_toml, + ninja: llvm_ninja_toml, + targets: llvm_targets_toml, + experimental_targets: llvm_experimental_targets_toml, + link_jobs: llvm_link_jobs_toml, + link_shared: llvm_link_shared_toml, + version_suffix: llvm_version_suffix_toml, + clang_cl: llvm_clang_cl_toml, + cflags: llvm_cflags_toml, + cxxflags: llvm_cxxflags_toml, + ldflags: llvm_ldflags_toml, + use_libcxx: llvm_use_libcxx_toml, + use_linker: llvm_use_linker_toml, + allow_old_toolchain: llvm_allow_old_toolchain_toml, + offload: llvm_offload_toml, + polly: llvm_polly_toml, + clang: llvm_clang_toml, + enable_warnings: llvm_enable_warnings_toml, + download_ci_llvm: llvm_download_ci_llvm_toml, + build_config: llvm_build_config_toml, } = toml.llvm.unwrap_or_default(); - set(&mut config.ninja_in_file, ninja); - set(&mut config.llvm_optimize, optimize_toml); - set(&mut config.llvm_thin_lto, thin_lto); - set(&mut config.llvm_release_debuginfo, release_debuginfo); - set(&mut config.llvm_static_stdcpp, static_libstdcpp); - set(&mut config.llvm_libzstd, libzstd); - if let Some(v) = link_shared { + set(&mut config.ninja_in_file, llvm_ninja_toml); + set(&mut config.llvm_optimize, llvm_optimize_toml); + set(&mut config.llvm_thin_lto, llvm_thin_lto_toml); + set(&mut config.llvm_release_debuginfo, llvm_release_debuginfo_toml); + set(&mut config.llvm_static_stdcpp, llvm_static_libstdcpp_toml); + set(&mut config.llvm_libzstd, llvm_libzstd_toml); + if let Some(v) = llvm_link_shared_toml { config.llvm_link_shared.set(Some(v)); } - config.llvm_targets.clone_from(&targets); - config.llvm_experimental_targets.clone_from(&experimental_targets); - config.llvm_link_jobs = link_jobs; - config.llvm_version_suffix.clone_from(&version_suffix); - config.llvm_clang_cl.clone_from(&clang_cl); - config.llvm_tests = llvm_tests.unwrap_or_default(); - config.llvm_enzyme = llvm_enzyme.unwrap_or_default(); - config.llvm_plugins = llvm_plugin.unwrap_or_default(); - - config.llvm_cflags.clone_from(&cflags); - config.llvm_cxxflags.clone_from(&cxxflags); - config.llvm_ldflags.clone_from(&ldflags); - set(&mut config.llvm_use_libcxx, use_libcxx); - config.llvm_use_linker.clone_from(&use_linker); - config.llvm_allow_old_toolchain = allow_old_toolchain.unwrap_or(false); - config.llvm_offload = llvm_offload.unwrap_or(false); - config.llvm_polly = polly.unwrap_or(false); - config.llvm_clang = clang.unwrap_or(false); - config.llvm_enable_warnings = enable_warnings.unwrap_or(false); - config.llvm_build_config = build_config.clone().unwrap_or(Default::default()); + config.llvm_targets.clone_from(&llvm_targets_toml); + config.llvm_experimental_targets.clone_from(&llvm_experimental_targets_toml); + config.llvm_link_jobs = llvm_link_jobs_toml; + config.llvm_version_suffix.clone_from(&llvm_version_suffix_toml); + config.llvm_clang_cl.clone_from(&llvm_clang_cl_toml); + config.llvm_tests = llvm_tests_toml.unwrap_or_default(); + config.llvm_enzyme = llvm_enzyme_toml.unwrap_or_default(); + config.llvm_plugins = llvm_plugin_toml.unwrap_or_default(); + + config.llvm_cflags.clone_from(&llvm_cflags_toml); + config.llvm_cxxflags.clone_from(&llvm_cxxflags_toml); + config.llvm_ldflags.clone_from(&llvm_ldflags_toml); + set(&mut config.llvm_use_libcxx, llvm_use_libcxx_toml); + config.llvm_use_linker.clone_from(&llvm_use_linker_toml); + config.llvm_allow_old_toolchain = llvm_allow_old_toolchain_toml.unwrap_or(false); + config.llvm_offload = llvm_offload_toml.unwrap_or(false); + config.llvm_polly = llvm_polly_toml.unwrap_or(false); + config.llvm_clang = llvm_clang_toml.unwrap_or(false); + config.llvm_enable_warnings = llvm_enable_warnings_toml.unwrap_or(false); + config.llvm_build_config = llvm_build_config_toml.clone().unwrap_or(Default::default()); config.llvm_from_ci = - config.parse_download_ci_llvm(download_ci_llvm, config.llvm_assertions); + config.parse_download_ci_llvm(llvm_download_ci_llvm_toml, config.llvm_assertions); if config.llvm_from_ci { let warn = |option: &str| { @@ -1205,11 +1205,11 @@ impl Config { ); }; - if static_libstdcpp.is_some() { + if llvm_static_libstdcpp_toml.is_some() { warn("static-libstdcpp"); } - if link_shared.is_some() { + if llvm_link_shared_toml.is_some() { warn("link-shared"); } @@ -1218,7 +1218,7 @@ impl Config { // 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() { + if llvm_libzstd_toml.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 \ @@ -1230,7 +1230,7 @@ impl Config { } } - if !config.llvm_from_ci && config.llvm_thin_lto && link_shared.is_none() { + if !config.llvm_from_ci && config.llvm_thin_lto && llvm_link_shared_toml.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. From c008a4b49c897ce511c37fbb9cb7c97cc3b22ec7 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 17:47:15 +0530 Subject: [PATCH 18/27] make gcc toml fields follow a specific naming convention --- src/bootstrap/src/core/config/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 3f373a667899c..a42a8e7fe7fcb 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1237,9 +1237,9 @@ impl Config { config.llvm_link_shared.set(Some(true)); } - let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default(); + let Gcc { download_ci_gcc: gcc_download_ci_gcc_toml } = toml.gcc.unwrap_or_default(); - config.gcc_ci_mode = match gcc_download_ci_gcc { + config.gcc_ci_mode = match gcc_download_ci_gcc_toml { Some(value) => match value { true => GccCiMode::DownloadFromCi, false => GccCiMode::BuildLocally, From 4d2a2c22b566429aee5a19cc04f182a43bf35f72 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 17:49:30 +0530 Subject: [PATCH 19/27] make dist toml fields follow a specific naming convention --- src/bootstrap/src/core/config/config.rs | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index a42a8e7fe7fcb..7e8e66b36980c 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1272,22 +1272,22 @@ impl Config { } let Dist { - sign_folder: dist_sign_folder, - upload_addr: dist_upload_addr, - src_tarball: dist_src_tarball, - compression_formats: dist_compression_formats, - compression_profile: dist_compression_profile, - include_mingw_linker: dist_include_mingw_linker, - vendor: dist_vendor, + sign_folder: dist_sign_folder_toml, + upload_addr: dist_upload_addr_toml, + src_tarball: dist_src_tarball_toml, + compression_formats: dist_compression_formats_toml, + compression_profile: dist_compression_profile_toml, + include_mingw_linker: dist_include_mingw_linker_toml, + vendor: dist_vendor_toml, } = toml.dist.unwrap_or_default(); - config.dist_sign_folder = dist_sign_folder.map(PathBuf::from); - config.dist_upload_addr = dist_upload_addr; - config.dist_compression_formats = dist_compression_formats; - set(&mut config.dist_compression_profile, dist_compression_profile); - set(&mut config.rust_dist_src, dist_src_tarball); - set(&mut config.dist_include_mingw_linker, dist_include_mingw_linker); - config.dist_vendor = dist_vendor.unwrap_or_else(|| { + config.dist_sign_folder = dist_sign_folder_toml.map(PathBuf::from); + config.dist_upload_addr = dist_upload_addr_toml; + config.dist_compression_formats = dist_compression_formats_toml; + set(&mut config.dist_compression_profile, dist_compression_profile_toml); + set(&mut config.rust_dist_src, dist_src_tarball_toml); + set(&mut config.dist_include_mingw_linker, dist_include_mingw_linker_toml); + config.dist_vendor = dist_vendor_toml.unwrap_or_else(|| { // If we're building from git or tarball sources, enable it by default. config.rust_info.is_managed_git_subrepository() || config.rust_info.is_from_tarball() }); From ad98550f708d1b18e7c2ea800d67e9662eee6995 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 17:51:38 +0530 Subject: [PATCH 20/27] make install toml fields follow a specific naming convention --- src/bootstrap/src/core/config/config.rs | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 7e8e66b36980c..8736f271cdace 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -759,22 +759,22 @@ impl Config { config.verbose_tests = config.is_verbose(); let Install { - prefix: install_prefix, - sysconfdir: install_sysconfdir, - docdir: install_docdir, - bindir: install_bindir, - libdir: install_libdir, - mandir: install_mandir, - datadir: install_datadir, + prefix: install_prefix_toml, + sysconfdir: install_sysconfdir_toml, + docdir: install_docdir_toml, + bindir: install_bindir_toml, + libdir: install_libdir_toml, + mandir: install_mandir_toml, + datadir: install_datadir_toml, } = toml.install.unwrap_or_default(); - let install_prefix = install_prefix.map(PathBuf::from); - let install_sysconfdir = install_sysconfdir.map(PathBuf::from); - let install_docdir = install_docdir.map(PathBuf::from); - let install_bindir = install_bindir.map(PathBuf::from); - let install_libdir = install_libdir.map(PathBuf::from); - let install_mandir = install_mandir.map(PathBuf::from); - let install_datadir = install_datadir.map(PathBuf::from); + let install_prefix = install_prefix_toml.map(PathBuf::from); + let install_sysconfdir = install_sysconfdir_toml.map(PathBuf::from); + let install_docdir = install_docdir_toml.map(PathBuf::from); + let install_bindir = install_bindir_toml.map(PathBuf::from); + let install_libdir = install_libdir_toml.map(PathBuf::from); + let install_mandir = install_mandir_toml.map(PathBuf::from); + let install_datadir = install_datadir_toml.map(PathBuf::from); config.prefix = install_prefix; config.sysconfdir = install_sysconfdir; config.datadir = install_datadir; From 2c96132c72a07d149511e01f3c3045911eeb8a53 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 18:12:33 +0530 Subject: [PATCH 21/27] make build toml fields follow a specific naming convention --- src/bootstrap/src/core/config/config.rs | 245 ++++++++++++------------ 1 file changed, 120 insertions(+), 125 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 8736f271cdace..f8df5687f5a75 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -501,86 +501,85 @@ impl Config { // Now override TOML values with flags, to make sure that we won't later override flags with // TOML values by accident instead, because flags have higher priority. let Build { - description, - mut build, - host, - target, - build_dir, - cargo, - rustc, - rustfmt, - cargo_clippy, - docs, - compiler_docs, - library_docs_private_items, - docs_minification, - submodules, - gdb, - lldb, - nodejs, - npm, - python, - reuse, - locked_deps, - vendor, - full_bootstrap, - bootstrap_cache_path, - extended, - tools, - tool, - verbose: build_verbose, - sanitizers, - profiler, - cargo_native_static, - low_priority, - configure_args, - local_rebuild, - print_step_timings, - print_step_rusage, - check_stage, - doc_stage, - build_stage, - test_stage, - install_stage, - dist_stage, - bench_stage, - patch_binaries_for_nix, + description: build_description_toml, + build: mut build_build_toml, + host: build_host_toml, + target: build_target_toml, + build_dir: build_build_dir_toml, + cargo: build_cargo_toml, + rustc: build_rustc_toml, + rustfmt: build_rustfmt_toml, + cargo_clippy: build_cargo_clippy_toml, + docs: build_docs_toml, + compiler_docs: build_compiler_docs_toml, + library_docs_private_items: build_library_docs_private_items_toml, + docs_minification: build_docs_minification_toml, + submodules: build_submodules_toml, + gdb: build_gdb_toml, + lldb: build_lldb_toml, + nodejs: build_nodejs_toml, + npm: build_npm_toml, + python: build_python_toml, + reuse: build_reuse_toml, + locked_deps: build_locked_deps_toml, + vendor: build_vendor_toml, + full_bootstrap: build_full_bootstrap_toml, + bootstrap_cache_path: build_bootstrap_cache_path_toml, + extended: build_extended_toml, + tools: build_tools_toml, + tool: build_tool_toml, + verbose: build_verbose_toml, + sanitizers: build_sanitizers_toml, + profiler: build_profiler_toml, + cargo_native_static: build_cargo_native_static_toml, + low_priority: build_low_priority_toml, + configure_args: build_configure_args_toml, + local_rebuild: build_local_rebuild_toml, + print_step_timings: build_print_step_timings_toml, + print_step_rusage: build_print_step_rusage_toml, + check_stage: build_check_stage_toml, + doc_stage: build_doc_stage_toml, + build_stage: build_build_stage_toml, + test_stage: build_test_stage_toml, + install_stage: build_install_stage_toml, + dist_stage: build_dist_stage_toml, + bench_stage: build_bench_stage_toml, + patch_binaries_for_nix: build_patch_binaries_for_nix_toml, // This field is only used by bootstrap.py metrics: _, - android_ndk, - optimized_compiler_builtins, - mut jobs, - compiletest_diff_tool, - compiletest_allow_stage0, - compiletest_use_stage0_libtest, - tidy_extra_checks, - ccache, - exclude, + android_ndk: build_android_ndk_toml, + optimized_compiler_builtins: build_optimized_compiler_builtins_toml, + jobs: mut build_jobs_toml, + compiletest_diff_tool: build_compiletest_diff_tool_toml, + compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest_toml, + tidy_extra_checks: build_tidy_extra_checks_toml, + ccache: build_ccache_toml, + exclude: build_exclude_toml, } = toml.build.unwrap_or_default(); - jobs = flags_jobs.or(jobs); - build = flags_build.or(build); - let build_dir = flags_build_dir.or(build_dir.map(PathBuf::from)); + build_jobs_toml = flags_jobs.or(build_jobs_toml); + build_build_toml = flags_build.or(build_build_toml); + let build_dir = flags_build_dir.or(build_build_dir_toml.map(PathBuf::from)); let host = if let Some(TargetSelectionList(hosts)) = flags_host { Some(hosts) - } else if let Some(file_host) = host { + } else if let Some(file_host) = build_host_toml { Some(file_host.iter().map(|h| TargetSelection::from_user(h)).collect()) } else { None }; let target = if let Some(TargetSelectionList(targets)) = flags_target { Some(targets) - } else if let Some(file_target) = target { + } else if let Some(file_target) = build_target_toml { Some(file_target.iter().map(|h| TargetSelection::from_user(h)).collect()) } else { None }; - if let Some(rustc) = &rustc { + if let Some(rustc) = &build_rustc_toml { if !flags_skip_stage0_validation { check_stage0_version(&rustc, "rustc", &config.src, config.exec_ctx()); } } - if let Some(cargo) = &cargo { + if let Some(cargo) = &build_cargo_toml { if !flags_skip_stage0_validation { check_stage0_version(&cargo, "cargo", &config.src, config.exec_ctx()); } @@ -590,10 +589,10 @@ impl Config { // TOML. config .exec_ctx - .set_verbosity(cmp::max(build_verbose.unwrap_or_default() as u8, flags_verbose)); + .set_verbosity(cmp::max(build_verbose_toml.unwrap_or_default() as u8, flags_verbose)); let mut paths: Vec = flags_skip.into_iter().chain(flags_exclude).collect(); - if let Some(exclude) = exclude { + if let Some(exclude) = build_exclude_toml { paths.extend(exclude); } @@ -657,8 +656,8 @@ impl Config { "config.skip" = ?config.skip, ); - config.jobs = Some(threads_from_config(jobs.unwrap_or(0))); - if let Some(build) = build { + config.jobs = Some(threads_from_config(build_jobs_toml.unwrap_or(0))); + if let Some(build) = build_build_toml { config.host_target = TargetSelection::from_user(&build); } @@ -670,18 +669,13 @@ impl Config { config.out = absolute(&config.out).expect("can't make empty path absolute"); } - if cargo_clippy.is_some() && rustc.is_none() { + if build_cargo_clippy_toml.is_some() && build_rustc_toml.is_none() { println!( "WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict." ); } - config.patch_binaries_for_nix = patch_binaries_for_nix; - config.bootstrap_cache_path = bootstrap_cache_path; - config.llvm_assertions = - toml.llvm.as_ref().is_some_and(|llvm| llvm.assertions.unwrap_or(false)); - - config.initial_rustc = if let Some(rustc) = rustc { + config.initial_rustc = if let Some(rustc) = build_rustc_toml { rustc } else { let dwn_ctx = DownloadContext::from(&config); @@ -703,9 +697,9 @@ impl Config { .trim() )); - config.initial_cargo_clippy = cargo_clippy; + config.initial_cargo_clippy = build_cargo_clippy_toml; - config.initial_cargo = if let Some(cargo) = cargo { + config.initial_cargo = if let Some(cargo) = build_cargo_toml { cargo } else { let dwn_ctx = DownloadContext::from(&config); @@ -729,31 +723,33 @@ impl Config { config.hosts.clone() }; - config.nodejs = nodejs.map(PathBuf::from); - config.npm = npm.map(PathBuf::from); - config.gdb = gdb.map(PathBuf::from); - config.lldb = lldb.map(PathBuf::from); - config.python = python.map(PathBuf::from); - config.reuse = reuse.map(PathBuf::from); - config.submodules = submodules; - config.android_ndk = android_ndk; - set(&mut config.low_priority, low_priority); - set(&mut config.compiler_docs, compiler_docs); - set(&mut config.library_docs_private_items, library_docs_private_items); - set(&mut config.docs_minification, docs_minification); - set(&mut config.docs, docs); - set(&mut config.locked_deps, locked_deps); - set(&mut config.full_bootstrap, full_bootstrap); - set(&mut config.extended, extended); - config.tools = tools; - set(&mut config.tool, tool); - set(&mut config.sanitizers, sanitizers); - set(&mut config.profiler, profiler); - set(&mut config.cargo_native_static, cargo_native_static); - set(&mut config.configure_args, configure_args); - set(&mut config.local_rebuild, local_rebuild); - set(&mut config.print_step_timings, print_step_timings); - set(&mut config.print_step_rusage, print_step_rusage); + config.nodejs = build_nodejs_toml.map(PathBuf::from); + config.npm = build_npm_toml.map(PathBuf::from); + config.gdb = build_gdb_toml.map(PathBuf::from); + config.lldb = build_lldb_toml.map(PathBuf::from); + config.python = build_python_toml.map(PathBuf::from); + config.reuse = build_reuse_toml.map(PathBuf::from); + config.submodules = build_submodules_toml; + config.android_ndk = build_android_ndk_toml; + config.bootstrap_cache_path = build_bootstrap_cache_path_toml; + set(&mut config.low_priority, build_low_priority_toml); + set(&mut config.compiler_docs, build_compiler_docs_toml); + set(&mut config.library_docs_private_items, build_library_docs_private_items_toml); + set(&mut config.docs_minification, build_docs_minification_toml); + set(&mut config.docs, build_docs_toml); + set(&mut config.locked_deps, build_locked_deps_toml); + set(&mut config.full_bootstrap, build_full_bootstrap_toml); + set(&mut config.extended, build_extended_toml); + config.tools = build_tools_toml; + set(&mut config.tool, build_tool_toml); + set(&mut config.sanitizers, build_sanitizers_toml); + set(&mut config.profiler, build_profiler_toml); + set(&mut config.cargo_native_static, build_cargo_native_static_toml); + set(&mut config.configure_args, build_configure_args_toml); + set(&mut config.local_rebuild, build_local_rebuild_toml); + set(&mut config.print_step_timings, build_print_step_timings_toml); + set(&mut config.print_step_rusage, build_print_step_rusage_toml); + config.patch_binaries_for_nix = build_patch_binaries_for_nix_toml; // Verbose flag is a good default for `rust.verbose-tests`. config.verbose_tests = config.is_verbose(); @@ -818,7 +814,7 @@ impl Config { config.in_tree_llvm_info = config.git_info(false, &config.src.join("src/llvm-project")); config.in_tree_gcc_info = config.git_info(false, &config.src.join("src/gcc")); - config.vendor = vendor.unwrap_or( + config.vendor = build_vendor_toml.unwrap_or( config.rust_info.is_from_tarball() && config.src.join("vendor").exists() && config.src.join(".cargo/config.toml").exists(), @@ -1113,7 +1109,7 @@ impl Config { rust_debuginfo_level_tests_toml.unwrap_or(DebuginfoLevel::None); config.reproducible_artifacts = flags_reproducible_artifact; - config.description = description; + config.description = build_description_toml; // We need to override `rust.channel` if it's manually specified when using the CI rustc. // This is because if the compiler uses a different channel than the one specified in bootstrap.toml, @@ -1247,7 +1243,7 @@ impl Config { None => GccCiMode::default(), }; - match ccache { + match build_ccache_toml { Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()), Some(StringOrBool::Bool(true)) => { config.ccache = Some("ccache".to_string()); @@ -1292,7 +1288,7 @@ impl Config { config.rust_info.is_managed_git_subrepository() || config.rust_info.is_from_tarball() }); - config.initial_rustfmt = if let Some(r) = rustfmt { + config.initial_rustfmt = if let Some(r) = build_rustfmt_toml { Some(r) } else { let dwn_ctx = DownloadContext::from(&config); @@ -1313,41 +1309,40 @@ impl Config { } config.optimized_compiler_builtins = - optimized_compiler_builtins.unwrap_or(config.channel != "dev"); - - config.compiletest_diff_tool = compiletest_diff_tool; - - config.compiletest_allow_stage0 = compiletest_allow_stage0.unwrap_or(false); - config.compiletest_use_stage0_libtest = compiletest_use_stage0_libtest.unwrap_or(true); - - config.tidy_extra_checks = tidy_extra_checks; + build_optimized_compiler_builtins_toml.unwrap_or(config.channel != "dev"); + config.compiletest_diff_tool = build_compiletest_diff_tool_toml; + config.compiletest_use_stage0_libtest = + build_compiletest_use_stage0_libtest_toml.unwrap_or(true); + config.tidy_extra_checks = build_tidy_extra_checks_toml; let download_rustc = config.download_rustc_commit.is_some(); config.explicit_stage_from_cli = flags_stage.is_some(); - config.explicit_stage_from_config = test_stage.is_some() - || build_stage.is_some() - || doc_stage.is_some() - || dist_stage.is_some() - || install_stage.is_some() - || check_stage.is_some() - || bench_stage.is_some(); + config.explicit_stage_from_config = build_test_stage_toml.is_some() + || build_build_stage_toml.is_some() + || build_doc_stage_toml.is_some() + || build_dist_stage_toml.is_some() + || build_install_stage_toml.is_some() + || build_check_stage_toml.is_some() + || build_bench_stage_toml.is_some(); config.stage = match config.cmd { - Subcommand::Check { .. } => flags_stage.or(check_stage).unwrap_or(1), - Subcommand::Clippy { .. } | Subcommand::Fix => flags_stage.or(check_stage).unwrap_or(1), + Subcommand::Check { .. } => flags_stage.or(build_check_stage_toml).unwrap_or(1), + Subcommand::Clippy { .. } | Subcommand::Fix => { + flags_stage.or(build_check_stage_toml).unwrap_or(1) + } // `download-rustc` only has a speed-up for stage2 builds. Default to stage2 unless explicitly overridden. Subcommand::Doc { .. } => { - flags_stage.or(doc_stage).unwrap_or(if download_rustc { 2 } else { 1 }) + flags_stage.or(build_doc_stage_toml).unwrap_or(if download_rustc { 2 } else { 1 }) } Subcommand::Build => { - flags_stage.or(build_stage).unwrap_or(if download_rustc { 2 } else { 1 }) + flags_stage.or(build_build_stage_toml).unwrap_or(if download_rustc { 2 } else { 1 }) } Subcommand::Test { .. } | Subcommand::Miri { .. } => { - flags_stage.or(test_stage).unwrap_or(if download_rustc { 2 } else { 1 }) + flags_stage.or(build_test_stage_toml).unwrap_or(if download_rustc { 2 } else { 1 }) } - Subcommand::Bench { .. } => flags_stage.or(bench_stage).unwrap_or(2), - Subcommand::Dist => flags_stage.or(dist_stage).unwrap_or(2), - Subcommand::Install => flags_stage.or(install_stage).unwrap_or(2), + Subcommand::Bench { .. } => flags_stage.or(build_bench_stage_toml).unwrap_or(2), + Subcommand::Dist => flags_stage.or(build_dist_stage_toml).unwrap_or(2), + Subcommand::Install => flags_stage.or(build_install_stage_toml).unwrap_or(2), Subcommand::Perf { .. } => flags_stage.unwrap_or(1), // These are all bootstrap tools, which don't depend on the compiler. // The stage we pass shouldn't matter, but use 0 just in case. From a75326bde1018e38f74e979dd20309010c02fbae Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 18:21:02 +0530 Subject: [PATCH 22/27] move build config to the top of parse method --- src/bootstrap/src/core/config/config.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index f8df5687f5a75..00f76c40fc6af 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -487,17 +487,6 @@ impl Config { &get_toml, ); - if cfg!(test) { - // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the - // same ones used to call the tests (if custom ones are not defined in the toml). If we - // don't do that, bootstrap will use its own detection logic to find a suitable rustc - // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or - // Cargo in their bootstrap.toml. - let build = toml.build.get_or_insert_with(Default::default); - build.rustc = build.rustc.take().or(std::env::var_os("RUSTC").map(|p| p.into())); - build.cargo = build.cargo.take().or(std::env::var_os("CARGO").map(|p| p.into())); - } - // Now override TOML values with flags, to make sure that we won't later override flags with // TOML values by accident instead, because flags have higher priority. let Build { @@ -507,7 +496,7 @@ impl Config { target: build_target_toml, build_dir: build_build_dir_toml, cargo: build_cargo_toml, - rustc: build_rustc_toml, + rustc: mut build_rustc_toml, rustfmt: build_rustfmt_toml, cargo_clippy: build_cargo_clippy_toml, docs: build_docs_toml, @@ -556,8 +545,20 @@ impl Config { ccache: build_ccache_toml, exclude: build_exclude_toml, } = toml.build.unwrap_or_default(); + + if cfg!(test) { + // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the + // same ones used to call the tests (if custom ones are not defined in the toml). If we + // don't do that, bootstrap will use its own detection logic to find a suitable rustc + // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or + // Cargo in their bootstrap.toml. + build_rustc_toml = build_rustc_toml.take().or(std::env::var_os("RUSTC").map(|p| p.into())); + build_build_toml = build_build_toml.take().or(std::env::var_os("CARGO").map(|p| p.into_string().unwrap())); + } + build_jobs_toml = flags_jobs.or(build_jobs_toml); build_build_toml = flags_build.or(build_build_toml); + let build_dir = flags_build_dir.or(build_build_dir_toml.map(PathBuf::from)); let host = if let Some(TargetSelectionList(hosts)) = flags_host { Some(hosts) From 39d9cf7d952b14e0ea40486428a20032061bb53c Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 18:22:30 +0530 Subject: [PATCH 23/27] move install config to the top of parse method --- src/bootstrap/src/core/config/config.rs | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 00f76c40fc6af..3d42200d0d83a 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -546,14 +546,27 @@ impl Config { exclude: build_exclude_toml, } = toml.build.unwrap_or_default(); + let Install { + prefix: install_prefix_toml, + sysconfdir: install_sysconfdir_toml, + docdir: install_docdir_toml, + bindir: install_bindir_toml, + libdir: install_libdir_toml, + mandir: install_mandir_toml, + datadir: install_datadir_toml, + } = toml.install.unwrap_or_default(); + if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the // same ones used to call the tests (if custom ones are not defined in the toml). If we // don't do that, bootstrap will use its own detection logic to find a suitable rustc // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or // Cargo in their bootstrap.toml. - build_rustc_toml = build_rustc_toml.take().or(std::env::var_os("RUSTC").map(|p| p.into())); - build_build_toml = build_build_toml.take().or(std::env::var_os("CARGO").map(|p| p.into_string().unwrap())); + build_rustc_toml = + build_rustc_toml.take().or(std::env::var_os("RUSTC").map(|p| p.into())); + build_build_toml = build_build_toml + .take() + .or(std::env::var_os("CARGO").map(|p| p.into_string().unwrap())); } build_jobs_toml = flags_jobs.or(build_jobs_toml); @@ -755,16 +768,6 @@ impl Config { // Verbose flag is a good default for `rust.verbose-tests`. config.verbose_tests = config.is_verbose(); - let Install { - prefix: install_prefix_toml, - sysconfdir: install_sysconfdir_toml, - docdir: install_docdir_toml, - bindir: install_bindir_toml, - libdir: install_libdir_toml, - mandir: install_mandir_toml, - datadir: install_datadir_toml, - } = toml.install.unwrap_or_default(); - let install_prefix = install_prefix_toml.map(PathBuf::from); let install_sysconfdir = install_sysconfdir_toml.map(PathBuf::from); let install_docdir = install_docdir_toml.map(PathBuf::from); From 120d93efdbbb0f83bc5327d7fa18c95643e709cc Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 18:31:01 +0530 Subject: [PATCH 24/27] move rust config to the top of parse method --- src/bootstrap/src/core/config/config.rs | 117 ++++++++++++------------ 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 3d42200d0d83a..1550fe367465d 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -556,6 +556,62 @@ impl Config { datadir: install_datadir_toml, } = toml.install.unwrap_or_default(); + let Rust { + optimize: rust_optimize_toml, + debug: rust_debug_toml, + codegen_units: rust_codegen_units_toml, + codegen_units_std: rust_codegen_units_std_toml, + rustc_debug_assertions: rust_rustc_debug_assertions_toml, + std_debug_assertions: rust_std_debug_assertions_toml, + tools_debug_assertions: rust_tools_debug_assertions_toml, + overflow_checks: rust_overflow_checks_toml, + overflow_checks_std: rust_overflow_checks_std_toml, + debug_logging: rust_debug_logging_toml, + debuginfo_level: rust_debuginfo_level_toml, + debuginfo_level_rustc: rust_debuginfo_level_rustc_toml, + debuginfo_level_std: rust_debuginfo_level_std_toml, + debuginfo_level_tools: rust_debuginfo_level_tools_toml, + debuginfo_level_tests: rust_debuginfo_level_tests_toml, + backtrace: rust_backtrace_toml, + incremental: rust_incremental_toml, + randomize_layout: rust_randomize_layout_toml, + default_linker: rust_default_linker_toml, + channel: rust_channel_toml, + musl_root: rust_musl_root_toml, + rpath: rust_rpath_toml, + verbose_tests: rust_verbose_tests_toml, + optimize_tests: rust_optimize_tests_toml, + codegen_tests: rust_codegen_tests_toml, + omit_git_hash: rust_omit_git_hash_toml, + dist_src: rust_dist_src_toml, + save_toolstates: rust_save_toolstates_toml, + codegen_backends: rust_codegen_backends_toml, + lld: rust_lld_enabled_toml, + llvm_tools: rust_llvm_tools_toml, + llvm_bitcode_linker: rust_llvm_bitcode_linker_toml, + deny_warnings: rust_deny_warnings_toml, + backtrace_on_ice: rust_backtrace_on_ice_toml, + verify_llvm_ir: rust_verify_llvm_ir_toml, + thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_toml, + remap_debuginfo: rust_remap_debuginfo_toml, + jemalloc: rust_jemalloc_toml, + test_compare_mode: rust_test_compare_mode_toml, + llvm_libunwind: rust_llvm_libunwind_toml, + control_flow_guard: rust_control_flow_guard_toml, + ehcont_guard: rust_ehcont_guard_toml, + new_symbol_mangling: rust_new_symbol_mangling_toml, + profile_generate: rust_profile_generate_toml, + profile_use: rust_profile_use_toml, + download_rustc: rust_download_rustc_toml, + lto: rust_lto_toml, + validate_mir_opts: rust_validate_mir_opts_toml, + frame_pointers: rust_frame_pointers_toml, + stack_protector: rust_stack_protector_toml, + strip: rust_strip_toml, + lld_mode: rust_lld_mode_toml, + std_features: rust_std_features_toml, + } = toml.rust.unwrap_or_default(); + if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the // same ones used to call the tests (if custom ones are not defined in the toml). If we @@ -786,8 +842,7 @@ impl Config { let file_content = t!(fs::read_to_string(config.src.join("src/ci/channel"))); let ci_channel = file_content.trim_end(); - let toml_channel = toml.rust.as_ref().and_then(|r| r.channel.clone()); - let is_user_configured_rust_channel = match toml_channel { + let is_user_configured_rust_channel = match rust_channel_toml { Some(channel) if channel == "auto-detect" => { config.channel = ci_channel.into(); true @@ -800,7 +855,7 @@ impl Config { }; let default = config.channel == "dev"; - config.omit_git_hash = toml.rust.as_ref().and_then(|r| r.omit_git_hash).unwrap_or(default); + config.omit_git_hash = rust_omit_git_hash_toml.unwrap_or(default); config.rust_info = config.git_info(config.omit_git_hash, &config.src); config.cargo_info = @@ -894,62 +949,6 @@ impl Config { } } - let Rust { - optimize: rust_optimize_toml, - debug: rust_debug_toml, - codegen_units: rust_codegen_units_toml, - codegen_units_std: rust_codegen_units_std_toml, - rustc_debug_assertions: rust_rustc_debug_assertions_toml, - std_debug_assertions: rust_std_debug_assertions_toml, - tools_debug_assertions: rust_tools_debug_assertions_toml, - overflow_checks: rust_overflow_checks_toml, - overflow_checks_std: rust_overflow_checks_std_toml, - debug_logging: rust_debug_logging_toml, - debuginfo_level: rust_debuginfo_level_toml, - debuginfo_level_rustc: rust_debuginfo_level_rustc_toml, - debuginfo_level_std: rust_debuginfo_level_std_toml, - debuginfo_level_tools: rust_debuginfo_level_tools_toml, - debuginfo_level_tests: rust_debuginfo_level_tests_toml, - backtrace: rust_backtrace_toml, - incremental: rust_incremental_toml, - randomize_layout: rust_randomize_layout_toml, - default_linker: rust_default_linker_toml, - channel: _, // already handled above - musl_root: rust_musl_root_toml, - rpath: rust_rpath_toml, - verbose_tests: rust_verbose_tests_toml, - optimize_tests: rust_optimize_tests_toml, - codegen_tests: rust_codegen_tests_toml, - omit_git_hash: _, // already handled above - dist_src: rust_dist_src_toml, - save_toolstates: rust_save_toolstates_toml, - codegen_backends: rust_codegen_backends_toml, - lld: rust_lld_enabled_toml, - llvm_tools: rust_llvm_tools_toml, - llvm_bitcode_linker: rust_llvm_bitcode_linker_toml, - deny_warnings: rust_deny_warnings_toml, - backtrace_on_ice: rust_backtrace_on_ice_toml, - verify_llvm_ir: rust_verify_llvm_ir_toml, - thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_toml, - remap_debuginfo: rust_remap_debuginfo_toml, - jemalloc: rust_jemalloc_toml, - test_compare_mode: rust_test_compare_mode_toml, - llvm_libunwind: rust_llvm_libunwind_toml, - control_flow_guard: rust_control_flow_guard_toml, - ehcont_guard: rust_ehcont_guard_toml, - new_symbol_mangling: rust_new_symbol_mangling_toml, - profile_generate: rust_profile_generate_toml, - profile_use: rust_profile_use_toml, - download_rustc: rust_download_rustc_toml, - lto: rust_lto_toml, - validate_mir_opts: rust_validate_mir_opts_toml, - frame_pointers: rust_frame_pointers_toml, - stack_protector: rust_stack_protector_toml, - strip: rust_strip_toml, - lld_mode: rust_lld_mode_toml, - std_features: rust_std_features_toml, - } = toml.rust.unwrap_or_default(); - // FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions // enabled. We should not download a CI alt rustc if we need rustc to have debug // assertions (e.g. for crashes test suite). This can be changed once something like From f74f1a006c983d621c5bf2c9989d695a14342c41 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 18:33:55 +0530 Subject: [PATCH 25/27] move llvm config to the top of parse method --- src/bootstrap/src/core/config/config.rs | 67 +++++++++++++------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 1550fe367465d..73e4e4310e074 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -612,6 +612,37 @@ impl Config { std_features: rust_std_features_toml, } = toml.rust.unwrap_or_default(); + let Llvm { + optimize: llvm_optimize_toml, + thin_lto: llvm_thin_lto_toml, + release_debuginfo: llvm_release_debuginfo_toml, + assertions: llvm_assertions_toml, + tests: llvm_tests_toml, + enzyme: llvm_enzyme_toml, + plugins: llvm_plugin_toml, + static_libstdcpp: llvm_static_libstdcpp_toml, + libzstd: llvm_libzstd_toml, + ninja: llvm_ninja_toml, + targets: llvm_targets_toml, + experimental_targets: llvm_experimental_targets_toml, + link_jobs: llvm_link_jobs_toml, + link_shared: llvm_link_shared_toml, + version_suffix: llvm_version_suffix_toml, + clang_cl: llvm_clang_cl_toml, + cflags: llvm_cflags_toml, + cxxflags: llvm_cxxflags_toml, + ldflags: llvm_ldflags_toml, + use_libcxx: llvm_use_libcxx_toml, + use_linker: llvm_use_linker_toml, + allow_old_toolchain: llvm_allow_old_toolchain_toml, + offload: llvm_offload_toml, + polly: llvm_polly_toml, + clang: llvm_clang_toml, + enable_warnings: llvm_enable_warnings_toml, + download_ci_llvm: llvm_download_ci_llvm_toml, + build_config: llvm_build_config_toml, + } = toml.llvm.unwrap_or_default(); + if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the // same ones used to call the tests (if custom ones are not defined in the toml). If we @@ -839,6 +870,11 @@ impl Config { config.libdir = install_libdir; config.mandir = install_mandir; +<<<<<<< HEAD +======= + config.llvm_assertions = llvm_assertions_toml.unwrap_or(false); + +>>>>>>> f1dbcb5ad2c (move llvm config to the top of parse method) let file_content = t!(fs::read_to_string(config.src.join("src/ci/channel"))); let ci_channel = file_content.trim_end(); @@ -1130,37 +1166,6 @@ impl Config { config.channel = channel; } - let Llvm { - optimize: llvm_optimize_toml, - thin_lto: llvm_thin_lto_toml, - release_debuginfo: llvm_release_debuginfo_toml, - assertions: _, - tests: llvm_tests_toml, - enzyme: llvm_enzyme_toml, - plugins: llvm_plugin_toml, - static_libstdcpp: llvm_static_libstdcpp_toml, - libzstd: llvm_libzstd_toml, - ninja: llvm_ninja_toml, - targets: llvm_targets_toml, - experimental_targets: llvm_experimental_targets_toml, - link_jobs: llvm_link_jobs_toml, - link_shared: llvm_link_shared_toml, - version_suffix: llvm_version_suffix_toml, - clang_cl: llvm_clang_cl_toml, - cflags: llvm_cflags_toml, - cxxflags: llvm_cxxflags_toml, - ldflags: llvm_ldflags_toml, - use_libcxx: llvm_use_libcxx_toml, - use_linker: llvm_use_linker_toml, - allow_old_toolchain: llvm_allow_old_toolchain_toml, - offload: llvm_offload_toml, - polly: llvm_polly_toml, - clang: llvm_clang_toml, - enable_warnings: llvm_enable_warnings_toml, - download_ci_llvm: llvm_download_ci_llvm_toml, - build_config: llvm_build_config_toml, - } = toml.llvm.unwrap_or_default(); - set(&mut config.ninja_in_file, llvm_ninja_toml); set(&mut config.llvm_optimize, llvm_optimize_toml); set(&mut config.llvm_thin_lto, llvm_thin_lto_toml); From 7f20ad86ba273315252c44adbce3ad99b6651863 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 1 Aug 2025 18:37:11 +0530 Subject: [PATCH 26/27] move dist and gcc config to the top of parse method --- src/bootstrap/src/core/config/config.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 73e4e4310e074..59c20377066af 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -643,6 +643,18 @@ impl Config { build_config: llvm_build_config_toml, } = toml.llvm.unwrap_or_default(); + let Dist { + sign_folder: dist_sign_folder_toml, + upload_addr: dist_upload_addr_toml, + src_tarball: dist_src_tarball_toml, + compression_formats: dist_compression_formats_toml, + compression_profile: dist_compression_profile_toml, + include_mingw_linker: dist_include_mingw_linker_toml, + vendor: dist_vendor_toml, + } = toml.dist.unwrap_or_default(); + + let Gcc { download_ci_gcc: gcc_download_ci_gcc_toml } = toml.gcc.unwrap_or_default(); + if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the // same ones used to call the tests (if custom ones are not defined in the toml). If we @@ -1241,8 +1253,6 @@ impl Config { config.llvm_link_shared.set(Some(true)); } - let Gcc { download_ci_gcc: gcc_download_ci_gcc_toml } = toml.gcc.unwrap_or_default(); - config.gcc_ci_mode = match gcc_download_ci_gcc_toml { Some(value) => match value { true => GccCiMode::DownloadFromCi, @@ -1275,16 +1285,6 @@ impl Config { Some(ci_llvm_bin.join(exe("FileCheck", config.host_target))); } - let Dist { - sign_folder: dist_sign_folder_toml, - upload_addr: dist_upload_addr_toml, - src_tarball: dist_src_tarball_toml, - compression_formats: dist_compression_formats_toml, - compression_profile: dist_compression_profile_toml, - include_mingw_linker: dist_include_mingw_linker_toml, - vendor: dist_vendor_toml, - } = toml.dist.unwrap_or_default(); - config.dist_sign_folder = dist_sign_folder_toml.map(PathBuf::from); config.dist_upload_addr = dist_upload_addr_toml; config.dist_compression_formats = dist_compression_formats_toml; From a2794f93e6584466fd7c042df2520489946c3ac2 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Mon, 4 Aug 2025 21:36:37 +0530 Subject: [PATCH 27/27] remove redundant _toml suffix and other misc changes --- src/bootstrap/src/core/config/config.rs | 697 +++++++++---------- src/bootstrap/src/core/config/toml/mod.rs | 2 +- src/bootstrap/src/core/config/toml/rust.rs | 2 +- src/bootstrap/src/core/config/toml/target.rs | 7 +- 4 files changed, 345 insertions(+), 363 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 59c20377066af..b3a4912043608 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -43,7 +43,7 @@ use crate::core::config::toml::install::Install; use crate::core::config::toml::llvm::Llvm; use crate::core::config::toml::rust::{ LldMode, Rust, RustOptimize, check_incompatible_options_for_ci_rustc, - default_lld_opt_in_targets, validate_codegen_backends, + default_lld_opt_in_targets, parse_codegen_backends, }; use crate::core::config::toml::target::Target; use crate::core::config::{ @@ -490,170 +490,171 @@ impl Config { // Now override TOML values with flags, to make sure that we won't later override flags with // TOML values by accident instead, because flags have higher priority. let Build { - description: build_description_toml, - build: mut build_build_toml, - host: build_host_toml, - target: build_target_toml, - build_dir: build_build_dir_toml, - cargo: build_cargo_toml, - rustc: mut build_rustc_toml, - rustfmt: build_rustfmt_toml, - cargo_clippy: build_cargo_clippy_toml, - docs: build_docs_toml, - compiler_docs: build_compiler_docs_toml, - library_docs_private_items: build_library_docs_private_items_toml, - docs_minification: build_docs_minification_toml, - submodules: build_submodules_toml, - gdb: build_gdb_toml, - lldb: build_lldb_toml, - nodejs: build_nodejs_toml, - npm: build_npm_toml, - python: build_python_toml, - reuse: build_reuse_toml, - locked_deps: build_locked_deps_toml, - vendor: build_vendor_toml, - full_bootstrap: build_full_bootstrap_toml, - bootstrap_cache_path: build_bootstrap_cache_path_toml, - extended: build_extended_toml, - tools: build_tools_toml, - tool: build_tool_toml, - verbose: build_verbose_toml, - sanitizers: build_sanitizers_toml, - profiler: build_profiler_toml, - cargo_native_static: build_cargo_native_static_toml, - low_priority: build_low_priority_toml, - configure_args: build_configure_args_toml, - local_rebuild: build_local_rebuild_toml, - print_step_timings: build_print_step_timings_toml, - print_step_rusage: build_print_step_rusage_toml, - check_stage: build_check_stage_toml, - doc_stage: build_doc_stage_toml, - build_stage: build_build_stage_toml, - test_stage: build_test_stage_toml, - install_stage: build_install_stage_toml, - dist_stage: build_dist_stage_toml, - bench_stage: build_bench_stage_toml, - patch_binaries_for_nix: build_patch_binaries_for_nix_toml, + description: build_description, + build: mut build_build, + host: build_host, + target: build_target, + build_dir: build_build_dir, + cargo: mut build_cargo, + rustc: mut build_rustc, + rustfmt: build_rustfmt, + cargo_clippy: build_cargo_clippy, + docs: build_docs, + compiler_docs: build_compiler_docs, + library_docs_private_items: build_library_docs_private_items, + docs_minification: build_docs_minification, + submodules: build_submodules, + gdb: build_gdb, + lldb: build_lldb, + nodejs: build_nodejs, + npm: build_npm, + python: build_python, + reuse: build_reuse, + locked_deps: build_locked_deps, + vendor: build_vendor, + full_bootstrap: build_full_bootstrap, + bootstrap_cache_path: build_bootstrap_cache_path, + extended: build_extended, + tools: build_tools, + tool: build_tool, + verbose: build_verbose, + sanitizers: build_sanitizers, + profiler: build_profiler, + cargo_native_static: build_cargo_native_static, + low_priority: build_low_priority, + configure_args: build_configure_args, + local_rebuild: build_local_rebuild, + print_step_timings: build_print_step_timings, + print_step_rusage: build_print_step_rusage, + check_stage: build_check_stage, + doc_stage: build_doc_stage, + build_stage: build_build_stage, + test_stage: build_test_stage, + install_stage: build_install_stage, + dist_stage: build_dist_stage, + bench_stage: build_bench_stage, + patch_binaries_for_nix: build_patch_binaries_for_nix, // This field is only used by bootstrap.py metrics: _, - android_ndk: build_android_ndk_toml, - optimized_compiler_builtins: build_optimized_compiler_builtins_toml, - jobs: mut build_jobs_toml, - compiletest_diff_tool: build_compiletest_diff_tool_toml, - compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest_toml, - tidy_extra_checks: build_tidy_extra_checks_toml, - ccache: build_ccache_toml, - exclude: build_exclude_toml, + android_ndk: build_android_ndk, + optimized_compiler_builtins: build_optimized_compiler_builtins, + jobs: mut build_jobs, + compiletest_diff_tool: build_compiletest_diff_tool, + compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest, + tidy_extra_checks: build_tidy_extra_checks, + ccache: build_ccache, + exclude: build_exclude, + compiletest_allow_stage0: build_compiletest_allow_stage0, } = toml.build.unwrap_or_default(); let Install { - prefix: install_prefix_toml, - sysconfdir: install_sysconfdir_toml, - docdir: install_docdir_toml, - bindir: install_bindir_toml, - libdir: install_libdir_toml, - mandir: install_mandir_toml, - datadir: install_datadir_toml, + prefix: install_prefix, + sysconfdir: install_sysconfdir, + docdir: install_docdir, + bindir: install_bindir, + libdir: install_libdir, + mandir: install_mandir, + datadir: install_datadir, } = toml.install.unwrap_or_default(); let Rust { - optimize: rust_optimize_toml, - debug: rust_debug_toml, - codegen_units: rust_codegen_units_toml, - codegen_units_std: rust_codegen_units_std_toml, - rustc_debug_assertions: rust_rustc_debug_assertions_toml, - std_debug_assertions: rust_std_debug_assertions_toml, - tools_debug_assertions: rust_tools_debug_assertions_toml, - overflow_checks: rust_overflow_checks_toml, - overflow_checks_std: rust_overflow_checks_std_toml, - debug_logging: rust_debug_logging_toml, - debuginfo_level: rust_debuginfo_level_toml, - debuginfo_level_rustc: rust_debuginfo_level_rustc_toml, - debuginfo_level_std: rust_debuginfo_level_std_toml, - debuginfo_level_tools: rust_debuginfo_level_tools_toml, - debuginfo_level_tests: rust_debuginfo_level_tests_toml, - backtrace: rust_backtrace_toml, - incremental: rust_incremental_toml, - randomize_layout: rust_randomize_layout_toml, - default_linker: rust_default_linker_toml, - channel: rust_channel_toml, - musl_root: rust_musl_root_toml, - rpath: rust_rpath_toml, - verbose_tests: rust_verbose_tests_toml, - optimize_tests: rust_optimize_tests_toml, - codegen_tests: rust_codegen_tests_toml, - omit_git_hash: rust_omit_git_hash_toml, - dist_src: rust_dist_src_toml, - save_toolstates: rust_save_toolstates_toml, - codegen_backends: rust_codegen_backends_toml, - lld: rust_lld_enabled_toml, - llvm_tools: rust_llvm_tools_toml, - llvm_bitcode_linker: rust_llvm_bitcode_linker_toml, - deny_warnings: rust_deny_warnings_toml, - backtrace_on_ice: rust_backtrace_on_ice_toml, - verify_llvm_ir: rust_verify_llvm_ir_toml, - thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit_toml, - remap_debuginfo: rust_remap_debuginfo_toml, - jemalloc: rust_jemalloc_toml, - test_compare_mode: rust_test_compare_mode_toml, - llvm_libunwind: rust_llvm_libunwind_toml, - control_flow_guard: rust_control_flow_guard_toml, - ehcont_guard: rust_ehcont_guard_toml, - new_symbol_mangling: rust_new_symbol_mangling_toml, - profile_generate: rust_profile_generate_toml, - profile_use: rust_profile_use_toml, - download_rustc: rust_download_rustc_toml, - lto: rust_lto_toml, - validate_mir_opts: rust_validate_mir_opts_toml, - frame_pointers: rust_frame_pointers_toml, - stack_protector: rust_stack_protector_toml, - strip: rust_strip_toml, - lld_mode: rust_lld_mode_toml, - std_features: rust_std_features_toml, + optimize: rust_optimize, + debug: rust_debug, + codegen_units: rust_codegen_units, + codegen_units_std: rust_codegen_units_std, + rustc_debug_assertions: rust_rustc_debug_assertions, + std_debug_assertions: rust_std_debug_assertions, + tools_debug_assertions: rust_tools_debug_assertions, + overflow_checks: rust_overflow_checks, + overflow_checks_std: rust_overflow_checks_std, + debug_logging: rust_debug_logging, + debuginfo_level: rust_debuginfo_level, + debuginfo_level_rustc: rust_debuginfo_level_rustc, + debuginfo_level_std: rust_debuginfo_level_std, + debuginfo_level_tools: rust_debuginfo_level_tools, + debuginfo_level_tests: rust_debuginfo_level_tests, + backtrace: rust_backtrace, + incremental: rust_incremental, + randomize_layout: rust_randomize_layout, + default_linker: rust_default_linker, + channel: rust_channel, + musl_root: rust_musl_root, + rpath: rust_rpath, + verbose_tests: rust_verbose_tests, + optimize_tests: rust_optimize_tests, + codegen_tests: rust_codegen_tests, + omit_git_hash: rust_omit_git_hash, + dist_src: rust_dist_src, + save_toolstates: rust_save_toolstates, + codegen_backends: rust_codegen_backends, + lld: rust_lld_enabled, + llvm_tools: rust_llvm_tools, + llvm_bitcode_linker: rust_llvm_bitcode_linker, + deny_warnings: rust_deny_warnings, + backtrace_on_ice: rust_backtrace_on_ice, + verify_llvm_ir: rust_verify_llvm_ir, + thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit, + remap_debuginfo: rust_remap_debuginfo, + jemalloc: rust_jemalloc, + test_compare_mode: rust_test_compare_mode, + llvm_libunwind: rust_llvm_libunwind, + control_flow_guard: rust_control_flow_guard, + ehcont_guard: rust_ehcont_guard, + new_symbol_mangling: rust_new_symbol_mangling, + profile_generate: rust_profile_generate, + profile_use: rust_profile_use, + download_rustc: rust_download_rustc, + lto: rust_lto, + validate_mir_opts: rust_validate_mir_opts, + frame_pointers: rust_frame_pointers, + stack_protector: rust_stack_protector, + strip: rust_strip, + lld_mode: rust_lld_mode, + std_features: rust_std_features, } = toml.rust.unwrap_or_default(); let Llvm { - optimize: llvm_optimize_toml, - thin_lto: llvm_thin_lto_toml, - release_debuginfo: llvm_release_debuginfo_toml, - assertions: llvm_assertions_toml, - tests: llvm_tests_toml, - enzyme: llvm_enzyme_toml, - plugins: llvm_plugin_toml, - static_libstdcpp: llvm_static_libstdcpp_toml, - libzstd: llvm_libzstd_toml, - ninja: llvm_ninja_toml, - targets: llvm_targets_toml, - experimental_targets: llvm_experimental_targets_toml, - link_jobs: llvm_link_jobs_toml, - link_shared: llvm_link_shared_toml, - version_suffix: llvm_version_suffix_toml, - clang_cl: llvm_clang_cl_toml, - cflags: llvm_cflags_toml, - cxxflags: llvm_cxxflags_toml, - ldflags: llvm_ldflags_toml, - use_libcxx: llvm_use_libcxx_toml, - use_linker: llvm_use_linker_toml, - allow_old_toolchain: llvm_allow_old_toolchain_toml, - offload: llvm_offload_toml, - polly: llvm_polly_toml, - clang: llvm_clang_toml, - enable_warnings: llvm_enable_warnings_toml, - download_ci_llvm: llvm_download_ci_llvm_toml, - build_config: llvm_build_config_toml, + optimize: llvm_optimize, + thin_lto: llvm_thin_lto, + release_debuginfo: llvm_release_debuginfo, + assertions: llvm_assertions, + tests: llvm_tests, + enzyme: llvm_enzyme, + plugins: llvm_plugin, + static_libstdcpp: llvm_static_libstdcpp, + libzstd: llvm_libzstd, + ninja: llvm_ninja, + targets: llvm_targets, + experimental_targets: llvm_experimental_targets, + link_jobs: llvm_link_jobs, + link_shared: llvm_link_shared, + version_suffix: llvm_version_suffix, + clang_cl: llvm_clang_cl, + cflags: llvm_cflags, + cxxflags: llvm_cxxflags, + ldflags: llvm_ldflags, + use_libcxx: llvm_use_libcxx, + use_linker: llvm_use_linker, + allow_old_toolchain: llvm_allow_old_toolchain, + offload: llvm_offload, + polly: llvm_polly, + clang: llvm_clang, + enable_warnings: llvm_enable_warnings, + download_ci_llvm: llvm_download_ci_llvm, + build_config: llvm_build_config, } = toml.llvm.unwrap_or_default(); let Dist { - sign_folder: dist_sign_folder_toml, - upload_addr: dist_upload_addr_toml, - src_tarball: dist_src_tarball_toml, - compression_formats: dist_compression_formats_toml, - compression_profile: dist_compression_profile_toml, - include_mingw_linker: dist_include_mingw_linker_toml, - vendor: dist_vendor_toml, + sign_folder: dist_sign_folder, + upload_addr: dist_upload_addr, + src_tarball: dist_src_tarball, + compression_formats: dist_compression_formats, + compression_profile: dist_compression_profile, + include_mingw_linker: dist_include_mingw_linker, + vendor: dist_vendor, } = toml.dist.unwrap_or_default(); - let Gcc { download_ci_gcc: gcc_download_ci_gcc_toml } = toml.gcc.unwrap_or_default(); + let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default(); if cfg!(test) { // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the @@ -661,51 +662,47 @@ impl Config { // don't do that, bootstrap will use its own detection logic to find a suitable rustc // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or // Cargo in their bootstrap.toml. - build_rustc_toml = - build_rustc_toml.take().or(std::env::var_os("RUSTC").map(|p| p.into())); - build_build_toml = build_build_toml - .take() - .or(std::env::var_os("CARGO").map(|p| p.into_string().unwrap())); + build_rustc = build_rustc.take().or(std::env::var_os("RUSTC").map(|p| p.into())); + build_cargo = build_cargo.take().or(std::env::var_os("CARGO").map(|p| p.into())); } - build_jobs_toml = flags_jobs.or(build_jobs_toml); - build_build_toml = flags_build.or(build_build_toml); + build_jobs = flags_jobs.or(build_jobs); + build_build = flags_build.or(build_build); - let build_dir = flags_build_dir.or(build_build_dir_toml.map(PathBuf::from)); + let build_dir = flags_build_dir.or(build_build_dir.map(PathBuf::from)); let host = if let Some(TargetSelectionList(hosts)) = flags_host { Some(hosts) - } else if let Some(file_host) = build_host_toml { - Some(file_host.iter().map(|h| TargetSelection::from_user(h)).collect()) } else { - None + build_host + .map(|file_host| file_host.iter().map(|h| TargetSelection::from_user(h)).collect()) }; let target = if let Some(TargetSelectionList(targets)) = flags_target { Some(targets) - } else if let Some(file_target) = build_target_toml { - Some(file_target.iter().map(|h| TargetSelection::from_user(h)).collect()) } else { - None + build_target.map(|file_target| { + file_target.iter().map(|h| TargetSelection::from_user(h)).collect() + }) }; - if let Some(rustc) = &build_rustc_toml { - if !flags_skip_stage0_validation { - check_stage0_version(&rustc, "rustc", &config.src, config.exec_ctx()); - } + if let Some(rustc) = &build_rustc + && !flags_skip_stage0_validation + { + check_stage0_version(rustc, "rustc", &config.src, config.exec_ctx()); } - if let Some(cargo) = &build_cargo_toml { - if !flags_skip_stage0_validation { - check_stage0_version(&cargo, "cargo", &config.src, config.exec_ctx()); - } + if let Some(cargo) = &build_cargo + && !flags_skip_stage0_validation + { + check_stage0_version(cargo, "cargo", &config.src, config.exec_ctx()); } // Prefer CLI verbosity flags if set (`flags_verbose` > 0), otherwise take the value from // TOML. config .exec_ctx - .set_verbosity(cmp::max(build_verbose_toml.unwrap_or_default() as u8, flags_verbose)); + .set_verbosity(cmp::max(build_verbose.unwrap_or_default() as u8, flags_verbose)); let mut paths: Vec = flags_skip.into_iter().chain(flags_exclude).collect(); - if let Some(exclude) = build_exclude_toml { + if let Some(exclude) = build_exclude { paths.extend(exclude); } @@ -743,6 +740,7 @@ impl Config { .to_path_buf(); } + config.compiletest_allow_stage0 = build_compiletest_allow_stage0.unwrap_or(false); config.stage0_metadata = build_helper::stage0_parser::parse_stage0_file(); config.change_id = toml.change_id.inner; @@ -769,8 +767,8 @@ impl Config { "config.skip" = ?config.skip, ); - config.jobs = Some(threads_from_config(build_jobs_toml.unwrap_or(0))); - if let Some(build) = build_build_toml { + config.jobs = Some(threads_from_config(build_jobs.unwrap_or(0))); + if let Some(build) = build_build { config.host_target = TargetSelection::from_user(&build); } @@ -782,13 +780,13 @@ impl Config { config.out = absolute(&config.out).expect("can't make empty path absolute"); } - if build_cargo_clippy_toml.is_some() && build_rustc_toml.is_none() { + if build_cargo_clippy.is_some() && build_rustc.is_none() { println!( "WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict." ); } - config.initial_rustc = if let Some(rustc) = build_rustc_toml { + config.initial_rustc = if let Some(rustc) = build_rustc { rustc } else { let dwn_ctx = DownloadContext::from(&config); @@ -810,9 +808,9 @@ impl Config { .trim() )); - config.initial_cargo_clippy = build_cargo_clippy_toml; + config.initial_cargo_clippy = build_cargo_clippy; - config.initial_cargo = if let Some(cargo) = build_cargo_toml { + config.initial_cargo = if let Some(cargo) = build_cargo { cargo } else { let dwn_ctx = DownloadContext::from(&config); @@ -836,61 +834,51 @@ impl Config { config.hosts.clone() }; - config.nodejs = build_nodejs_toml.map(PathBuf::from); - config.npm = build_npm_toml.map(PathBuf::from); - config.gdb = build_gdb_toml.map(PathBuf::from); - config.lldb = build_lldb_toml.map(PathBuf::from); - config.python = build_python_toml.map(PathBuf::from); - config.reuse = build_reuse_toml.map(PathBuf::from); - config.submodules = build_submodules_toml; - config.android_ndk = build_android_ndk_toml; - config.bootstrap_cache_path = build_bootstrap_cache_path_toml; - set(&mut config.low_priority, build_low_priority_toml); - set(&mut config.compiler_docs, build_compiler_docs_toml); - set(&mut config.library_docs_private_items, build_library_docs_private_items_toml); - set(&mut config.docs_minification, build_docs_minification_toml); - set(&mut config.docs, build_docs_toml); - set(&mut config.locked_deps, build_locked_deps_toml); - set(&mut config.full_bootstrap, build_full_bootstrap_toml); - set(&mut config.extended, build_extended_toml); - config.tools = build_tools_toml; - set(&mut config.tool, build_tool_toml); - set(&mut config.sanitizers, build_sanitizers_toml); - set(&mut config.profiler, build_profiler_toml); - set(&mut config.cargo_native_static, build_cargo_native_static_toml); - set(&mut config.configure_args, build_configure_args_toml); - set(&mut config.local_rebuild, build_local_rebuild_toml); - set(&mut config.print_step_timings, build_print_step_timings_toml); - set(&mut config.print_step_rusage, build_print_step_rusage_toml); - config.patch_binaries_for_nix = build_patch_binaries_for_nix_toml; + config.nodejs = build_nodejs.map(PathBuf::from); + config.npm = build_npm.map(PathBuf::from); + config.gdb = build_gdb.map(PathBuf::from); + config.lldb = build_lldb.map(PathBuf::from); + config.python = build_python.map(PathBuf::from); + config.reuse = build_reuse.map(PathBuf::from); + config.submodules = build_submodules; + config.android_ndk = build_android_ndk; + config.bootstrap_cache_path = build_bootstrap_cache_path; + set(&mut config.low_priority, build_low_priority); + set(&mut config.compiler_docs, build_compiler_docs); + set(&mut config.library_docs_private_items, build_library_docs_private_items); + set(&mut config.docs_minification, build_docs_minification); + set(&mut config.docs, build_docs); + set(&mut config.locked_deps, build_locked_deps); + set(&mut config.full_bootstrap, build_full_bootstrap); + set(&mut config.extended, build_extended); + config.tools = build_tools; + set(&mut config.tool, build_tool); + set(&mut config.sanitizers, build_sanitizers); + set(&mut config.profiler, build_profiler); + set(&mut config.cargo_native_static, build_cargo_native_static); + set(&mut config.configure_args, build_configure_args); + set(&mut config.local_rebuild, build_local_rebuild); + set(&mut config.print_step_timings, build_print_step_timings); + set(&mut config.print_step_rusage, build_print_step_rusage); + config.patch_binaries_for_nix = build_patch_binaries_for_nix; // Verbose flag is a good default for `rust.verbose-tests`. config.verbose_tests = config.is_verbose(); - let install_prefix = install_prefix_toml.map(PathBuf::from); - let install_sysconfdir = install_sysconfdir_toml.map(PathBuf::from); - let install_docdir = install_docdir_toml.map(PathBuf::from); - let install_bindir = install_bindir_toml.map(PathBuf::from); - let install_libdir = install_libdir_toml.map(PathBuf::from); - let install_mandir = install_mandir_toml.map(PathBuf::from); - let install_datadir = install_datadir_toml.map(PathBuf::from); - config.prefix = install_prefix; - config.sysconfdir = install_sysconfdir; - config.datadir = install_datadir; - config.docdir = install_docdir; - set(&mut config.bindir, install_bindir); - config.libdir = install_libdir; - config.mandir = install_mandir; - -<<<<<<< HEAD -======= - config.llvm_assertions = llvm_assertions_toml.unwrap_or(false); - ->>>>>>> f1dbcb5ad2c (move llvm config to the top of parse method) + config.prefix = install_prefix.map(PathBuf::from); + config.sysconfdir = install_sysconfdir.map(PathBuf::from); + config.datadir = install_datadir.map(PathBuf::from); + config.docdir = install_docdir.map(PathBuf::from); + set(&mut config.bindir, install_bindir.map(PathBuf::from)); + config.libdir = install_libdir.map(PathBuf::from); + config.mandir = install_mandir.map(PathBuf::from); + + config.llvm_assertions = llvm_assertions.unwrap_or(false); + let file_content = t!(fs::read_to_string(config.src.join("src/ci/channel"))); let ci_channel = file_content.trim_end(); - let is_user_configured_rust_channel = match rust_channel_toml { + let is_user_configured_rust_channel = match rust_channel { Some(channel) if channel == "auto-detect" => { config.channel = ci_channel.into(); true @@ -903,7 +891,7 @@ impl Config { }; let default = config.channel == "dev"; - config.omit_git_hash = rust_omit_git_hash_toml.unwrap_or(default); + config.omit_git_hash = rust_omit_git_hash.unwrap_or(default); config.rust_info = config.git_info(config.omit_git_hash, &config.src); config.cargo_info = @@ -921,7 +909,7 @@ impl Config { config.in_tree_llvm_info = config.git_info(false, &config.src.join("src/llvm-project")); config.in_tree_gcc_info = config.git_info(false, &config.src.join("src/gcc")); - config.vendor = build_vendor_toml.unwrap_or( + config.vendor = build_vendor.unwrap_or( config.rust_info.is_from_tarball() && config.src.join("vendor").exists() && config.src.join(".cargo/config.toml").exists(), @@ -984,7 +972,7 @@ impl Config { target.jemalloc = cfg.jemalloc; if let Some(backends) = cfg.codegen_backends { target.codegen_backends = - Some(validate_codegen_backends(backends, &format!("target.{triple}"))) + Some(parse_codegen_backends(backends, &format!("target.{triple}"))) } target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| { @@ -1007,12 +995,12 @@ impl Config { // // This relies also on the fact that the global default for `download-rustc` will be // `false` if it's not explicitly set. - let debug_assertions_requested = matches!(rust_rustc_debug_assertions_toml, Some(true)) - || (matches!(rust_debug_toml, Some(true)) - && !matches!(rust_rustc_debug_assertions_toml, Some(false))); + let debug_assertions_requested = matches!(rust_rustc_debug_assertions, Some(true)) + || (matches!(rust_debug, Some(true)) + && !matches!(rust_rustc_debug_assertions, Some(false))); if debug_assertions_requested - && let Some(ref opt) = rust_download_rustc_toml + && let Some(ref opt) = rust_download_rustc && opt.is_string_or_true() { eprintln!( @@ -1023,12 +1011,12 @@ impl Config { } config.download_rustc_commit = config.download_ci_rustc_commit( - rust_download_rustc_toml, + rust_download_rustc, debug_assertions_requested, config.llvm_assertions, ); - if rust_optimize_toml.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { + if rust_optimize.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { eprintln!( "WARNING: setting `optimize` to `false` is known to cause errors and \ should be considered unsupported. Refer to `bootstrap.example.toml` \ @@ -1036,71 +1024,69 @@ impl Config { ); } - config.rust_new_symbol_mangling = rust_new_symbol_mangling_toml; - set(&mut config.rust_optimize_tests, rust_optimize_tests_toml); - set(&mut config.codegen_tests, rust_codegen_tests_toml); - set(&mut config.rust_rpath, rust_rpath_toml); - set(&mut config.rust_strip, rust_strip_toml); - set(&mut config.rust_frame_pointers, rust_frame_pointers_toml); - config.rust_stack_protector = rust_stack_protector_toml; - set(&mut config.jemalloc, rust_jemalloc_toml); - set(&mut config.test_compare_mode, rust_test_compare_mode_toml); - set(&mut config.backtrace, rust_backtrace_toml); - set(&mut config.rust_dist_src, rust_dist_src_toml); - set(&mut config.verbose_tests, rust_verbose_tests_toml); + config.rust_new_symbol_mangling = rust_new_symbol_mangling; + set(&mut config.rust_optimize_tests, rust_optimize_tests); + set(&mut config.codegen_tests, rust_codegen_tests); + set(&mut config.rust_rpath, rust_rpath); + set(&mut config.rust_strip, rust_strip); + set(&mut config.rust_frame_pointers, rust_frame_pointers); + config.rust_stack_protector = rust_stack_protector; + set(&mut config.jemalloc, rust_jemalloc); + set(&mut config.test_compare_mode, rust_test_compare_mode); + set(&mut config.backtrace, rust_backtrace); + set(&mut config.rust_dist_src, rust_dist_src); + set(&mut config.verbose_tests, rust_verbose_tests); // in the case "false" is set explicitly, do not overwrite the command line args - if let Some(true) = rust_incremental_toml { + if let Some(true) = rust_incremental { config.incremental = true; } - set(&mut config.lld_mode, rust_lld_mode_toml); - set(&mut config.llvm_bitcode_linker_enabled, rust_llvm_bitcode_linker_toml); + set(&mut config.lld_mode, rust_lld_mode); + set(&mut config.llvm_bitcode_linker_enabled, rust_llvm_bitcode_linker); - config.rust_randomize_layout = rust_randomize_layout_toml.unwrap_or_default(); - config.llvm_tools_enabled = rust_llvm_tools_toml.unwrap_or(true); + config.rust_randomize_layout = rust_randomize_layout.unwrap_or_default(); + config.llvm_tools_enabled = rust_llvm_tools.unwrap_or(true); config.llvm_enzyme = config.channel == "dev" || config.channel == "nightly"; - config.rustc_default_linker = rust_default_linker_toml; - config.musl_root = rust_musl_root_toml.map(PathBuf::from); - config.save_toolstates = rust_save_toolstates_toml.map(PathBuf::from); + config.rustc_default_linker = rust_default_linker; + config.musl_root = rust_musl_root.map(PathBuf::from); + config.save_toolstates = rust_save_toolstates.map(PathBuf::from); set( &mut config.deny_warnings, match flags_warnings { Warnings::Deny => Some(true), Warnings::Warn => Some(false), - Warnings::Default => rust_deny_warnings_toml, + Warnings::Default => rust_deny_warnings, }, ); - set(&mut config.backtrace_on_ice, rust_backtrace_on_ice_toml); - set(&mut config.rust_verify_llvm_ir, rust_verify_llvm_ir_toml); - config.rust_thin_lto_import_instr_limit = rust_thin_lto_import_instr_limit_toml; - set(&mut config.rust_remap_debuginfo, rust_remap_debuginfo_toml); - set(&mut config.control_flow_guard, rust_control_flow_guard_toml); - set(&mut config.ehcont_guard, rust_ehcont_guard_toml); - config.llvm_libunwind_default = rust_llvm_libunwind_toml - .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); + set(&mut config.backtrace_on_ice, rust_backtrace_on_ice); + set(&mut config.rust_verify_llvm_ir, rust_verify_llvm_ir); + config.rust_thin_lto_import_instr_limit = rust_thin_lto_import_instr_limit; + set(&mut config.rust_remap_debuginfo, rust_remap_debuginfo); + set(&mut config.control_flow_guard, rust_control_flow_guard); + set(&mut config.ehcont_guard, rust_ehcont_guard); + config.llvm_libunwind_default = + rust_llvm_libunwind.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); set( &mut config.rust_codegen_backends, - rust_codegen_backends_toml.map(|backends| validate_codegen_backends(backends, "rust")), + rust_codegen_backends.map(|backends| parse_codegen_backends(backends, "rust")), ); - config.rust_codegen_units = rust_codegen_units_toml.map(threads_from_config); - config.rust_codegen_units_std = rust_codegen_units_std_toml.map(threads_from_config); + config.rust_codegen_units = rust_codegen_units.map(threads_from_config); + config.rust_codegen_units_std = rust_codegen_units_std.map(threads_from_config); if config.rust_profile_use.is_none() { - config.rust_profile_use = rust_profile_use_toml; + config.rust_profile_use = rust_profile_use; } if config.rust_profile_generate.is_none() { - config.rust_profile_generate = rust_profile_generate_toml; + config.rust_profile_generate = rust_profile_generate; } - config.rust_lto = rust_lto_toml - .as_deref() - .map(|value| RustcLto::from_str(value).unwrap()) - .unwrap_or_default(); - config.rust_validate_mir_opts = rust_validate_mir_opts_toml; + config.rust_lto = + rust_lto.as_deref().map(|value| RustcLto::from_str(value).unwrap()).unwrap_or_default(); + config.rust_validate_mir_opts = rust_validate_mir_opts; - config.rust_optimize = rust_optimize_toml.unwrap_or(RustOptimize::Bool(true)); + config.rust_optimize = rust_optimize.unwrap_or(RustOptimize::Bool(true)); // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will // build our internal lld and use it as the default linker, by setting the `rust.lld` config @@ -1123,44 +1109,43 @@ impl Config { .is_none_or(|target_config| target_config.llvm_config.is_none()); let enable_lld = config.llvm_from_ci || no_llvm_config; // Prefer the config setting in case an explicit opt-out is needed. - config.lld_enabled = rust_lld_enabled_toml.unwrap_or(enable_lld); + config.lld_enabled = rust_lld_enabled.unwrap_or(enable_lld); } else { - set(&mut config.lld_enabled, rust_lld_enabled_toml); + set(&mut config.lld_enabled, rust_lld_enabled); } let default_std_features = BTreeSet::from([String::from("panic-unwind")]); - config.rust_std_features = rust_std_features_toml.unwrap_or(default_std_features); + config.rust_std_features = rust_std_features.unwrap_or(default_std_features); - let default = rust_debug_toml == Some(true); - config.rustc_debug_assertions = rust_rustc_debug_assertions_toml.unwrap_or(default); + let default = rust_debug == Some(true); + config.rustc_debug_assertions = rust_rustc_debug_assertions.unwrap_or(default); config.std_debug_assertions = - rust_std_debug_assertions_toml.unwrap_or(config.rustc_debug_assertions); + rust_std_debug_assertions.unwrap_or(config.rustc_debug_assertions); config.tools_debug_assertions = - rust_tools_debug_assertions_toml.unwrap_or(config.rustc_debug_assertions); - config.rust_overflow_checks = rust_overflow_checks_toml.unwrap_or(default); + rust_tools_debug_assertions.unwrap_or(config.rustc_debug_assertions); + config.rust_overflow_checks = rust_overflow_checks.unwrap_or(default); config.rust_overflow_checks_std = - rust_overflow_checks_std_toml.unwrap_or(config.rust_overflow_checks); + rust_overflow_checks_std.unwrap_or(config.rust_overflow_checks); - config.rust_debug_logging = - rust_debug_logging_toml.unwrap_or(config.rustc_debug_assertions); + config.rust_debug_logging = rust_debug_logging.unwrap_or(config.rustc_debug_assertions); let with_defaults = |debuginfo_level_specific: Option<_>| { - debuginfo_level_specific.or(rust_debuginfo_level_toml).unwrap_or( - if rust_debug_toml == Some(true) { + debuginfo_level_specific.or(rust_debuginfo_level).unwrap_or( + if rust_debug == Some(true) { DebuginfoLevel::Limited } else { DebuginfoLevel::None }, ) }; - config.rust_debuginfo_level_rustc = with_defaults(rust_debuginfo_level_rustc_toml); - config.rust_debuginfo_level_std = with_defaults(rust_debuginfo_level_std_toml); - config.rust_debuginfo_level_tools = with_defaults(rust_debuginfo_level_tools_toml); + config.rust_debuginfo_level_rustc = with_defaults(rust_debuginfo_level_rustc); + config.rust_debuginfo_level_std = with_defaults(rust_debuginfo_level_std); + config.rust_debuginfo_level_tools = with_defaults(rust_debuginfo_level_tools); config.rust_debuginfo_level_tests = - rust_debuginfo_level_tests_toml.unwrap_or(DebuginfoLevel::None); + rust_debuginfo_level_tests.unwrap_or(DebuginfoLevel::None); config.reproducible_artifacts = flags_reproducible_artifact; - config.description = build_description_toml; + config.description = build_description; // We need to override `rust.channel` if it's manually specified when using the CI rustc. // This is because if the compiler uses a different channel than the one specified in bootstrap.toml, @@ -1178,38 +1163,38 @@ impl Config { config.channel = channel; } - set(&mut config.ninja_in_file, llvm_ninja_toml); - set(&mut config.llvm_optimize, llvm_optimize_toml); - set(&mut config.llvm_thin_lto, llvm_thin_lto_toml); - set(&mut config.llvm_release_debuginfo, llvm_release_debuginfo_toml); - set(&mut config.llvm_static_stdcpp, llvm_static_libstdcpp_toml); - set(&mut config.llvm_libzstd, llvm_libzstd_toml); - if let Some(v) = llvm_link_shared_toml { + set(&mut config.ninja_in_file, llvm_ninja); + set(&mut config.llvm_optimize, llvm_optimize); + set(&mut config.llvm_thin_lto, llvm_thin_lto); + set(&mut config.llvm_release_debuginfo, llvm_release_debuginfo); + set(&mut config.llvm_static_stdcpp, llvm_static_libstdcpp); + set(&mut config.llvm_libzstd, llvm_libzstd); + if let Some(v) = llvm_link_shared { config.llvm_link_shared.set(Some(v)); } - config.llvm_targets.clone_from(&llvm_targets_toml); - config.llvm_experimental_targets.clone_from(&llvm_experimental_targets_toml); - config.llvm_link_jobs = llvm_link_jobs_toml; - config.llvm_version_suffix.clone_from(&llvm_version_suffix_toml); - config.llvm_clang_cl.clone_from(&llvm_clang_cl_toml); - config.llvm_tests = llvm_tests_toml.unwrap_or_default(); - config.llvm_enzyme = llvm_enzyme_toml.unwrap_or_default(); - config.llvm_plugins = llvm_plugin_toml.unwrap_or_default(); - - config.llvm_cflags.clone_from(&llvm_cflags_toml); - config.llvm_cxxflags.clone_from(&llvm_cxxflags_toml); - config.llvm_ldflags.clone_from(&llvm_ldflags_toml); - set(&mut config.llvm_use_libcxx, llvm_use_libcxx_toml); - config.llvm_use_linker.clone_from(&llvm_use_linker_toml); - config.llvm_allow_old_toolchain = llvm_allow_old_toolchain_toml.unwrap_or(false); - config.llvm_offload = llvm_offload_toml.unwrap_or(false); - config.llvm_polly = llvm_polly_toml.unwrap_or(false); - config.llvm_clang = llvm_clang_toml.unwrap_or(false); - config.llvm_enable_warnings = llvm_enable_warnings_toml.unwrap_or(false); - config.llvm_build_config = llvm_build_config_toml.clone().unwrap_or(Default::default()); + config.llvm_targets.clone_from(&llvm_targets); + config.llvm_experimental_targets.clone_from(&llvm_experimental_targets); + config.llvm_link_jobs = llvm_link_jobs; + config.llvm_version_suffix.clone_from(&llvm_version_suffix); + config.llvm_clang_cl.clone_from(&llvm_clang_cl); + config.llvm_tests = llvm_tests.unwrap_or_default(); + config.llvm_enzyme = llvm_enzyme.unwrap_or_default(); + config.llvm_plugins = llvm_plugin.unwrap_or_default(); + + config.llvm_cflags.clone_from(&llvm_cflags); + config.llvm_cxxflags.clone_from(&llvm_cxxflags); + config.llvm_ldflags.clone_from(&llvm_ldflags); + set(&mut config.llvm_use_libcxx, llvm_use_libcxx); + config.llvm_use_linker.clone_from(&llvm_use_linker); + config.llvm_allow_old_toolchain = llvm_allow_old_toolchain.unwrap_or(false); + config.llvm_offload = llvm_offload.unwrap_or(false); + config.llvm_polly = llvm_polly.unwrap_or(false); + config.llvm_clang = llvm_clang.unwrap_or(false); + config.llvm_enable_warnings = llvm_enable_warnings.unwrap_or(false); + config.llvm_build_config = llvm_build_config.clone().unwrap_or(Default::default()); config.llvm_from_ci = - config.parse_download_ci_llvm(llvm_download_ci_llvm_toml, config.llvm_assertions); + config.parse_download_ci_llvm(llvm_download_ci_llvm, config.llvm_assertions); if config.llvm_from_ci { let warn = |option: &str| { @@ -1221,11 +1206,11 @@ impl Config { ); }; - if llvm_static_libstdcpp_toml.is_some() { + if llvm_static_libstdcpp.is_some() { warn("static-libstdcpp"); } - if llvm_link_shared_toml.is_some() { + if llvm_link_shared.is_some() { warn("link-shared"); } @@ -1234,7 +1219,7 @@ impl Config { // config to the ones used to build the LLVM artifacts on CI, and only notify users // if they've chosen a different value. - if llvm_libzstd_toml.is_some() { + if llvm_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 \ @@ -1246,14 +1231,14 @@ impl Config { } } - if !config.llvm_from_ci && config.llvm_thin_lto && llvm_link_shared_toml.is_none() { + if !config.llvm_from_ci && config.llvm_thin_lto && llvm_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. config.llvm_link_shared.set(Some(true)); } - config.gcc_ci_mode = match gcc_download_ci_gcc_toml { + config.gcc_ci_mode = match gcc_download_ci_gcc { Some(value) => match value { true => GccCiMode::DownloadFromCi, false => GccCiMode::BuildLocally, @@ -1261,7 +1246,7 @@ impl Config { None => GccCiMode::default(), }; - match build_ccache_toml { + match build_ccache { Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()), Some(StringOrBool::Bool(true)) => { config.ccache = Some("ccache".to_string()); @@ -1285,18 +1270,18 @@ impl Config { Some(ci_llvm_bin.join(exe("FileCheck", config.host_target))); } - config.dist_sign_folder = dist_sign_folder_toml.map(PathBuf::from); - config.dist_upload_addr = dist_upload_addr_toml; - config.dist_compression_formats = dist_compression_formats_toml; - set(&mut config.dist_compression_profile, dist_compression_profile_toml); - set(&mut config.rust_dist_src, dist_src_tarball_toml); - set(&mut config.dist_include_mingw_linker, dist_include_mingw_linker_toml); - config.dist_vendor = dist_vendor_toml.unwrap_or_else(|| { + config.dist_sign_folder = dist_sign_folder.map(PathBuf::from); + config.dist_upload_addr = dist_upload_addr; + config.dist_compression_formats = dist_compression_formats; + set(&mut config.dist_compression_profile, dist_compression_profile); + set(&mut config.rust_dist_src, dist_src_tarball); + set(&mut config.dist_include_mingw_linker, dist_include_mingw_linker); + config.dist_vendor = dist_vendor.unwrap_or_else(|| { // If we're building from git or tarball sources, enable it by default. config.rust_info.is_managed_git_subrepository() || config.rust_info.is_from_tarball() }); - config.initial_rustfmt = if let Some(r) = build_rustfmt_toml { + config.initial_rustfmt = if let Some(r) = build_rustfmt { Some(r) } else { let dwn_ctx = DownloadContext::from(&config); @@ -1317,40 +1302,40 @@ impl Config { } config.optimized_compiler_builtins = - build_optimized_compiler_builtins_toml.unwrap_or(config.channel != "dev"); - config.compiletest_diff_tool = build_compiletest_diff_tool_toml; + build_optimized_compiler_builtins.unwrap_or(config.channel != "dev"); + config.compiletest_diff_tool = build_compiletest_diff_tool; config.compiletest_use_stage0_libtest = - build_compiletest_use_stage0_libtest_toml.unwrap_or(true); - config.tidy_extra_checks = build_tidy_extra_checks_toml; + build_compiletest_use_stage0_libtest.unwrap_or(true); + config.tidy_extra_checks = build_tidy_extra_checks; let download_rustc = config.download_rustc_commit.is_some(); config.explicit_stage_from_cli = flags_stage.is_some(); - config.explicit_stage_from_config = build_test_stage_toml.is_some() - || build_build_stage_toml.is_some() - || build_doc_stage_toml.is_some() - || build_dist_stage_toml.is_some() - || build_install_stage_toml.is_some() - || build_check_stage_toml.is_some() - || build_bench_stage_toml.is_some(); + config.explicit_stage_from_config = build_test_stage.is_some() + || build_build_stage.is_some() + || build_doc_stage.is_some() + || build_dist_stage.is_some() + || build_install_stage.is_some() + || build_check_stage.is_some() + || build_bench_stage.is_some(); config.stage = match config.cmd { - Subcommand::Check { .. } => flags_stage.or(build_check_stage_toml).unwrap_or(1), + Subcommand::Check { .. } => flags_stage.or(build_check_stage).unwrap_or(1), Subcommand::Clippy { .. } | Subcommand::Fix => { - flags_stage.or(build_check_stage_toml).unwrap_or(1) + flags_stage.or(build_check_stage).unwrap_or(1) } // `download-rustc` only has a speed-up for stage2 builds. Default to stage2 unless explicitly overridden. Subcommand::Doc { .. } => { - flags_stage.or(build_doc_stage_toml).unwrap_or(if download_rustc { 2 } else { 1 }) + flags_stage.or(build_doc_stage).unwrap_or(if download_rustc { 2 } else { 1 }) } Subcommand::Build => { - flags_stage.or(build_build_stage_toml).unwrap_or(if download_rustc { 2 } else { 1 }) + flags_stage.or(build_build_stage).unwrap_or(if download_rustc { 2 } else { 1 }) } Subcommand::Test { .. } | Subcommand::Miri { .. } => { - flags_stage.or(build_test_stage_toml).unwrap_or(if download_rustc { 2 } else { 1 }) + flags_stage.or(build_test_stage).unwrap_or(if download_rustc { 2 } else { 1 }) } - Subcommand::Bench { .. } => flags_stage.or(build_bench_stage_toml).unwrap_or(2), - Subcommand::Dist => flags_stage.or(build_dist_stage_toml).unwrap_or(2), - Subcommand::Install => flags_stage.or(build_install_stage_toml).unwrap_or(2), + Subcommand::Bench { .. } => flags_stage.or(build_bench_stage).unwrap_or(2), + Subcommand::Dist => flags_stage.or(build_dist_stage).unwrap_or(2), + Subcommand::Install => flags_stage.or(build_install_stage).unwrap_or(2), Subcommand::Perf { .. } => flags_stage.unwrap_or(1), // These are all bootstrap tools, which don't depend on the compiler. // The stage we pass shouldn't matter, but use 0 just in case. @@ -2254,7 +2239,7 @@ fn postprocess_toml( exit!(2); }); toml.merge( - Some(include_path.into()), + Some(include_path), &mut Default::default(), included_toml, ReplaceOpt::IgnoreDuplicate, diff --git a/src/bootstrap/src/core/config/toml/mod.rs b/src/bootstrap/src/core/config/toml/mod.rs index 01eb243159cea..7af22432ef8ca 100644 --- a/src/bootstrap/src/core/config/toml/mod.rs +++ b/src/bootstrap/src/core/config/toml/mod.rs @@ -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; diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index fd154200bc7a1..b95fb236fa16b 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer}; use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX; use crate::core::config::toml::TomlConfig; use crate::core::config::{DebuginfoLevel, Merge, ReplaceOpt, StringOrBool}; -use crate::{BTreeSet, HashSet, PathBuf, TargetSelection, define_config, exit}; +use crate::{BTreeSet, CodegenBackendKind, HashSet, PathBuf, TargetSelection, define_config, exit}; define_config! { /// TOML representation of how the Rust build is configured. diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 0c9d2bd0ab5f2..2c06fd083a810 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -7,15 +7,12 @@ //! * [`TomlTarget`]: This struct directly mirrors the `[target.]` sections in your //! `bootstrap.toml`. It's used for deserializing raw TOML data for a specific target. //! * [`Target`]: This struct represents the processed and validated configuration for a -//! build target, which is is stored in the main [`Config`] structure. -//! * [`Config::apply_target_config`]: This method processes the `TomlTarget` data and -//! applies it to the global [`Config`], ensuring proper path resolution, validation, -//! and integration with other build settings. +//! build target, which is is stored in the main `Config` structure. use serde::{Deserialize, Deserializer}; use crate::core::config::{LlvmLibunwind, Merge, ReplaceOpt, SplitDebuginfo, StringOrBool}; -use crate::{HashSet, PathBuf, define_config, exit}; +use crate::{CodegenBackendKind, HashSet, PathBuf, define_config, exit}; define_config! { /// TOML representation of how each build target is configured.