@@ -45,7 +45,9 @@ define_config! {
4545 codegen_backends: Option <Vec <String >> = "codegen-backends" ,
4646 llvm_bitcode_linker: Option <bool > = "llvm-bitcode-linker" ,
4747 lld: Option <bool > = "lld" ,
48- lld_mode: Option <LldMode > = "use-lld" ,
48+ bootstrap_override_lld: Option <BootstrapOverrideLld > = "bootstrap-override-lld" ,
49+ // FIXME: Remove this option in Spring 2026
50+ bootstrap_override_lld_legacy: Option <BootstrapOverrideLld > = "use-lld" ,
4951 llvm_tools: Option <bool > = "llvm-tools" ,
5052 deny_warnings: Option <bool > = "deny-warnings" ,
5153 backtrace_on_ice: Option <bool > = "backtrace-on-ice" ,
@@ -70,22 +72,33 @@ define_config! {
7072 }
7173}
7274
73- /// LLD in bootstrap works like this:
74- /// - Self-contained lld: use `rust-lld` from the compiler's sysroot
75+ /// Determines if we should override the linker used for linking Rust code built
76+ /// during the bootstrapping process to be LLD.
77+ ///
78+ /// The primary use-case for this is to make local (re)builds of Rust code faster
79+ /// when using bootstrap.
80+ ///
81+ /// This does not affect the *behavior* of the built/distributed compiler when invoked
82+ /// outside of bootstrap.
83+ /// It might affect its performance/binary size though, as that can depend on the
84+ /// linker that links rustc.
85+ ///
86+ /// There are two ways of overriding the linker to be LLD:
87+ /// - Self-contained LLD: use `rust-lld` from the compiler's sysroot
7588/// - External: use an external `lld` binary
7689///
7790/// It is configured depending on the target:
7891/// 1) Everything except MSVC
79- /// - Self-contained: `-Clinker-flavor=gnu- lld-cc -Clink-self-contained=+linker`
80- /// - External: `-Clinker-flavor=gnu- lld-cc `
92+ /// - Self-contained: `-Clinker-features=+ lld -Clink-self-contained=+linker`
93+ /// - External: `-Clinker-features=+ lld`
8194/// 2) MSVC
8295/// - Self-contained: `-Clinker=<path to rust-lld>`
8396/// - External: `-Clinker=lld`
8497#[ derive( Copy , Clone , Default , Debug , PartialEq ) ]
85- pub enum LldMode {
86- /// Do not use LLD
98+ pub enum BootstrapOverrideLld {
99+ /// Do not override the linker LLD
87100 #[ default]
88- Unused ,
101+ None ,
89102 /// Use `rust-lld` from the compiler's sysroot
90103 SelfContained ,
91104 /// Use an externally provided `lld` binary.
@@ -94,24 +107,24 @@ pub enum LldMode {
94107 External ,
95108}
96109
97- impl LldMode {
110+ impl BootstrapOverrideLld {
98111 pub fn is_used ( & self ) -> bool {
99112 match self {
100- LldMode :: SelfContained | LldMode :: External => true ,
101- LldMode :: Unused => false ,
113+ BootstrapOverrideLld :: SelfContained | BootstrapOverrideLld :: External => true ,
114+ BootstrapOverrideLld :: None => false ,
102115 }
103116 }
104117}
105118
106- impl < ' de > Deserialize < ' de > for LldMode {
119+ impl < ' de > Deserialize < ' de > for BootstrapOverrideLld {
107120 fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
108121 where
109122 D : Deserializer < ' de > ,
110123 {
111124 struct LldModeVisitor ;
112125
113126 impl serde:: de:: Visitor < ' _ > for LldModeVisitor {
114- type Value = LldMode ;
127+ type Value = BootstrapOverrideLld ;
115128
116129 fn expecting ( & self , formatter : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
117130 formatter. write_str ( "one of true, 'self-contained' or 'external'" )
@@ -121,16 +134,16 @@ impl<'de> Deserialize<'de> for LldMode {
121134 where
122135 E : serde:: de:: Error ,
123136 {
124- Ok ( if v { LldMode :: External } else { LldMode :: Unused } )
137+ Ok ( if v { BootstrapOverrideLld :: External } else { BootstrapOverrideLld :: None } )
125138 }
126139
127140 fn visit_str < E > ( self , v : & str ) -> Result < Self :: Value , E >
128141 where
129142 E : serde:: de:: Error ,
130143 {
131144 match v {
132- "external" => Ok ( LldMode :: External ) ,
133- "self-contained" => Ok ( LldMode :: SelfContained ) ,
145+ "external" => Ok ( BootstrapOverrideLld :: External ) ,
146+ "self-contained" => Ok ( BootstrapOverrideLld :: SelfContained ) ,
134147 _ => Err ( E :: custom ( format ! ( "unknown mode {v}" ) ) ) ,
135148 }
136149 }
@@ -311,7 +324,6 @@ pub fn check_incompatible_options_for_ci_rustc(
311324 lto,
312325 stack_protector,
313326 strip,
314- lld_mode,
315327 jemalloc,
316328 rpath,
317329 channel,
@@ -359,6 +371,8 @@ pub fn check_incompatible_options_for_ci_rustc(
359371 frame_pointers : _,
360372 break_on_ice : _,
361373 parallel_frontend_threads : _,
374+ bootstrap_override_lld : _,
375+ bootstrap_override_lld_legacy : _,
362376 } = ci_rust_config;
363377
364378 // There are two kinds of checks for CI rustc incompatible options:
@@ -374,7 +388,6 @@ pub fn check_incompatible_options_for_ci_rustc(
374388 err ! ( current_rust_config. debuginfo_level_rustc, debuginfo_level_rustc, "rust" ) ;
375389 err ! ( current_rust_config. rpath, rpath, "rust" ) ;
376390 err ! ( current_rust_config. strip, strip, "rust" ) ;
377- err ! ( current_rust_config. lld_mode, lld_mode, "rust" ) ;
378391 err ! ( current_rust_config. llvm_tools, llvm_tools, "rust" ) ;
379392 err ! ( current_rust_config. llvm_bitcode_linker, llvm_bitcode_linker, "rust" ) ;
380393 err ! ( current_rust_config. jemalloc, jemalloc, "rust" ) ;
0 commit comments