@@ -20,7 +20,6 @@ use rustc_errors::{
20
20
Suggestions ,
21
21
} ;
22
22
use rustc_fs_util:: link_or_copy;
23
- use rustc_hir:: def_id:: CrateNum ;
24
23
use rustc_incremental:: {
25
24
copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
26
25
} ;
@@ -340,7 +339,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
340
339
pub time_trace : bool ,
341
340
pub opts : Arc < config:: Options > ,
342
341
pub crate_types : Vec < CrateType > ,
343
- pub each_linked_rlib_for_lto : Vec < ( CrateNum , PathBuf ) > ,
344
342
pub output_filenames : Arc < OutputFilenames > ,
345
343
pub invocation_temp : Option < String > ,
346
344
pub regular_module_config : Arc < ModuleConfig > ,
@@ -396,14 +394,20 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
396
394
fn generate_thin_lto_work < B : ExtraBackendMethods > (
397
395
cgcx : & CodegenContext < B > ,
398
396
exported_symbols_for_lto : & [ String ] ,
397
+ each_linked_rlib_for_lto : & [ PathBuf ] ,
399
398
needs_thin_lto : Vec < ( String , B :: ThinBuffer ) > ,
400
399
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
401
400
) -> Vec < ( WorkItem < B > , u64 ) > {
402
401
let _prof_timer = cgcx. prof . generic_activity ( "codegen_thin_generate_lto_work" ) ;
403
402
404
- let ( lto_modules, copy_jobs) =
405
- B :: run_thin_lto ( cgcx, exported_symbols_for_lto, needs_thin_lto, import_only_modules)
406
- . unwrap_or_else ( |e| e. raise ( ) ) ;
403
+ let ( lto_modules, copy_jobs) = B :: run_thin_lto (
404
+ cgcx,
405
+ exported_symbols_for_lto,
406
+ each_linked_rlib_for_lto,
407
+ needs_thin_lto,
408
+ import_only_modules,
409
+ )
410
+ . unwrap_or_else ( |e| e. raise ( ) ) ;
407
411
lto_modules
408
412
. into_iter ( )
409
413
. map ( |module| {
@@ -720,6 +724,7 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
720
724
/// Performs fat LTO on the given module.
721
725
FatLto {
722
726
exported_symbols_for_lto : Arc < Vec < String > > ,
727
+ each_linked_rlib_for_lto : Vec < PathBuf > ,
723
728
needs_fat_lto : Vec < FatLtoInput < B > > ,
724
729
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
725
730
autodiff : Vec < AutoDiffItem > ,
@@ -993,6 +998,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
993
998
fn execute_fat_lto_work_item < B : ExtraBackendMethods > (
994
999
cgcx : & CodegenContext < B > ,
995
1000
exported_symbols_for_lto : & [ String ] ,
1001
+ each_linked_rlib_for_lto : & [ PathBuf ] ,
996
1002
mut needs_fat_lto : Vec < FatLtoInput < B > > ,
997
1003
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
998
1004
autodiff : Vec < AutoDiffItem > ,
@@ -1002,8 +1008,13 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
1002
1008
needs_fat_lto. push ( FatLtoInput :: Serialized { name : wp. cgu_name , buffer : module } )
1003
1009
}
1004
1010
1005
- let module =
1006
- B :: run_and_optimize_fat_lto ( cgcx, exported_symbols_for_lto, needs_fat_lto, autodiff) ?;
1011
+ let module = B :: run_and_optimize_fat_lto (
1012
+ cgcx,
1013
+ exported_symbols_for_lto,
1014
+ each_linked_rlib_for_lto,
1015
+ needs_fat_lto,
1016
+ autodiff,
1017
+ ) ?;
1007
1018
let module = B :: codegen ( cgcx, module, module_config) ?;
1008
1019
Ok ( WorkItemResult :: Finished ( module) )
1009
1020
}
@@ -1119,11 +1130,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
1119
1130
let autodiff_items = autodiff_items. to_vec ( ) ;
1120
1131
1121
1132
let mut each_linked_rlib_for_lto = Vec :: new ( ) ;
1133
+ let mut each_linked_rlib_file_for_lto = Vec :: new ( ) ;
1122
1134
drop ( link:: each_linked_rlib ( crate_info, None , & mut |cnum, path| {
1123
1135
if link:: ignored_for_lto ( sess, crate_info, cnum) {
1124
1136
return ;
1125
1137
}
1126
- each_linked_rlib_for_lto. push ( ( cnum, path. to_path_buf ( ) ) ) ;
1138
+ each_linked_rlib_for_lto. push ( cnum) ;
1139
+ each_linked_rlib_file_for_lto. push ( path. to_path_buf ( ) ) ;
1127
1140
} ) ) ;
1128
1141
1129
1142
// Compute the set of symbols we need to retain when doing LTO (if we need to)
@@ -1163,7 +1176,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
1163
1176
1164
1177
let cgcx = CodegenContext :: < B > {
1165
1178
crate_types : tcx. crate_types ( ) . to_vec ( ) ,
1166
- each_linked_rlib_for_lto,
1167
1179
lto : sess. lto ( ) ,
1168
1180
fewer_names : sess. fewer_names ( ) ,
1169
1181
save_temps : sess. opts . cg . save_temps ,
@@ -1436,6 +1448,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
1436
1448
let needs_fat_lto = mem:: take ( & mut needs_fat_lto) ;
1437
1449
let needs_thin_lto = mem:: take ( & mut needs_thin_lto) ;
1438
1450
let import_only_modules = mem:: take ( & mut lto_import_only_modules) ;
1451
+ let each_linked_rlib_file_for_lto =
1452
+ mem:: take ( & mut each_linked_rlib_file_for_lto) ;
1439
1453
1440
1454
check_lto_allowed ( & cgcx) ;
1441
1455
@@ -1445,6 +1459,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1445
1459
work_items. push ( (
1446
1460
WorkItem :: FatLto {
1447
1461
exported_symbols_for_lto : Arc :: clone ( & exported_symbols_for_lto) ,
1462
+ each_linked_rlib_for_lto : each_linked_rlib_file_for_lto,
1448
1463
needs_fat_lto,
1449
1464
import_only_modules,
1450
1465
autodiff : autodiff_items. clone ( ) ,
@@ -1463,6 +1478,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1463
1478
for ( work, cost) in generate_thin_lto_work (
1464
1479
& cgcx,
1465
1480
& exported_symbols_for_lto,
1481
+ & each_linked_rlib_file_for_lto,
1466
1482
needs_thin_lto,
1467
1483
import_only_modules,
1468
1484
) {
@@ -1806,6 +1822,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
1806
1822
}
1807
1823
WorkItem :: FatLto {
1808
1824
exported_symbols_for_lto,
1825
+ each_linked_rlib_for_lto,
1809
1826
needs_fat_lto,
1810
1827
import_only_modules,
1811
1828
autodiff,
@@ -1816,6 +1833,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
1816
1833
execute_fat_lto_work_item (
1817
1834
& cgcx,
1818
1835
& exported_symbols_for_lto,
1836
+ & each_linked_rlib_for_lto,
1819
1837
needs_fat_lto,
1820
1838
import_only_modules,
1821
1839
autodiff,
0 commit comments