@@ -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} ; 
@@ -339,7 +338,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
339338    pub  time_trace :  bool , 
340339    pub  opts :  Arc < config:: Options > , 
341340    pub  crate_types :  Vec < CrateType > , 
342-     pub  each_linked_rlib_for_lto :  Vec < ( CrateNum ,  PathBuf ) > , 
343341    pub  output_filenames :  Arc < OutputFilenames > , 
344342    pub  invocation_temp :  Option < String > , 
345343    pub  regular_module_config :  Arc < ModuleConfig > , 
@@ -395,14 +393,20 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
395393fn  generate_thin_lto_work < B :  ExtraBackendMethods > ( 
396394    cgcx :  & CodegenContext < B > , 
397395    exported_symbols_for_lto :  & [ String ] , 
396+     each_linked_rlib_for_lto :  & [ PathBuf ] , 
398397    needs_thin_lto :  Vec < ( String ,  B :: ThinBuffer ) > , 
399398    import_only_modules :  Vec < ( SerializedModule < B :: ModuleBuffer > ,  WorkProduct ) > , 
400399)  -> Vec < ( WorkItem < B > ,  u64 ) >  { 
401400    let  _prof_timer = cgcx. prof . generic_activity ( "codegen_thin_generate_lto_work" ) ; 
402401
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 ( ) ) ; 
406410    lto_modules
407411        . into_iter ( ) 
408412        . map ( |module| { 
@@ -719,6 +723,7 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
719723    /// Performs fat LTO on the given module. 
720724FatLto  { 
721725        exported_symbols_for_lto :  Arc < Vec < String > > , 
726+         each_linked_rlib_for_lto :  Vec < PathBuf > , 
722727        needs_fat_lto :  Vec < FatLtoInput < B > > , 
723728        import_only_modules :  Vec < ( SerializedModule < B :: ModuleBuffer > ,  WorkProduct ) > , 
724729        autodiff :  Vec < AutoDiffItem > , 
@@ -992,6 +997,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
992997fn  execute_fat_lto_work_item < B :  ExtraBackendMethods > ( 
993998    cgcx :  & CodegenContext < B > , 
994999    exported_symbols_for_lto :  & [ String ] , 
1000+     each_linked_rlib_for_lto :  & [ PathBuf ] , 
9951001    mut  needs_fat_lto :  Vec < FatLtoInput < B > > , 
9961002    import_only_modules :  Vec < ( SerializedModule < B :: ModuleBuffer > ,  WorkProduct ) > , 
9971003    autodiff :  Vec < AutoDiffItem > , 
@@ -1001,8 +1007,13 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
10011007        needs_fat_lto. push ( FatLtoInput :: Serialized  {  name :  wp. cgu_name ,  buffer :  module } ) 
10021008    } 
10031009
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+     ) ?; 
10061017    let  module = B :: codegen ( cgcx,  module,  module_config) ?; 
10071018    Ok ( WorkItemResult :: Finished ( module) ) 
10081019} 
@@ -1118,11 +1129,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
11181129    let  autodiff_items = autodiff_items. to_vec ( ) ; 
11191130
11201131    let  mut  each_linked_rlib_for_lto = Vec :: new ( ) ; 
1132+     let  mut  each_linked_rlib_file_for_lto = Vec :: new ( ) ; 
11211133    drop ( link:: each_linked_rlib ( crate_info,  None ,  & mut  |cnum,  path| { 
11221134        if  link:: ignored_for_lto ( sess,  crate_info,  cnum)  { 
11231135            return ; 
11241136        } 
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 ( ) ) ; 
11261139    } ) ) ; 
11271140
11281141    // 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>(
11621175
11631176    let  cgcx = CodegenContext :: < B >  { 
11641177        crate_types :  tcx. crate_types ( ) . to_vec ( ) , 
1165-         each_linked_rlib_for_lto, 
11661178        lto :  sess. lto ( ) , 
11671179        fewer_names :  sess. fewer_names ( ) , 
11681180        save_temps :  sess. opts . cg . save_temps , 
@@ -1435,13 +1447,16 @@ fn start_executing_work<B: ExtraBackendMethods>(
14351447                    let  needs_fat_lto = mem:: take ( & mut  needs_fat_lto) ; 
14361448                    let  needs_thin_lto = mem:: take ( & mut  needs_thin_lto) ; 
14371449                    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) ; 
14381452
14391453                    if  !needs_fat_lto. is_empty ( )  { 
14401454                        assert ! ( needs_thin_lto. is_empty( ) ) ; 
14411455
14421456                        work_items. push ( ( 
14431457                            WorkItem :: FatLto  { 
14441458                                exported_symbols_for_lto :  Arc :: clone ( & exported_symbols_for_lto) , 
1459+                                 each_linked_rlib_for_lto :  each_linked_rlib_file_for_lto, 
14451460                                needs_fat_lto, 
14461461                                import_only_modules, 
14471462                                autodiff :  autodiff_items. clone ( ) , 
@@ -1460,6 +1475,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14601475                        for  ( work,  cost)  in  generate_thin_lto_work ( 
14611476                            & cgcx, 
14621477                            & exported_symbols_for_lto, 
1478+                             & each_linked_rlib_file_for_lto, 
14631479                            needs_thin_lto, 
14641480                            import_only_modules, 
14651481                        )  { 
@@ -1803,6 +1819,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18031819                } 
18041820                WorkItem :: FatLto  { 
18051821                    exported_symbols_for_lto, 
1822+                     each_linked_rlib_for_lto, 
18061823                    needs_fat_lto, 
18071824                    import_only_modules, 
18081825                    autodiff, 
@@ -1813,6 +1830,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18131830                    execute_fat_lto_work_item ( 
18141831                        & cgcx, 
18151832                        & exported_symbols_for_lto, 
1833+                         & each_linked_rlib_for_lto, 
18161834                        needs_fat_lto, 
18171835                        import_only_modules, 
18181836                        autodiff, 
0 commit comments