@@ -20,6 +20,7 @@ pub(crate) struct RustcCodegenFlags<'a> {
2020 soft_float : Option < bool > ,
2121 dwarf_version : Option < u32 > ,
2222 stack_protector : Option < & ' a str > ,
23+ linker_plugin_lto : Option < bool > ,
2324}
2425
2526impl < ' this > RustcCodegenFlags < ' this > {
@@ -140,6 +141,8 @@ impl<'this> RustcCodegenFlags<'this> {
140141 "-Ccontrol-flow-guard" => self . control_flow_guard = value. or ( Some ( "true" ) ) ,
141142 // https://doc.rust-lang.org/rustc/codegen-options/index.html#lto
142143 "-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 ) ,
143146 // https://doc.rust-lang.org/rustc/codegen-options/index.html#relocation-model
144147 "-Crelocation-model" => {
145148 self . relocation_model = flag_not_empty ( value) ?;
@@ -316,16 +319,14 @@ impl<'this> RustcCodegenFlags<'this> {
316319 push_if_supported ( format ! ( "-fembed-bitcode={cc_val}" ) . into ( ) ) ;
317320 }
318321
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" ,
325328 } ;
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 ( ) ) ;
329330 }
330331 // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mguard
331332 if let Some ( value) = self . control_flow_guard {
@@ -513,7 +514,7 @@ mod tests {
513514 "-Clink-self-contained=yes" ,
514515 "-Clinker=lld" ,
515516 "-Clinker-flavor=ld.lld" ,
516- "-Clinker-plugin-lto=yes " ,
517+ "-Clinker-plugin-lto=/path " ,
517518 "-Cllvm-args=foo" ,
518519 "-Cmetadata=foo" ,
519520 "-Cno-prepopulate-passes" ,
@@ -553,6 +554,7 @@ mod tests {
553554 branch_protection : Some ( "bti,pac-ret,leaf" ) ,
554555 dwarf_version : Some ( 5 ) ,
555556 stack_protector : Some ( "strong" ) ,
557+ linker_plugin_lto : Some ( true ) ,
556558 } ,
557559 ) ;
558560 }
0 commit comments