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