@@ -1366,6 +1366,7 @@ impl Config {
1366
1366
let mut debuginfo_level_tests = None ;
1367
1367
let mut optimize = None ;
1368
1368
let mut omit_git_hash = None ;
1369
+ let mut lld_enabled = None ;
1369
1370
1370
1371
if let Some ( rust) = toml. rust {
1371
1372
set ( & mut config. channel , rust. channel ) ;
@@ -1398,6 +1399,7 @@ impl Config {
1398
1399
debuginfo_level_std = rust. debuginfo_level_std ;
1399
1400
debuginfo_level_tools = rust. debuginfo_level_tools ;
1400
1401
debuginfo_level_tests = rust. debuginfo_level_tests ;
1402
+ lld_enabled = rust. lld ;
1401
1403
1402
1404
config. rust_split_debuginfo = rust
1403
1405
. split_debuginfo
@@ -1422,7 +1424,6 @@ impl Config {
1422
1424
config. incremental = true ;
1423
1425
}
1424
1426
set ( & mut config. use_lld , rust. use_lld ) ;
1425
- set ( & mut config. lld_enabled , rust. lld ) ;
1426
1427
set ( & mut config. llvm_tools_enabled , rust. llvm_tools ) ;
1427
1428
config. rustc_parallel = rust. parallel_compiler . unwrap_or ( false ) ;
1428
1429
config. rustc_default_linker = rust. default_linker ;
@@ -1663,6 +1664,22 @@ impl Config {
1663
1664
config. llvm_plugins = llvm_plugins. unwrap_or ( false ) ;
1664
1665
config. rust_optimize = optimize. unwrap_or ( RustOptimize :: Bool ( true ) ) ;
1665
1666
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
+
1666
1683
let default = debug == Some ( true ) ;
1667
1684
config. rust_debug_assertions = debug_assertions. unwrap_or ( default) ;
1668
1685
config. rust_debug_assertions_std =
0 commit comments