Skip to content

Commit a53f060

Browse files
committed
more streamlining
1 parent 595ecf7 commit a53f060

File tree

1 file changed

+62
-80
lines changed

1 file changed

+62
-80
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 62 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,12 @@ impl Config {
478478

479479
// Now load the TOML config, as soon as possible
480480
let (mut toml, toml_path) = load_toml_config(&src, flags_config, &get_toml);
481-
let config = toml_path.clone();
482481

483482
let compile_time_deps = flags_compile_time_deps;
484483
let cmd = flags_cmd;
485484
let is_running_on_ci = flags_ci.unwrap_or(CiEnv::is_ci());
486485

487-
postprocess_toml(&mut toml, &src, toml_path, &exec_ctx, &flags_set, &get_toml);
486+
postprocess_toml(&mut toml, &src, toml_path.clone(), &exec_ctx, &flags_set, &get_toml);
488487

489488
// Now override TOML values with flags, to make sure that we won't later override flags with
490489
// TOML values by accident instead, because flags have higher priority.
@@ -660,13 +659,8 @@ impl Config {
660659
exec_ctx.set_verbosity(cmp::max(build_verbose.unwrap_or_default() as u8, flags_verbose));
661660

662661
let stage0_metadata = build_helper::stage0_parser::parse_stage0_file();
663-
let llvm_thin_lto = llvm_thin_lto_.unwrap_or(false);
664-
let lld_mode = rust_lld_mode.unwrap_or_default();
665662
let bootstrap_cache_path = build_bootstrap_cache_path;
666663
let patch_binaries_for_nix = build_patch_binaries_for_nix;
667-
let rustc_debug_assertions =
668-
rust_rustc_debug_assertions.unwrap_or(rust_debug == Some(true));
669-
let rust_overflow_checks = rust_overflow_checks_.unwrap_or(rust_debug == Some(true));
670664

671665
let path_modification_cache = Arc::new(Mutex::new(HashMap::new()));
672666

@@ -688,12 +682,6 @@ impl Config {
688682
build_host.map(|h| h.iter().map(|t| TargetSelection::from_user(t)).collect())
689683
})
690684
.unwrap_or_else(|| vec![host_target]);
691-
let targets = flags_target
692-
.map(|TargetSelectionList(targets)| targets)
693-
.or_else(|| {
694-
build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect())
695-
})
696-
.unwrap_or_else(|| hosts.clone());
697685

698686
let submodules = build_submodules;
699687
let llvm_assertions = llvm_assertions_.unwrap_or(false);
@@ -744,32 +732,6 @@ impl Config {
744732
}
745733
}
746734

747-
let mut paths_: Vec<PathBuf> = flags_skip.into_iter().chain(flags_exclude).collect();
748-
if let Some(exclude) = build_exclude {
749-
paths_.extend(exclude);
750-
}
751-
752-
let skip = paths_
753-
.into_iter()
754-
.map(|p| {
755-
// Never return top-level path here as it would break `--skip`
756-
// logic on rustc's internal test framework which is utilized
757-
// by compiletest.
758-
if cfg!(windows) {
759-
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
760-
} else {
761-
p
762-
}
763-
})
764-
.collect();
765-
#[cfg(feature = "tracing")]
766-
span!(
767-
target: "CONFIG_HANDLING",
768-
tracing::Level::TRACE,
769-
"normalizing and combining `flag.skip`/`flag.exclude` paths",
770-
"config.skip" = ?skip,
771-
);
772-
773735
if build_cargo_clippy.is_some() && build_rustc.is_none() {
774736
println!(
775737
"WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict."
@@ -860,15 +822,6 @@ impl Config {
860822
let omit_git_hash = rust_omit_git_hash.unwrap_or(channel == "dev");
861823

862824
rust_info = git_info(&exec_ctx, omit_git_hash, &src);
863-
let cargo_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/cargo"));
864-
let rust_analyzer_info =
865-
git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/rust-analyzer"));
866-
let clippy_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/clippy"));
867-
let miri_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/miri"));
868-
let rustfmt_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/rustfmt"));
869-
let enzyme_info = git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/enzyme"));
870-
let in_tree_llvm_info = git_info(&exec_ctx, false, &src.join("src/llvm-project"));
871-
let in_tree_gcc_info = git_info(&exec_ctx, false, &src.join("src/gcc"));
872825

873826
let vendor = build_vendor.unwrap_or(
874827
rust_info.is_from_tarball()
@@ -1111,7 +1064,7 @@ impl Config {
11111064
}
11121065
}
11131066

1114-
if !llvm_from_ci && llvm_thin_lto && llvm_link_shared_.is_none() {
1067+
if !llvm_from_ci && llvm_thin_lto_.unwrap_or(false) && llvm_link_shared_.is_none() {
11151068
// If we're building with ThinLTO on, by default we want to link
11161069
// to LLVM shared, to avoid re-doing ThinLTO (which happens in
11171070
// the link step) with each stage.
@@ -1147,11 +1100,6 @@ impl Config {
11471100
build_target.llvm_filecheck = Some(ci_llvm_bin.join(exe("FileCheck", host_target)));
11481101
}
11491102

1150-
let dist_vendor = dist_vendor_.unwrap_or_else(|| {
1151-
// If we're building from git or tarball sources, enable it by default.
1152-
rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball()
1153-
});
1154-
11551103
let initial_rustfmt = if let Some(r) = build_rustfmt {
11561104
Some(r)
11571105
} else {
@@ -1175,7 +1123,7 @@ impl Config {
11751123
maybe_download_rustfmt(dwn_ctx)
11761124
};
11771125

1178-
if matches!(lld_mode, LldMode::SelfContained)
1126+
if matches!(rust_lld_mode.unwrap_or_default(), LldMode::SelfContained)
11791127
&& !lld_enabled
11801128
&& flags_stage.unwrap_or(0) > 0
11811129
{
@@ -1205,9 +1153,6 @@ impl Config {
12051153
panic!("Cannot enable LLD with `rust.lld = true` when using external llvm-config.");
12061154
}
12071155

1208-
let optimized_compiler_builtins =
1209-
build_optimized_compiler_builtins.unwrap_or(channel != "dev");
1210-
12111156
let download_rustc = download_rustc_commit.is_some();
12121157

12131158
let stage = match cmd {
@@ -1328,7 +1273,8 @@ impl Config {
13281273
test_compare_mode: rust_test_compare_mode.unwrap_or(false),
13291274
color: flags_color,
13301275
android_ndk: build_android_ndk,
1331-
optimized_compiler_builtins,
1276+
optimized_compiler_builtins: build_optimized_compiler_builtins
1277+
.unwrap_or(channel != "dev"),
13321278
stdout_is_tty: std::io::stdout().is_terminal(),
13331279
stderr_is_tty: std::io::stderr().is_terminal(),
13341280
on_fail: flags_on_fail,
@@ -1388,10 +1334,19 @@ impl Config {
13881334
rust_optimize: rust_optimize_.unwrap_or(RustOptimize::Bool(true)),
13891335
rust_codegen_units: rust_codegen_units_.map(threads_from_config),
13901336
rust_codegen_units_std: rust_codegen_units_std_.map(threads_from_config),
1391-
std_debug_assertions: rust_std_debug_assertions.unwrap_or(rustc_debug_assertions),
1392-
tools_debug_assertions: rust_tools_debug_assertions.unwrap_or(rustc_debug_assertions),
1393-
rust_overflow_checks_std: rust_overflow_checks_std_.unwrap_or(rust_overflow_checks),
1394-
rust_debug_logging: rust_debug_logging_.unwrap_or(rustc_debug_assertions),
1337+
std_debug_assertions: rust_std_debug_assertions
1338+
.or(rust_rustc_debug_assertions)
1339+
.unwrap_or(rust_debug == Some(true)),
1340+
tools_debug_assertions: rust_tools_debug_assertions
1341+
.or(rust_rustc_debug_assertions)
1342+
.unwrap_or(rust_debug == Some(true)),
1343+
rust_overflow_checks_std: rust_overflow_checks_std_
1344+
.or(rust_overflow_checks_)
1345+
.unwrap_or(rust_debug == Some(true)),
1346+
rust_overflow_checks: rust_overflow_checks_.unwrap_or(rust_debug == Some(true)),
1347+
rust_debug_logging: rust_debug_logging_
1348+
.or(rust_rustc_debug_assertions)
1349+
.unwrap_or(rust_debug == Some(true)),
13951350
rust_debuginfo_level_rustc: with_defaults(rust_debuginfo_level_rustc_),
13961351
rust_debuginfo_level_std: with_defaults(rust_debuginfo_level_std_),
13971352
rust_debuginfo_level_tools: with_defaults(rust_debuginfo_level_tools_),
@@ -1464,50 +1419,77 @@ impl Config {
14641419
compiletest_use_stage0_libtest: build_compiletest_use_stage0_libtest.unwrap_or(true),
14651420
tidy_extra_checks: build_tidy_extra_checks,
14661421
skip_std_check_if_no_download_rustc: flags_skip_std_check_if_no_download_rustc,
1422+
cargo_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/cargo")),
1423+
rust_analyzer_info: git_info(
1424+
&exec_ctx,
1425+
omit_git_hash,
1426+
&src.join("src/tools/rust-analyzer"),
1427+
),
1428+
clippy_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/clippy")),
1429+
miri_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/miri")),
1430+
rustfmt_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/rustfmt")),
1431+
enzyme_info: git_info(&exec_ctx, omit_git_hash, &src.join("src/tools/enzyme")),
1432+
in_tree_llvm_info: git_info(&exec_ctx, false, &src.join("src/llvm-project")),
1433+
in_tree_gcc_info: git_info(&exec_ctx, false, &src.join("src/gcc")),
1434+
dist_vendor: dist_vendor_.unwrap_or_else(|| {
1435+
// If we're building from git or tarball sources, enable it by default.
1436+
rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball()
1437+
}),
1438+
targets: flags_target
1439+
.map(|TargetSelectionList(targets)| targets)
1440+
.or_else(|| {
1441+
build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect())
1442+
})
1443+
.unwrap_or_else(|| hosts.clone()),
1444+
skip: flags_skip
1445+
.into_iter()
1446+
.chain(flags_exclude)
1447+
.chain(build_exclude.unwrap_or_default())
1448+
.map(|p| {
1449+
// Never return top-level path here as it would break `--skip`
1450+
// logic on rustc's internal test framework which is utilized by compiletest.
1451+
#[cfg(windows)]
1452+
{
1453+
PathBuf::from(p.to_string_lossy().replace('/', "\\"))
1454+
}
1455+
#[cfg(not(windows))]
1456+
{
1457+
p
1458+
}
1459+
})
1460+
.collect(),
1461+
paths: flags_paths,
1462+
config: toml_path,
1463+
llvm_thin_lto: llvm_thin_lto_.unwrap_or(false),
1464+
rustc_debug_assertions: rust_rustc_debug_assertions.unwrap_or(rust_debug == Some(true)),
1465+
lld_mode: rust_lld_mode.unwrap_or_default(),
14671466
exec_ctx,
14681467
out,
14691468
rust_info,
1470-
cargo_info,
1471-
rust_analyzer_info,
1472-
clippy_info,
1473-
miri_info,
1474-
rustfmt_info,
1475-
enzyme_info,
1476-
in_tree_llvm_info,
1477-
in_tree_gcc_info,
14781469
initial_cargo,
14791470
initial_rustc,
14801471
initial_cargo_clippy,
14811472
initial_sysroot,
14821473
initial_rustfmt,
14831474
submodules,
1484-
paths: flags_paths,
14851475
vendor,
14861476
target_config,
14871477
omit_git_hash,
1488-
skip,
14891478
stage,
14901479
src,
1491-
config,
14921480
cmd,
14931481
llvm_from_ci,
14941482
llvm_assertions,
1495-
lld_mode,
14961483
lld_enabled,
1497-
rust_overflow_checks,
14981484
host_target,
14991485
hosts,
1500-
targets,
1501-
dist_vendor,
15021486
channel,
15031487
is_running_on_ci,
15041488
path_modification_cache,
15051489
patch_binaries_for_nix,
15061490
stage0_metadata,
15071491
download_rustc_commit,
1508-
llvm_thin_lto,
15091492
llvm_link_shared,
1510-
rustc_debug_assertions,
15111493
}
15121494
}
15131495

0 commit comments

Comments
 (0)