From b189f6e09faa34282dbf04e6bd567a25940640f7 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 3 Aug 2026 21:58:01 +1000 Subject: [PATCH 1/3] Move and rename bootstrap's `main.rs` This intermediate commit helps to preserve line history. --- src/bootstrap/Cargo.toml | 2 +- src/bootstrap/src/{bin/main.rs => cli_main.rs} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/bootstrap/src/{bin/main.rs => cli_main.rs} (100%) diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index bdbdbade90fa4..71b6e1fa5bba1 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -15,7 +15,7 @@ doctest = false [[bin]] name = "bootstrap" -path = "src/bin/main.rs" +path = "src/cli_main.rs" test = false [[bin]] diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/cli_main.rs similarity index 100% rename from src/bootstrap/src/bin/main.rs rename to src/bootstrap/src/cli_main.rs From d14e7c41d721364a7d9015e077e8fcd734a4f506 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 3 Aug 2026 21:59:23 +1000 Subject: [PATCH 2/3] Make bootstrap's `main.rs` a stub that calls into the library crate If there is non-trivial code in `main.rs`, then any items it touches need to be publicly exported from the library crate. Those public exports make it harder to identify unused code within bootstrap. --- src/bootstrap/Cargo.toml | 2 +- src/bootstrap/src/bin/main.rs | 8 ++++++++ src/bootstrap/src/cli_main.rs | 6 +++--- src/bootstrap/src/lib.rs | 3 +-- 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/bootstrap/src/bin/main.rs diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 71b6e1fa5bba1..bdbdbade90fa4 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -15,7 +15,7 @@ doctest = false [[bin]] name = "bootstrap" -path = "src/cli_main.rs" +path = "src/bin/main.rs" test = false [[bin]] diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs new file mode 100644 index 0000000000000..171ef1811ca40 --- /dev/null +++ b/src/bootstrap/src/bin/main.rs @@ -0,0 +1,8 @@ +//! The `main.rs` for bootstrap is a small stub that delegates to the real +//! entry point within the bootstrap library crate. +//! +//! Don't add more code here! Add it to the inner main instead. + +fn main() { + bootstrap::cli_main::main(); +} diff --git a/src/bootstrap/src/cli_main.rs b/src/bootstrap/src/cli_main.rs index 1310255de3ca4..879cf7159fb6b 100644 --- a/src/bootstrap/src/cli_main.rs +++ b/src/bootstrap/src/cli_main.rs @@ -13,7 +13,7 @@ use std::sync::Once; use std::time::Instant; use std::{env, process}; -use bootstrap::{ +use crate::{ Build, CONFIG_CHANGE_HISTORY, ChangeId, Config, Flags, StepStack, Subcommand, debug, find_recent_config_change_ids, human_readable_changes, t, }; @@ -22,9 +22,9 @@ fn is_tracing_enabled() -> bool { cfg!(feature = "tracing") } -fn main() { +pub fn main() { #[cfg(feature = "tracing")] - let guard = bootstrap::setup_tracing("BOOTSTRAP_TRACING"); + let guard = crate::utils::tracing::setup_tracing("BOOTSTRAP_TRACING"); let _start_time = Instant::now(); diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index a276f0378f450..7c0f2fc0f2937 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -39,6 +39,7 @@ use crate::core::config::{BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSel use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, split_debuginfo}; +pub mod cli_main; mod core; mod utils; @@ -54,8 +55,6 @@ pub use utils::change_tracker::{ CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes, }; pub use utils::helpers::{PanicTracker, symlink_dir}; -#[cfg(feature = "tracing")] -pub use utils::tracing::setup_tracing; use crate::core::build_steps::vendor::VENDOR_DIR; From 55050c13e58a93d104b22e25777686e568898339 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 10 Aug 2026 12:45:49 +1000 Subject: [PATCH 3/3] Tidy imports in `lib.rs` There is no need to re-export anything, so all `pub use` imports can be simplified to `use` and merged with their siblings. --- src/bootstrap/src/lib.rs | 42 ++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 7c0f2fc0f2937..f9b29a155eab1 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -28,35 +28,31 @@ use std::{env, fs, io, str}; use build_helper::ci::gha; use cc::Tool; use termcolor::{ColorChoice, StandardStream, WriteColor}; -use utils::build_stamp::BuildStamp; -use utils::channel::GitInfo; -use utils::exec::ExecutionContext; - -use crate::core::build_steps::format::InternalRustfmt; -use crate::core::builder; -use crate::core::builder::Kind; -use crate::core::config::{BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSelection, flags}; -use crate::utils::exec::{BootstrapCommand, command}; -use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, split_debuginfo}; - -pub mod cli_main; -mod core; -mod utils; - #[cfg(feature = "tracing")] -pub use core::builder::STEP_SPAN_TARGET; -pub use core::builder::{PathSet, StepStack}; -pub use core::config::flags::{Flags, Subcommand}; -pub use core::config::{ChangeId, Config}; +use tracing::{instrument, span}; +use crate::core::build_steps::format::InternalRustfmt; +use crate::core::build_steps::vendor::VENDOR_DIR; #[cfg(feature = "tracing")] -use tracing::{instrument, span}; -pub use utils::change_tracker::{ +use crate::core::builder::STEP_SPAN_TARGET; +use crate::core::builder::{self, Kind, StepStack}; +use crate::core::config::flags::{Flags, Subcommand}; +use crate::core::config::{ + BootstrapOverrideLld, ChangeId, Config, DryRun, LlvmLibunwind, TargetSelection, flags, +}; +use crate::utils::build_stamp::BuildStamp; +use crate::utils::change_tracker::{ CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes, }; -pub use utils::helpers::{PanicTracker, symlink_dir}; +use crate::utils::channel::GitInfo; +use crate::utils::exec::{BootstrapCommand, ExecutionContext, command}; +use crate::utils::helpers::{ + self, PanicTracker, dir_is_empty, exe, libdir, set_file_times, split_debuginfo, symlink_dir, +}; -use crate::core::build_steps::vendor::VENDOR_DIR; +pub mod cli_main; +mod core; +mod utils; const LLVM_TOOLS: &[&str] = &[ "llvm-cov", // used to generate coverage report