@@ -45,7 +45,9 @@ define_config! {
45
45
codegen_backends: Option <Vec <String >> = "codegen-backends" ,
46
46
llvm_bitcode_linker: Option <bool > = "llvm-bitcode-linker" ,
47
47
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" ,
49
51
llvm_tools: Option <bool > = "llvm-tools" ,
50
52
deny_warnings: Option <bool > = "deny-warnings" ,
51
53
backtrace_on_ice: Option <bool > = "backtrace-on-ice" ,
@@ -70,22 +72,33 @@ define_config! {
70
72
}
71
73
}
72
74
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
75
88
/// - External: use an external `lld` binary
76
89
///
77
90
/// It is configured depending on the target:
78
91
/// 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`
81
94
/// 2) MSVC
82
95
/// - Self-contained: `-Clinker=<path to rust-lld>`
83
96
/// - External: `-Clinker=lld`
84
97
#[ 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
87
100
#[ default]
88
- Unused ,
101
+ None ,
89
102
/// Use `rust-lld` from the compiler's sysroot
90
103
SelfContained ,
91
104
/// Use an externally provided `lld` binary.
@@ -94,24 +107,24 @@ pub enum LldMode {
94
107
External ,
95
108
}
96
109
97
- impl LldMode {
110
+ impl BootstrapOverrideLld {
98
111
pub fn is_used ( & self ) -> bool {
99
112
match self {
100
- LldMode :: SelfContained | LldMode :: External => true ,
101
- LldMode :: Unused => false ,
113
+ BootstrapOverrideLld :: SelfContained | BootstrapOverrideLld :: External => true ,
114
+ BootstrapOverrideLld :: None => false ,
102
115
}
103
116
}
104
117
}
105
118
106
- impl < ' de > Deserialize < ' de > for LldMode {
119
+ impl < ' de > Deserialize < ' de > for BootstrapOverrideLld {
107
120
fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
108
121
where
109
122
D : Deserializer < ' de > ,
110
123
{
111
124
struct LldModeVisitor ;
112
125
113
126
impl serde:: de:: Visitor < ' _ > for LldModeVisitor {
114
- type Value = LldMode ;
127
+ type Value = BootstrapOverrideLld ;
115
128
116
129
fn expecting ( & self , formatter : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
117
130
formatter. write_str ( "one of true, 'self-contained' or 'external'" )
@@ -121,16 +134,16 @@ impl<'de> Deserialize<'de> for LldMode {
121
134
where
122
135
E : serde:: de:: Error ,
123
136
{
124
- Ok ( if v { LldMode :: External } else { LldMode :: Unused } )
137
+ Ok ( if v { BootstrapOverrideLld :: External } else { BootstrapOverrideLld :: None } )
125
138
}
126
139
127
140
fn visit_str < E > ( self , v : & str ) -> Result < Self :: Value , E >
128
141
where
129
142
E : serde:: de:: Error ,
130
143
{
131
144
match v {
132
- "external" => Ok ( LldMode :: External ) ,
133
- "self-contained" => Ok ( LldMode :: SelfContained ) ,
145
+ "external" => Ok ( BootstrapOverrideLld :: External ) ,
146
+ "self-contained" => Ok ( BootstrapOverrideLld :: SelfContained ) ,
134
147
_ => Err ( E :: custom ( format ! ( "unknown mode {v}" ) ) ) ,
135
148
}
136
149
}
@@ -311,7 +324,6 @@ pub fn check_incompatible_options_for_ci_rustc(
311
324
lto,
312
325
stack_protector,
313
326
strip,
314
- lld_mode,
315
327
jemalloc,
316
328
rpath,
317
329
channel,
@@ -359,6 +371,8 @@ pub fn check_incompatible_options_for_ci_rustc(
359
371
frame_pointers : _,
360
372
break_on_ice : _,
361
373
parallel_frontend_threads : _,
374
+ bootstrap_override_lld : _,
375
+ bootstrap_override_lld_legacy : _,
362
376
} = ci_rust_config;
363
377
364
378
// There are two kinds of checks for CI rustc incompatible options:
@@ -374,7 +388,6 @@ pub fn check_incompatible_options_for_ci_rustc(
374
388
err ! ( current_rust_config. debuginfo_level_rustc, debuginfo_level_rustc, "rust" ) ;
375
389
err ! ( current_rust_config. rpath, rpath, "rust" ) ;
376
390
err ! ( current_rust_config. strip, strip, "rust" ) ;
377
- err ! ( current_rust_config. lld_mode, lld_mode, "rust" ) ;
378
391
err ! ( current_rust_config. llvm_tools, llvm_tools, "rust" ) ;
379
392
err ! ( current_rust_config. llvm_bitcode_linker, llvm_bitcode_linker, "rust" ) ;
380
393
err ! ( current_rust_config. jemalloc, jemalloc, "rust" ) ;
0 commit comments