@@ -20,7 +20,6 @@ use rustc_errors::{
2020    Suggestions , 
2121} ; 
2222use  rustc_fs_util:: link_or_copy; 
23- use  rustc_hir:: def_id:: CrateNum ; 
2423use  rustc_incremental:: { 
2524    copy_cgu_workproduct_to_incr_comp_cache_dir,  in_incr_comp_dir,  in_incr_comp_dir_sess, 
2625} ; 
@@ -340,7 +339,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
340339    pub  time_trace :  bool , 
341340    pub  opts :  Arc < config:: Options > , 
342341    pub  crate_types :  Vec < CrateType > , 
343-     pub  each_linked_rlib_for_lto :  Vec < ( CrateNum ,  PathBuf ) > , 
344342    pub  output_filenames :  Arc < OutputFilenames > , 
345343    pub  invocation_temp :  Option < String > , 
346344    pub  regular_module_config :  Arc < ModuleConfig > , 
@@ -396,14 +394,20 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
396394fn  generate_thin_lto_work < B :  ExtraBackendMethods > ( 
397395    cgcx :  & CodegenContext < B > , 
398396    exported_symbols_for_lto :  & [ String ] , 
397+     each_linked_rlib_for_lto :  & [ PathBuf ] , 
399398    needs_thin_lto :  Vec < ( String ,  B :: ThinBuffer ) > , 
400399    import_only_modules :  Vec < ( SerializedModule < B :: ModuleBuffer > ,  WorkProduct ) > , 
401400)  -> Vec < ( WorkItem < B > ,  u64 ) >  { 
402401    let  _prof_timer = cgcx. prof . generic_activity ( "codegen_thin_generate_lto_work" ) ; 
403402
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 ( ) ) ; 
407411    lto_modules
408412        . into_iter ( ) 
409413        . map ( |module| { 
@@ -720,6 +724,7 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
720724    /// Performs fat LTO on the given module. 
721725FatLto  { 
722726        exported_symbols_for_lto :  Arc < Vec < String > > , 
727+         each_linked_rlib_for_lto :  Vec < PathBuf > , 
723728        needs_fat_lto :  Vec < FatLtoInput < B > > , 
724729        import_only_modules :  Vec < ( SerializedModule < B :: ModuleBuffer > ,  WorkProduct ) > , 
725730        autodiff :  Vec < AutoDiffItem > , 
@@ -993,6 +998,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
993998fn  execute_fat_lto_work_item < B :  ExtraBackendMethods > ( 
994999    cgcx :  & CodegenContext < B > , 
9951000    exported_symbols_for_lto :  & [ String ] , 
1001+     each_linked_rlib_for_lto :  & [ PathBuf ] , 
9961002    mut  needs_fat_lto :  Vec < FatLtoInput < B > > , 
9971003    import_only_modules :  Vec < ( SerializedModule < B :: ModuleBuffer > ,  WorkProduct ) > , 
9981004    autodiff :  Vec < AutoDiffItem > , 
@@ -1002,8 +1008,13 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
10021008        needs_fat_lto. push ( FatLtoInput :: Serialized  {  name :  wp. cgu_name ,  buffer :  module } ) 
10031009    } 
10041010
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+     ) ?; 
10071018    let  module = B :: codegen ( cgcx,  module,  module_config) ?; 
10081019    Ok ( WorkItemResult :: Finished ( module) ) 
10091020} 
@@ -1119,11 +1130,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
11191130    let  autodiff_items = autodiff_items. to_vec ( ) ; 
11201131
11211132    let  mut  each_linked_rlib_for_lto = Vec :: new ( ) ; 
1133+     let  mut  each_linked_rlib_file_for_lto = Vec :: new ( ) ; 
11221134    drop ( link:: each_linked_rlib ( crate_info,  None ,  & mut  |cnum,  path| { 
11231135        if  link:: ignored_for_lto ( sess,  crate_info,  cnum)  { 
11241136            return ; 
11251137        } 
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 ( ) ) ; 
11271140    } ) ) ; 
11281141
11291142    // 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>(
11631176
11641177    let  cgcx = CodegenContext :: < B >  { 
11651178        crate_types :  tcx. crate_types ( ) . to_vec ( ) , 
1166-         each_linked_rlib_for_lto, 
11671179        lto :  sess. lto ( ) , 
11681180        fewer_names :  sess. fewer_names ( ) , 
11691181        save_temps :  sess. opts . cg . save_temps , 
@@ -1436,6 +1448,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
14361448                    let  needs_fat_lto = mem:: take ( & mut  needs_fat_lto) ; 
14371449                    let  needs_thin_lto = mem:: take ( & mut  needs_thin_lto) ; 
14381450                    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) ; 
14391453
14401454                    check_lto_allowed ( & cgcx) ; 
14411455
@@ -1445,6 +1459,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14451459                        work_items. push ( ( 
14461460                            WorkItem :: FatLto  { 
14471461                                exported_symbols_for_lto :  Arc :: clone ( & exported_symbols_for_lto) , 
1462+                                 each_linked_rlib_for_lto :  each_linked_rlib_file_for_lto, 
14481463                                needs_fat_lto, 
14491464                                import_only_modules, 
14501465                                autodiff :  autodiff_items. clone ( ) , 
@@ -1463,6 +1478,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14631478                        for  ( work,  cost)  in  generate_thin_lto_work ( 
14641479                            & cgcx, 
14651480                            & exported_symbols_for_lto, 
1481+                             & each_linked_rlib_file_for_lto, 
14661482                            needs_thin_lto, 
14671483                            import_only_modules, 
14681484                        )  { 
@@ -1806,6 +1822,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18061822                } 
18071823                WorkItem :: FatLto  { 
18081824                    exported_symbols_for_lto, 
1825+                     each_linked_rlib_for_lto, 
18091826                    needs_fat_lto, 
18101827                    import_only_modules, 
18111828                    autodiff, 
@@ -1816,6 +1833,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18161833                    execute_fat_lto_work_item ( 
18171834                        & cgcx, 
18181835                        & exported_symbols_for_lto, 
1836+                         & each_linked_rlib_for_lto, 
18191837                        needs_fat_lto, 
18201838                        import_only_modules, 
18211839                        autodiff, 
0 commit comments