Skip to content

Commit 76c7224

Browse files
committed
move default config initialization at the end of the parse_inner method
1 parent 94534ca commit 76c7224

File tree

1 file changed

+16
-52
lines changed

1 file changed

+16
-52
lines changed

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

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -337,46 +337,8 @@ impl Config {
337337
span!(target: "CONFIG_HANDLING", tracing::Level::TRACE, "constructing default config");
338338

339339
Config {
340-
bypass_bootstrap_lock: false,
341-
llvm_optimize: true,
342-
ninja_in_file: true,
343-
llvm_static_stdcpp: false,
344-
llvm_libzstd: false,
345-
backtrace: true,
346-
rust_optimize: RustOptimize::Bool(true),
347-
rust_optimize_tests: true,
348-
rust_randomize_layout: false,
349-
submodules: None,
350-
docs: true,
351-
docs_minification: true,
352-
rust_rpath: true,
353-
rust_strip: false,
354-
channel: "dev".to_string(),
355-
codegen_tests: true,
356-
rust_dist_src: true,
357-
rust_codegen_backends: vec![CodegenBackendKind::Llvm],
358-
deny_warnings: true,
359-
bindir: "bin".into(),
360-
dist_include_mingw_linker: true,
361-
dist_compression_profile: "fast".into(),
362-
363340
stdout_is_tty: std::io::stdout().is_terminal(),
364341
stderr_is_tty: std::io::stderr().is_terminal(),
365-
366-
// set by build.rs
367-
host_target: get_host_target(),
368-
369-
src: {
370-
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
371-
// Undo `src/bootstrap`
372-
manifest_dir.parent().unwrap().parent().unwrap().to_owned()
373-
},
374-
out: PathBuf::from("build"),
375-
376-
// This is needed by codegen_ssa on macOS to ship `llvm-objcopy` aliased to
377-
// `rust-objcopy` to workaround bad `strip`s on macOS.
378-
llvm_tools_enabled: true,
379-
380342
..Default::default()
381343
}
382344
}
@@ -464,6 +426,7 @@ impl Config {
464426
);
465427

466428
let mut out = PathBuf::from("build");
429+
// set by build.rs
467430
let mut host_target = get_host_target();
468431
let initial_rustc;
469432
let initial_sysroot;
@@ -521,18 +484,16 @@ impl Config {
521484

522485
// First initialize the bare minimum that we need for further operation - source directory
523486
// and execution context.
524-
let mut config = Config::default_opts();
525-
let exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast());
487+
let mut exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast());
526488

527489
if let Some(src_) = compute_src_directory(flags_src, &exec_ctx) {
528490
src = src_;
529491
}
530492

531493
// Now load the TOML config, as soon as possible
532494
let (mut toml, toml_path) = load_toml_config(&src, flags_config, &get_toml);
533-
config.config = toml_path.clone();
534495

535-
postprocess_toml(&mut toml, &src, toml_path, &exec_ctx, &flags_set, &get_toml);
496+
postprocess_toml(&mut toml, &src, toml_path.clone(), &exec_ctx, &flags_set, &get_toml);
536497

537498
// Now override TOML values with flags, to make sure that we won't later override flags with
538499
// TOML values by accident instead, because flags have higher priority.
@@ -748,8 +709,7 @@ impl Config {
748709

749710
// Prefer CLI verbosity flags if set (`flags_verbose` > 0), otherwise take the value from
750711
// TOML.
751-
config
752-
.exec_ctx
712+
exec_ctx
753713
.set_verbosity(cmp::max(build_verbose_toml.unwrap_or_default() as u8, flags_verbose));
754714

755715
let mut paths: Vec<PathBuf> = flags_skip.into_iter().chain(flags_exclude).collect();
@@ -914,7 +874,7 @@ impl Config {
914874
command(&initial_rustc)
915875
.args(["--print", "sysroot"])
916876
.run_in_dry_run()
917-
.run_capture_stdout(&config)
877+
.run_capture_stdout(&exec_ctx)
918878
.stdout()
919879
.trim()
920880
));
@@ -1136,13 +1096,6 @@ impl Config {
11361096
_ => {}
11371097
}
11381098

1139-
if config.compile_time_deps && !matches!(cmd, Subcommand::Check { .. }) {
1140-
eprintln!(
1141-
"WARNING: Can't use --compile-time-deps with any subcommand other than check."
1142-
);
1143-
exit!(1);
1144-
}
1145-
11461099
// CI should always run stage 2 builds, unless it specifically states otherwise
11471100
#[cfg(not(test))]
11481101
if flags_stage.is_none() && is_running_on_ci {
@@ -1172,12 +1125,23 @@ impl Config {
11721125
}
11731126
}
11741127

1128+
let mut config = Config::default_opts();
1129+
config.config = toml_path.clone();
1130+
11751131
// Flag-based core settings
11761132
config.paths = flags_paths;
11771133
config.include_default_paths = flags_include_default_paths;
11781134
config.rustc_error_format = flags_rustc_error_format;
11791135
config.json_output = flags_json_output;
11801136
config.compile_time_deps = flags_compile_time_deps;
1137+
1138+
if config.compile_time_deps && !matches!(cmd, Subcommand::Check { .. }) {
1139+
eprintln!(
1140+
"WARNING: Can't use --compile-time-deps with any subcommand other than check."
1141+
);
1142+
exit!(1);
1143+
}
1144+
11811145
config.on_fail = flags_on_fail;
11821146
config.incremental = flags_incremental;
11831147
config.dump_bootstrap_shims = flags_dump_bootstrap_shims;

0 commit comments

Comments
 (0)