Skip to content

Commit 5ae81c9

Browse files
committed
remove unwanted references, and make more initialization inline
1 parent b91b310 commit 5ae81c9

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

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

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ impl Config {
623623
targets: llvm_targets,
624624
experimental_targets: llvm_experimental_targets,
625625
link_jobs: llvm_link_jobs,
626-
link_shared: llvm_link_shared_,
626+
link_shared: llvm_link_shared,
627627
version_suffix: llvm_version_suffix,
628628
clang_cl: llvm_clang_cl,
629629
cflags: llvm_cflags,
@@ -682,7 +682,6 @@ impl Config {
682682

683683
let mut target_config = HashMap::new();
684684
let mut download_rustc_commit = None;
685-
let llvm_link_shared = Cell::default();
686685
let mut llvm_from_ci = false;
687686
let mut channel = "dev".to_string();
688687
let mut out = flags_build_dir
@@ -764,7 +763,7 @@ impl Config {
764763
));
765764

766765
let initial_cargo = build_cargo.unwrap_or_else(|| {
767-
download_beta_toolchain(&mut dwn_ctx);
766+
download_beta_toolchain(&dwn_ctx);
768767
initial_sysroot.join("bin").join(exe("cargo", host_target))
769768
});
770769

@@ -848,11 +847,9 @@ impl Config {
848847
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
849848
);
850849

851-
let channel_ = read_file_by_commit(&dwn_ctx, Path::new("src/ci/channel"), commit)
850+
channel = read_file_by_commit(&dwn_ctx, Path::new("src/ci/channel"), commit)
852851
.trim()
853852
.to_owned();
854-
855-
channel = channel_;
856853
}
857854

858855
if let Some(t) = toml.target {
@@ -917,6 +914,9 @@ impl Config {
917914
dwn_ctx.target_config = target_config.clone();
918915
}
919916

917+
llvm_from_ci = parse_download_ci_llvm(&dwn_ctx, llvm_download_ci_llvm, llvm_assertions);
918+
dwn_ctx.llvm_from_ci = llvm_from_ci;
919+
920920
// We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will
921921
// build our internal lld and use it as the default linker, by setting the `rust.lld` config
922922
// to true by default:
@@ -939,13 +939,6 @@ impl Config {
939939
rust_lld_enabled.unwrap_or(false)
940940
};
941941

942-
if let Some(v) = llvm_link_shared_ {
943-
llvm_link_shared.set(Some(v));
944-
}
945-
946-
llvm_from_ci = parse_download_ci_llvm(&dwn_ctx, llvm_download_ci_llvm, llvm_assertions);
947-
dwn_ctx.llvm_from_ci = llvm_from_ci;
948-
949942
if llvm_from_ci {
950943
let warn = |option: &str| {
951944
println!(
@@ -960,7 +953,7 @@ impl Config {
960953
warn("static-libstdcpp");
961954
}
962955

963-
if llvm_link_shared_.is_some() {
956+
if llvm_link_shared.is_some() {
964957
warn("link-shared");
965958
}
966959

@@ -981,13 +974,6 @@ impl Config {
981974
}
982975
}
983976

984-
if !llvm_from_ci && llvm_thin_lto.unwrap_or(false) && llvm_link_shared_.is_none() {
985-
// If we're building with ThinLTO on, by default we want to link
986-
// to LLVM shared, to avoid re-doing ThinLTO (which happens in
987-
// the link step) with each stage.
988-
llvm_link_shared.set(Some(true));
989-
}
990-
991977
if llvm_from_ci {
992978
let triple = &host_target.triple;
993979
let ci_llvm_bin = ci_llvm_root(&dwn_ctx).join("bin");
@@ -1340,6 +1326,13 @@ impl Config {
13401326
patch_binaries_for_nix: build_patch_binaries_for_nix,
13411327
cmd: flags_cmd,
13421328
submodules: build_submodules,
1329+
// If we're building with ThinLTO on, by default we want to link
1330+
// to LLVM shared, to avoid re-doing ThinLTO (which happens in
1331+
// the link step) with each stage.
1332+
llvm_link_shared: Cell::new(
1333+
llvm_link_shared
1334+
.or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)),
1335+
),
13431336
exec_ctx,
13441337
out,
13451338
rust_info,
@@ -1361,7 +1354,6 @@ impl Config {
13611354
path_modification_cache,
13621355
stage0_metadata,
13631356
download_rustc_commit,
1364-
llvm_link_shared,
13651357
}
13661358
}
13671359

0 commit comments

Comments
 (0)