@@ -1372,6 +1372,7 @@ impl Config {
1372
1372
let mut debuginfo_level_tests = None ;
1373
1373
let mut optimize = None ;
1374
1374
let mut omit_git_hash = None ;
1375
+ let mut lld_enabled = None ;
1375
1376
1376
1377
if let Some ( rust) = toml. rust {
1377
1378
set ( & mut config. channel , rust. channel ) ;
@@ -1404,6 +1405,7 @@ impl Config {
1404
1405
debuginfo_level_std = rust. debuginfo_level_std ;
1405
1406
debuginfo_level_tools = rust. debuginfo_level_tools ;
1406
1407
debuginfo_level_tests = rust. debuginfo_level_tests ;
1408
+ lld_enabled = rust. lld ;
1407
1409
1408
1410
config. rust_split_debuginfo = rust
1409
1411
. split_debuginfo
@@ -1428,7 +1430,6 @@ impl Config {
1428
1430
config. incremental = true ;
1429
1431
}
1430
1432
set ( & mut config. use_lld , rust. use_lld ) ;
1431
- set ( & mut config. lld_enabled , rust. lld ) ;
1432
1433
set ( & mut config. llvm_tools_enabled , rust. llvm_tools ) ;
1433
1434
config. rustc_parallel = rust
1434
1435
. parallel_compiler
@@ -1665,6 +1666,26 @@ impl Config {
1665
1666
config. llvm_plugins = llvm_plugins. unwrap_or ( false ) ;
1666
1667
config. rust_optimize = optimize. unwrap_or ( RustOptimize :: Bool ( true ) ) ;
1667
1668
1669
+ // `x86_64-unknown-linux-gnu` now uses the self-contained linker, so we have to build
1670
+ // our internal lld by default:
1671
+ // - when building our in-tree llvm (the target has not set an `llvm-config`), we're able to
1672
+ // build rust-lld as well
1673
+ // - when using an external llvm that's downloaded from CI, rust-lld is also packaged there
1674
+ // - otherwise, we're using an external llvm and lld is not available and thus, disabled
1675
+ // - similarly, it's not built or used by this target when asked not to (when the config
1676
+ // sets `rust.lld = false`)
1677
+ if config. build . triple == "x86_64-unknown-linux-gnu" && config. hosts == & [ config. build ] {
1678
+ let no_llvm_config = config
1679
+ . target_config
1680
+ . get ( & config. build )
1681
+ . is_some_and ( |target_config| target_config. llvm_config . is_none ( ) ) ;
1682
+ let enable_lld = config. llvm_from_ci || no_llvm_config;
1683
+ // Prefer the config setting in case an explicit opt-out is needed.
1684
+ config. lld_enabled = lld_enabled. unwrap_or ( enable_lld) ;
1685
+ } else {
1686
+ set ( & mut config. lld_enabled , lld_enabled) ;
1687
+ }
1688
+
1668
1689
let default = debug == Some ( true ) ;
1669
1690
config. rust_debug_assertions = debug_assertions. unwrap_or ( default) ;
1670
1691
config. rust_debug_assertions_std =
0 commit comments