Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/bootstrap/src/cli_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ use std::sync::Once;
use std::time::Instant;
use std::{env, process};

use crate::{
Build, CONFIG_CHANGE_HISTORY, ChangeId, Config, Flags, StepStack, Subcommand, debug,
find_recent_config_change_ids, human_readable_changes, t,
use crate::core::builder::StepStack;
use crate::core::config::flags::Flags;
use crate::core::config::{ChangeId, Config, Subcommand};
use crate::utils::change_tracker::{
CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes,
};
use crate::utils::helpers::t;
use crate::{Build, debug};

fn is_tracing_enabled() -> bool {
cfg!(feature = "tracing")
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use crate::core::builder::{
self, Alias, Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata,
crate_description,
};
use crate::core::config::TargetSelection;
use crate::core::config::{Subcommand, TargetSelection};
use crate::utils::build_stamp::{self, BuildStamp};
use crate::{CodegenBackendKind, Compiler, Mode, Subcommand, t};
use crate::utils::helpers::t;
use crate::{CodegenBackendKind, Compiler, Mode};

/// Allows individual check-step instances to keep track of whether they
/// represent `cargo check` or `cargo fix`, independently of [`Builder::kind`].
Expand Down
7 changes: 5 additions & 2 deletions src/bootstrap/src/core/build_steps/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ use std::fs;
use std::io::{self, ErrorKind};
use std::path::Path;

use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun, crate_description};
use crate::core::builder::{
Builder, CommandLineStep, Kind, RunConfig, ShouldRun, crate_description,
};
use crate::core::config::Subcommand;
use crate::utils::build_stamp::BuildStamp;
use crate::utils::helpers::t;
use crate::{Build, Compiler, Kind, Mode, Subcommand};
use crate::{Build, Compiler, Mode};

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CleanAll {}
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/build_steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
//! (as usual) a massive undertaking/refactoring.

use super::tool::{SourceType, prepare_tool_cargo};
use crate::builder::{Builder, ShouldRun};
use crate::core::build_steps::check::{CompilerForCheck, prepare_compiler_for_check};
use crate::core::build_steps::compile::{
ArtifactKeepMode, run_cargo, rustc_cargo, std_cargo, std_crates_for_make_run,
};
use crate::core::builder;
use crate::core::builder::{
Alias, CommandLineStep, Kind, RunConfig, StepMetadata, crate_description,
Alias, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, StepMetadata, crate_description,
};
use crate::core::config::{Subcommand, TargetSelection};
use crate::utils::build_stamp::{self, BuildStamp};
use crate::{Compiler, Mode, Subcommand, TargetSelection, exit};
use crate::{Compiler, Mode, exit};

/// Disable the most spammy clippy lints
const IGNORED_RULES_FOR_STD_AND_RUSTC: &[&str] = &[
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::core::builder::{
crate_description,
};
use crate::core::config::{Config, TargetSelection};
use crate::helpers::{submodule_path_of, symlink_dir, t, up_to_date};
use crate::utils::helpers::{submodule_path_of, symlink_dir, t, up_to_date};
use crate::{FileType, Mode};

macro_rules! book {
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/build_steps/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::sync::OnceLock;
use build_helper::git::PathFreshness;

use crate::core::builder::{Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun};
use crate::core::config::TargetSelection;
use crate::core::config::{Config, TargetSelection};
use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash};
use crate::utils::exec::command;
use crate::utils::helpers::{self, t};
Expand Down Expand Up @@ -366,12 +366,12 @@ pub fn add_cg_gcc_cargo_flags(cargo: &mut Cargo, gcc: &GccOutput) {
}

/// The absolute path to the downloaded GCC artifacts.
fn ci_gcc_root(config: &crate::Config, target: TargetSelection) -> PathBuf {
fn ci_gcc_root(config: &Config, target: TargetSelection) -> PathBuf {
config.out.join(target).join("ci-gcc")
}

/// Detect whether GCC sources have been modified locally or not.
fn detect_gcc_freshness(config: &crate::Config, is_git: bool) -> build_helper::git::PathFreshness {
fn detect_gcc_freshness(config: &Config, is_git: bool) -> build_helper::git::PathFreshness {
assert!(cfg!(not(test)), "unit tests shouldn't care about GCC freshness");

if is_git {
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use std::path::{Component, Path, PathBuf};
use std::{env, fs};

use crate::Compiler;
use crate::core::build_steps::dist;
use crate::core::build_steps::tool::RustcPrivateCompilers;
use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun};
use crate::core::builder::{Builder, CommandLineStep, Kind, RunConfig, ShouldRun};
use crate::core::config::{Config, TargetSelection};
use crate::utils::exec::command;
use crate::utils::helpers::t;
use crate::utils::tarball::GeneratedTarball;
use crate::{Compiler, Kind};

#[cfg(target_os = "illumos")]
const SHELL: &str = "bash";
Expand Down
6 changes: 4 additions & 2 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ use std::{env, fs};
use build_helper::git::PathFreshness;

use crate::core::build_steps::llvm;
use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun, Step, StepMetadata};
use crate::core::builder::{
Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata,
};
use crate::core::config::{Config, LlvmPgoGenerationMode, TargetSelection};
use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash};
use crate::utils::exec::command;
use crate::utils::helpers::{
self, exe, get_clang_cl_resource_dir, libdir, t, unhashed_basename, up_to_date,
};
use crate::{CLang, GitRepo, Kind, exit, trace};
use crate::{CLang, GitRepo, exit, trace};

/// Result of building or downloading LLVM artifacts.
#[derive(Clone)]
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/build_steps/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use crate::core::builder::{Builder, CommandLineStep, Kind, RunConfig, ShouldRun,
use crate::core::config::TargetSelection;
use crate::core::config::flags::{get_completion, top_level_help};
use crate::utils::exec::command;
use crate::{Mode, exit, t};
use crate::utils::helpers::t;
use crate::{Mode, exit};

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct BuildManifest;
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use sha2::Digest;

use crate::core::build_steps::format;
use crate::core::builder::{Builder, CommandLineStep, RunConfig, ShouldRun};
use crate::core::config::Config;
use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY;
use crate::utils::exec::command;
use crate::utils::helpers::{self, hex_encode};
use crate::{Config, t};
use crate::utils::helpers::{self, hex_encode, t};

#[cfg(test)]
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/test/failed_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::{BufRead, BufReader, ErrorKind};
use std::path::{Path, PathBuf};

use crate::core::builder::{Builder, Step};
use crate::t;
use crate::utils::helpers::t;

#[derive(Clone)]
pub struct RecordFailedTests {
Expand Down
7 changes: 3 additions & 4 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ use std::{env, fs};
use crate::core::build_steps::compile::is_lto_stage;
use crate::core::build_steps::toolstate::ToolState;
use crate::core::build_steps::{compile, llvm};
use crate::core::builder;
use crate::core::builder::{
Builder, Cargo as CargoCommand, CommandLineStep, RunConfig, ShouldRun, Step, StepMetadata,
apply_pgo, cargo_profile_var,
self, Builder, Cargo as CargoCommand, CommandLineStep, Kind, RunConfig, ShouldRun, Step,
StepMetadata, apply_pgo, cargo_profile_var,
};
use crate::core::config::{Allocator, DebuginfoLevel, RustcLto, TargetSelection};
use crate::utils::exec::{BootstrapCommand, command};
use crate::utils::helpers::{add_dylib_path, exe, t};
use crate::{Compiler, FileType, Kind, Mode};
use crate::{Compiler, FileType, Mode};

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum SourceType {
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::core::build_steps::test;
use crate::core::build_steps::tool::SourceType;
use crate::core::config::flags::Color;
use crate::core::config::toml::pgo::PgoConfig;
use crate::core::config::{CompressDebuginfo, SplitDebuginfo};
use crate::core::config::{CompressDebuginfo, Config, DryRun, SplitDebuginfo, TargetSelection};
use crate::utils::build_stamp;
use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_flags};
use crate::utils::exec::{BootstrapCommand, command};
use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_flags, t};
use crate::{
BootstrapCommand, CLang, Compiler, Config, DryRun, EXTRA_CHECK_CFGS, GitRepo, Mode,
RemapScheme, TargetSelection, command, prepare_behaviour_dump_dir, t,
CLang, Compiler, EXTRA_CHECK_CFGS, GitRepo, Mode, RemapScheme, prepare_behaviour_dump_dir,
};

/// Represents flag values in `String` form with a `\x1f` delimiter to pass to the compiler later.
Expand Down
13 changes: 6 additions & 7 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
//! and the `bootstrap.toml` file—merging them, applying defaults, and performing
//! cross-component validation. The main `parse_inner` function and its supporting
//! helpers reside here, transforming raw `Toml` data into the structured `Config` type.

use std::cell::Cell;
use std::collections::{BTreeSet, HashMap, HashSet};
use std::io::IsTerminal;
use std::path::{Path, PathBuf, absolute};
use std::str::FromStr;
use std::sync::{Arc, Mutex};
use std::sync::{Arc, Mutex, OnceLock};
use std::{cmp, env, fs};

use build_helper::ci::CiEnv;
Expand Down Expand Up @@ -51,15 +52,13 @@ use crate::core::config::toml::target::{
use crate::core::config::{
Allocator, CompilerBuiltins, CompressDebuginfo, DebuggerPath, DebuginfoLevel, DryRun,
GccCiMode, LlvmLibunwind, Merge, ReplaceOpt, RustcLto, SplitDebuginfo, StringOrBool,
threads_from_config,
TargetSelection, threads_from_config,
};
use crate::core::download::{DownloadContext, download_beta_toolchain, is_download_ci_available};
use crate::utils::channel;
use crate::utils::channel::{self, GitInfo};
use crate::utils::exec::{ExecutionContext, command};
use crate::utils::helpers::{exe, fail, get_host_target};
use crate::{
CodegenBackendKind, GitInfo, OnceLock, TargetSelection, check_ci_llvm, exit, helpers, t,
};
use crate::utils::helpers::{self, exe, fail, get_host_target, t};
use crate::{CodegenBackendKind, check_ci_llvm, exit};

/// Each path in this list is considered "allowed" in the `download-rustc="if-unchanged"` logic.
/// This means they can be modified and changes to these paths should never trigger a compiler build
Expand Down
11 changes: 6 additions & 5 deletions src/bootstrap/src/core/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ mod tests;
pub mod toml;

use std::collections::HashSet;
use std::fmt::Display;
use std::path::PathBuf;
use std::str::FromStr;

pub use config::*;
use serde::de::Unexpected;
Expand All @@ -40,8 +42,7 @@ pub use toml::change_id::ChangeId;
pub use toml::rust::BootstrapOverrideLld;
pub use toml::target::Target;

use crate::str::FromStr;
use crate::{Display, exit};
use crate::exit;

// We are using a decl macro instead of a derive proc macro here to reduce the compile time of bootstrap.
#[macro_export]
Expand All @@ -63,8 +64,8 @@ macro_rules! define_config {
impl Merge for $name {
fn merge(
&mut self,
_parent_config_path: Option<PathBuf>,
_included_extensions: &mut HashSet<PathBuf>,
_parent_config_path: Option<std::path::PathBuf>,
_included_extensions: &mut std::collections::HashSet<std::path::PathBuf>,
other: Self,
replace: ReplaceOpt
) {
Expand All @@ -87,7 +88,7 @@ macro_rules! define_config {
panic!("overriding existing option")
} else {
eprintln!("overriding existing option: `{}`", stringify!($field));
exit!(2);
$crate::exit!(2);
}
} else {
self.$field = other.$field;
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/config/target_selection.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::fmt;
use std::path::Path;
use std::{env, fmt};

use crate::core::config::SplitDebuginfo;
use crate::utils::cache::{INTERNER, Interned};
use crate::{Path, env};

#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
// N.B.: This type is used everywhere, and the entire codebase relies on it being Copy.
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use super::flags::Flags;
use super::toml::change_id::ChangeIdWrapper;
use super::toml::rust::parse_codegen_backends;
use super::{Config, DebuggerPath, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
use crate::ChangeId;
use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
use crate::core::config::{BootstrapOverrideLld, CompilerBuiltins, Target, TargetSelection};
use crate::core::config::{
BootstrapOverrideLld, ChangeId, CompilerBuiltins, Target, TargetSelection,
};
use crate::utils::tests::TestCtx;
use crate::utils::tests::git::git_test;

Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/src/core/config/toml/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
//! various feature flags. These options apply across different stages and components
//! unless specifically overridden by other configuration sections or command-line flags.

use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;

use serde::{Deserialize, Deserializer};

use crate::core::config::toml::ReplaceOpt;
use crate::core::config::{Allocator, CompilerBuiltins, DebuggerPath, Merge, StringOrBool};
use crate::{HashSet, PathBuf, define_config, exit};
use crate::define_config;

define_config! {
/// TOML representation of various global build decisions.
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/config/toml/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Deserializer};

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

define_config! {
#[derive(Default)]
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/src/core/config/toml/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
//! The `[gcc]` table contains options specifically related to building or
//! acquiring the GCC compiler for use within the Rust build process.

use std::path::PathBuf;

use serde::{Deserialize, Deserializer};

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

define_config! {
/// TOML representation of how the GCC build is configured.
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/config/toml/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Deserializer};

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

define_config! {
/// TOML representation of various global install decisions.
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/src/core/config/toml/llvm.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//! This module defines the `Llvm` struct, which represents the `[llvm]` table
//! in the `bootstrap.toml` configuration file.

use std::collections::HashMap;

use serde::{Deserialize, Deserializer};

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

define_config! {
/// TOML representation of how the LLVM build is configured.
Expand Down
Loading
Loading