@@ -1372,6 +1372,7 @@ impl Config {
13721372        let  mut  debuginfo_level_tests = None ; 
13731373        let  mut  optimize = None ; 
13741374        let  mut  omit_git_hash = None ; 
1375+         let  mut  lld_enabled = None ; 
13751376
13761377        if  let  Some ( rust)  = toml. rust  { 
13771378            set ( & mut  config. channel ,  rust. channel ) ; 
@@ -1404,6 +1405,7 @@ impl Config {
14041405            debuginfo_level_std = rust. debuginfo_level_std ; 
14051406            debuginfo_level_tools = rust. debuginfo_level_tools ; 
14061407            debuginfo_level_tests = rust. debuginfo_level_tests ; 
1408+             lld_enabled = rust. lld ; 
14071409
14081410            config. rust_split_debuginfo  = rust
14091411                . split_debuginfo 
@@ -1428,7 +1430,6 @@ impl Config {
14281430                config. incremental  = true ; 
14291431            } 
14301432            set ( & mut  config. use_lld ,  rust. use_lld ) ; 
1431-             set ( & mut  config. lld_enabled ,  rust. lld ) ; 
14321433            set ( & mut  config. llvm_tools_enabled ,  rust. llvm_tools ) ; 
14331434            config. rustc_parallel  = rust
14341435                . parallel_compiler 
@@ -1665,6 +1666,26 @@ impl Config {
16651666        config. llvm_plugins  = llvm_plugins. unwrap_or ( false ) ; 
16661667        config. rust_optimize  = optimize. unwrap_or ( RustOptimize :: Bool ( true ) ) ; 
16671668
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+ 
16681689        let  default = debug == Some ( true ) ; 
16691690        config. rust_debug_assertions  = debug_assertions. unwrap_or ( default) ; 
16701691        config. rust_debug_assertions_std  =
0 commit comments