@@ -20,6 +20,7 @@ pub(crate) struct RustcCodegenFlags<'a> {
20
20
soft_float : Option < bool > ,
21
21
dwarf_version : Option < u32 > ,
22
22
stack_protector : Option < & ' a str > ,
23
+ linker_plugin_lto : Option < bool > ,
23
24
}
24
25
25
26
impl < ' this > RustcCodegenFlags < ' this > {
@@ -140,6 +141,8 @@ impl<'this> RustcCodegenFlags<'this> {
140
141
"-Ccontrol-flow-guard" => self . control_flow_guard = value. or ( Some ( "true" ) ) ,
141
142
// https://doc.rust-lang.org/rustc/codegen-options/index.html#lto
142
143
"-Clto" => self . lto = value. or ( Some ( "true" ) ) ,
144
+ // https://doc.rust-lang.org/rustc/linker-plugin-lto.html
145
+ "-Clinker-plugin-lto" => self . linker_plugin_lto = Some ( true ) ,
143
146
// https://doc.rust-lang.org/rustc/codegen-options/index.html#relocation-model
144
147
"-Crelocation-model" => {
145
148
self . relocation_model = flag_not_empty ( value) ?;
@@ -316,16 +319,14 @@ impl<'this> RustcCodegenFlags<'this> {
316
319
push_if_supported ( format ! ( "-fembed-bitcode={cc_val}" ) . into ( ) ) ;
317
320
}
318
321
319
- // https://clang.llvm .org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
320
- if let Some ( value ) = self . lto {
321
- let cc_val = match value {
322
- "y" | "yes" | "on" | "true" | "fat" => Some ( "full" ) ,
323
- "thin" => Some ( "thin" ) ,
324
- _ => None ,
322
+ // https://doc.rust-lang .org/rustc/linker-plugin-lto.html
323
+ if self . linker_plugin_lto . unwrap_or ( false ) {
324
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
325
+ let cc_val = match self . lto {
326
+ Some ( "thin" ) => "thin" ,
327
+ _ => "full" ,
325
328
} ;
326
- if let Some ( cc_val) = cc_val {
327
- push_if_supported ( format ! ( "-flto={cc_val}" ) . into ( ) ) ;
328
- }
329
+ push_if_supported ( format ! ( "-flto={cc_val}" ) . into ( ) ) ;
329
330
}
330
331
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mguard
331
332
if let Some ( value) = self . control_flow_guard {
@@ -513,7 +514,7 @@ mod tests {
513
514
"-Clink-self-contained=yes" ,
514
515
"-Clinker=lld" ,
515
516
"-Clinker-flavor=ld.lld" ,
516
- "-Clinker-plugin-lto=yes " ,
517
+ "-Clinker-plugin-lto=/path " ,
517
518
"-Cllvm-args=foo" ,
518
519
"-Cmetadata=foo" ,
519
520
"-Cno-prepopulate-passes" ,
@@ -553,6 +554,7 @@ mod tests {
553
554
branch_protection : Some ( "bti,pac-ret,leaf" ) ,
554
555
dwarf_version : Some ( 5 ) ,
555
556
stack_protector : Some ( "strong" ) ,
557
+ linker_plugin_lto : Some ( true ) ,
556
558
} ,
557
559
) ;
558
560
}
0 commit comments