Skip to content

Commit 2523b0c

Browse files
committed
bootstrap: enable lld x86_64-unknown-linux-gnu when necessary
that is: - when we build our own llvm - when we use download-ci-llvm - otherwise, when using an external llvm we can't enable it
1 parent bba318e commit 2523b0c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/bootstrap/config.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,7 @@ impl Config {
13661366
let mut debuginfo_level_tests = None;
13671367
let mut optimize = None;
13681368
let mut omit_git_hash = None;
1369+
let mut lld_enabled = None;
13691370

13701371
if let Some(rust) = toml.rust {
13711372
set(&mut config.channel, rust.channel);
@@ -1398,6 +1399,7 @@ impl Config {
13981399
debuginfo_level_std = rust.debuginfo_level_std;
13991400
debuginfo_level_tools = rust.debuginfo_level_tools;
14001401
debuginfo_level_tests = rust.debuginfo_level_tests;
1402+
lld_enabled = rust.lld;
14011403

14021404
config.rust_split_debuginfo = rust
14031405
.split_debuginfo
@@ -1422,7 +1424,6 @@ impl Config {
14221424
config.incremental = true;
14231425
}
14241426
set(&mut config.use_lld, rust.use_lld);
1425-
set(&mut config.lld_enabled, rust.lld);
14261427
set(&mut config.llvm_tools_enabled, rust.llvm_tools);
14271428
config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
14281429
config.rustc_default_linker = rust.default_linker;
@@ -1663,6 +1664,22 @@ impl Config {
16631664
config.llvm_plugins = llvm_plugins.unwrap_or(false);
16641665
config.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true));
16651666

1667+
// `x86_64-unknown-linux-gnu` has self-contained linking enabled, and enables building our
1668+
// internal lld by default:
1669+
// - when building our in-tree llvm (the target has not set an `llvm-config`), we're able to
1670+
// build rust-lld as well
1671+
// - when using an external llvm that's downloaded from CI, rust-lld is also packaged there
1672+
// - otherwise, we're using an external llvm and lld is not available and thus, disabled
1673+
if config.build.triple == "x86_64-unknown-linux-gnu" && config.hosts == &[config.build] {
1674+
let no_llvm_config = config
1675+
.target_config
1676+
.get(&config.build)
1677+
.is_some_and(|target_config| target_config.llvm_config.is_none());
1678+
let enable_lld = config.llvm_from_ci || no_llvm_config;
1679+
// Prefer the config setting in case an explicit opt-out is needed.
1680+
config.lld_enabled = lld_enabled.unwrap_or(enable_lld);
1681+
}
1682+
16661683
let default = debug == Some(true);
16671684
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
16681685
config.rust_debug_assertions_std =

0 commit comments

Comments
 (0)