@@ -182,6 +182,38 @@ impl<'a> GccLinker<'a> {
182
182
self . hinted_static = false ;
183
183
}
184
184
}
185
+
186
+ fn push_cross_lang_lto_args ( & mut self , plugin_path : Option < & OsStr > ) {
187
+ if let Some ( plugin_path) = plugin_path {
188
+ let mut arg = OsString :: from ( "-plugin=" ) ;
189
+ arg. push ( plugin_path) ;
190
+ self . linker_arg ( & arg) ;
191
+ }
192
+
193
+ let opt_level = match self . sess . opts . optimize {
194
+ config:: OptLevel :: No => "O0" ,
195
+ config:: OptLevel :: Less => "O1" ,
196
+ config:: OptLevel :: Default => "O2" ,
197
+ config:: OptLevel :: Aggressive => "O3" ,
198
+ config:: OptLevel :: Size => "Os" ,
199
+ config:: OptLevel :: SizeMin => "Oz" ,
200
+ } ;
201
+
202
+ self . linker_arg ( & format ! ( "-plugin-opt={}" , opt_level) ) ;
203
+ self . linker_arg ( & format ! ( "-plugin-opt=mcpu={}" , self . sess. target_cpu( ) ) ) ;
204
+
205
+ match self . sess . opts . cg . lto {
206
+ config:: Lto :: Thin |
207
+ config:: Lto :: ThinLocal => {
208
+ self . linker_arg ( & format ! ( "-plugin-opt=thin" ) ) ;
209
+ }
210
+ config:: Lto :: Fat |
211
+ config:: Lto :: Yes |
212
+ config:: Lto :: No => {
213
+ // default to regular LTO
214
+ }
215
+ }
216
+ }
185
217
}
186
218
187
219
impl < ' a > Linker for GccLinker < ' a > {
@@ -443,32 +475,11 @@ impl<'a> Linker for GccLinker<'a> {
443
475
CrossLangLto :: NoLink => {
444
476
// Nothing to do
445
477
}
478
+ CrossLangLto :: LinkerPluginAuto => {
479
+ self . push_cross_lang_lto_args ( None ) ;
480
+ }
446
481
CrossLangLto :: LinkerPlugin ( ref path) => {
447
- self . linker_arg ( & format ! ( "-plugin={}" , path. display( ) ) ) ;
448
-
449
- let opt_level = match self . sess . opts . optimize {
450
- config:: OptLevel :: No => "O0" ,
451
- config:: OptLevel :: Less => "O1" ,
452
- config:: OptLevel :: Default => "O2" ,
453
- config:: OptLevel :: Aggressive => "O3" ,
454
- config:: OptLevel :: Size => "Os" ,
455
- config:: OptLevel :: SizeMin => "Oz" ,
456
- } ;
457
-
458
- self . linker_arg ( & format ! ( "-plugin-opt={}" , opt_level) ) ;
459
- self . linker_arg ( & format ! ( "-plugin-opt=mcpu={}" , self . sess. target_cpu( ) ) ) ;
460
-
461
- match self . sess . opts . cg . lto {
462
- config:: Lto :: Thin |
463
- config:: Lto :: ThinLocal => {
464
- self . linker_arg ( & format ! ( "-plugin-opt=thin" ) ) ;
465
- }
466
- config:: Lto :: Fat |
467
- config:: Lto :: Yes |
468
- config:: Lto :: No => {
469
- // default to regular LTO
470
- }
471
- }
482
+ self . push_cross_lang_lto_args ( Some ( path. as_os_str ( ) ) ) ;
472
483
}
473
484
}
474
485
}
0 commit comments