remove default config

This commit is contained in:
bit-aloo 2025-08-18 09:37:50 +05:30
parent 425a9c0a0e
commit 77c3d6edfa
No known key found for this signature in database
3 changed files with 561 additions and 580 deletions

File diff suppressed because it is too large Load diff

View file

@ -402,12 +402,6 @@ pub enum GccCiMode {
DownloadFromCi,
}
pub fn set<T>(field: &mut T, val: Option<T>) {
if let Some(v) = val {
*field = v;
}
}
pub fn threads_from_config(v: u32) -> u32 {
match v {
0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32,

View file

@ -403,13 +403,13 @@ impl Config {
pub(crate) struct DownloadContext<'a> {
pub path_modification_cache: Arc<Mutex<HashMap<Vec<&'static str>, PathFreshness>>>,
pub src: &'a Path,
pub rust_info: &'a channel::GitInfo,
pub rust_info: channel::GitInfo,
pub submodules: &'a Option<bool>,
pub download_rustc_commit: &'a Option<String>,
pub download_rustc_commit: Option<String>,
pub host_target: TargetSelection,
pub llvm_from_ci: bool,
pub target_config: &'a HashMap<TargetSelection, Target>,
pub out: &'a Path,
pub target_config: HashMap<TargetSelection, Target>,
pub out: PathBuf,
pub patch_binaries_for_nix: Option<bool>,
pub exec_ctx: &'a ExecutionContext,
pub stage0_metadata: &'a build_helper::stage0_parser::Stage0,
@ -418,6 +418,45 @@ pub(crate) struct DownloadContext<'a> {
pub is_running_on_ci: bool,
}
impl<'a> DownloadContext<'a> {
#[allow(clippy::too_many_arguments)]
pub fn new(
path_modification_cache: Arc<Mutex<HashMap<Vec<&'static str>, PathFreshness>>>,
src: &'a Path,
rust_info: channel::GitInfo,
submodules: &'a Option<bool>,
download_rustc_commit: Option<String>,
host_target: TargetSelection,
llvm_from_ci: bool,
target_config: HashMap<TargetSelection, Target>,
out: PathBuf,
patch_binaries_for_nix: Option<bool>,
exec_ctx: &'a ExecutionContext,
stage0_metadata: &'a build_helper::stage0_parser::Stage0,
llvm_assertions: bool,
bootstrap_cache_path: &'a Option<PathBuf>,
is_running_on_ci: bool,
) -> Self {
Self {
path_modification_cache,
src,
rust_info,
submodules,
download_rustc_commit,
host_target,
llvm_from_ci,
target_config,
out,
patch_binaries_for_nix,
exec_ctx,
stage0_metadata,
llvm_assertions,
bootstrap_cache_path,
is_running_on_ci,
}
}
}
impl<'a> AsRef<DownloadContext<'a>> for DownloadContext<'a> {
fn as_ref(&self) -> &DownloadContext<'a> {
self
@ -430,12 +469,12 @@ impl<'a> From<&'a Config> for DownloadContext<'a> {
path_modification_cache: value.path_modification_cache.clone(),
src: &value.src,
host_target: value.host_target,
rust_info: &value.rust_info,
download_rustc_commit: &value.download_rustc_commit,
rust_info: value.rust_info.clone(),
download_rustc_commit: value.download_rustc_commit.clone(),
submodules: &value.submodules,
llvm_from_ci: value.llvm_from_ci,
target_config: &value.target_config,
out: &value.out,
target_config: value.target_config.clone(),
out: value.out.clone(),
patch_binaries_for_nix: value.patch_binaries_for_nix,
exec_ctx: &value.exec_ctx,
stage0_metadata: &value.stage0_metadata,
@ -543,13 +582,13 @@ pub(crate) fn maybe_download_rustfmt<'a>(
);
if should_fix_bins_and_dylibs(dwn_ctx.patch_binaries_for_nix, dwn_ctx.exec_ctx) {
fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("rustfmt"), dwn_ctx.exec_ctx);
fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("cargo-fmt"), dwn_ctx.exec_ctx);
fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustfmt"), dwn_ctx.exec_ctx);
fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("cargo-fmt"), dwn_ctx.exec_ctx);
let lib_dir = bin_root.join("lib");
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
let lib = t!(lib);
if path_is_dylib(&lib.path()) {
fix_bin_or_dylib(dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx);
fix_bin_or_dylib(&dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx);
}
}
}
@ -615,10 +654,10 @@ fn download_toolchain<'a>(
}
if should_fix_bins_and_dylibs(dwn_ctx.patch_binaries_for_nix, dwn_ctx.exec_ctx) {
fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("rustc"), dwn_ctx.exec_ctx);
fix_bin_or_dylib(dwn_ctx.out, &bin_root.join("bin").join("rustdoc"), dwn_ctx.exec_ctx);
fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustc"), dwn_ctx.exec_ctx);
fix_bin_or_dylib(&dwn_ctx.out, &bin_root.join("bin").join("rustdoc"), dwn_ctx.exec_ctx);
fix_bin_or_dylib(
dwn_ctx.out,
&dwn_ctx.out,
&bin_root.join("libexec").join("rust-analyzer-proc-macro-srv"),
dwn_ctx.exec_ctx,
);
@ -626,7 +665,7 @@ fn download_toolchain<'a>(
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
let lib = t!(lib);
if path_is_dylib(&lib.path()) {
fix_bin_or_dylib(dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx);
fix_bin_or_dylib(&dwn_ctx.out, &lib.path(), dwn_ctx.exec_ctx);
}
}
}
@ -963,7 +1002,7 @@ fn download_file<'a>(
println!("download {url}");
});
// Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
let tempfile = tempdir(dwn_ctx.out).join(dest_path.file_name().unwrap());
let tempfile = tempdir(&dwn_ctx.out).join(dest_path.file_name().unwrap());
// While bootstrap itself only supports http and https downloads, downstream forks might
// need to download components from other protocols. The match allows them adding more
// protocols without worrying about merge conflicts if we change the HTTP implementation.