@@ -340,7 +340,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
340340 pub opts : Arc < config:: Options > ,
341341 pub crate_types : Vec < CrateType > ,
342342 pub each_linked_rlib_for_lto : Vec < ( CrateNum , PathBuf ) > ,
343- pub exported_symbols_for_lto : Arc < Vec < String > > ,
344343 pub output_filenames : Arc < OutputFilenames > ,
345344 pub invocation_temp : Option < String > ,
346345 pub regular_module_config : Arc < ModuleConfig > ,
@@ -395,13 +394,15 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
395394
396395fn generate_thin_lto_work < B : ExtraBackendMethods > (
397396 cgcx : & CodegenContext < B > ,
397+ exported_symbols_for_lto : & [ String ] ,
398398 needs_thin_lto : Vec < ( String , B :: ThinBuffer ) > ,
399399 import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
400400) -> Vec < ( WorkItem < B > , u64 ) > {
401401 let _prof_timer = cgcx. prof . generic_activity ( "codegen_thin_generate_lto_work" ) ;
402402
403403 let ( lto_modules, copy_jobs) =
404- B :: run_thin_lto ( cgcx, needs_thin_lto, import_only_modules) . unwrap_or_else ( |e| e. raise ( ) ) ;
404+ B :: run_thin_lto ( cgcx, exported_symbols_for_lto, needs_thin_lto, import_only_modules)
405+ . unwrap_or_else ( |e| e. raise ( ) ) ;
405406 lto_modules
406407 . into_iter ( )
407408 . map ( |module| {
@@ -717,6 +718,7 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
717718 CopyPostLtoArtifacts ( CachedModuleCodegen ) ,
718719 /// Performs fat LTO on the given module.
719720 FatLto {
721+ exported_symbols_for_lto : Arc < Vec < String > > ,
720722 needs_fat_lto : Vec < FatLtoInput < B > > ,
721723 import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
722724 autodiff : Vec < AutoDiffItem > ,
@@ -989,6 +991,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
989991
990992fn execute_fat_lto_work_item < B : ExtraBackendMethods > (
991993 cgcx : & CodegenContext < B > ,
994+ exported_symbols_for_lto : & [ String ] ,
992995 mut needs_fat_lto : Vec < FatLtoInput < B > > ,
993996 import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
994997 autodiff : Vec < AutoDiffItem > ,
@@ -998,7 +1001,8 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
9981001 needs_fat_lto. push ( FatLtoInput :: Serialized { name : wp. cgu_name , buffer : module } )
9991002 }
10001003
1001- let module = B :: run_and_optimize_fat_lto ( cgcx, needs_fat_lto, autodiff) ?;
1004+ let module =
1005+ B :: run_and_optimize_fat_lto ( cgcx, exported_symbols_for_lto, needs_fat_lto, autodiff) ?;
10021006 let module = B :: codegen ( cgcx, module, module_config) ?;
10031007 Ok ( WorkItemResult :: Finished ( module) )
10041008}
@@ -1159,7 +1163,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
11591163 let cgcx = CodegenContext :: < B > {
11601164 crate_types : tcx. crate_types ( ) . to_vec ( ) ,
11611165 each_linked_rlib_for_lto,
1162- exported_symbols_for_lto,
11631166 lto : sess. lto ( ) ,
11641167 fewer_names : sess. fewer_names ( ) ,
11651168 save_temps : sess. opts . cg . save_temps ,
@@ -1438,6 +1441,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14381441
14391442 work_items. push ( (
14401443 WorkItem :: FatLto {
1444+ exported_symbols_for_lto : Arc :: clone ( & exported_symbols_for_lto) ,
14411445 needs_fat_lto,
14421446 import_only_modules,
14431447 autodiff : autodiff_items. clone ( ) ,
@@ -1453,9 +1457,12 @@ fn start_executing_work<B: ExtraBackendMethods>(
14531457 dcx. handle ( ) . emit_fatal ( AutodiffWithoutLto { } ) ;
14541458 }
14551459
1456- for ( work, cost) in
1457- generate_thin_lto_work ( & cgcx, needs_thin_lto, import_only_modules)
1458- {
1460+ for ( work, cost) in generate_thin_lto_work (
1461+ & cgcx,
1462+ & exported_symbols_for_lto,
1463+ needs_thin_lto,
1464+ import_only_modules,
1465+ ) {
14591466 let insertion_index = work_items
14601467 . binary_search_by_key ( & cost, |& ( _, cost) | cost)
14611468 . unwrap_or_else ( |e| e) ;
@@ -1794,12 +1801,18 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
17941801 ) ;
17951802 Ok ( execute_copy_from_cache_work_item ( & cgcx, m, module_config) )
17961803 }
1797- WorkItem :: FatLto { needs_fat_lto, import_only_modules, autodiff } => {
1804+ WorkItem :: FatLto {
1805+ exported_symbols_for_lto,
1806+ needs_fat_lto,
1807+ import_only_modules,
1808+ autodiff,
1809+ } => {
17981810 let _timer = cgcx
17991811 . prof
18001812 . generic_activity_with_arg ( "codegen_module_perform_lto" , "everything" ) ;
18011813 execute_fat_lto_work_item (
18021814 & cgcx,
1815+ & exported_symbols_for_lto,
18031816 needs_fat_lto,
18041817 import_only_modules,
18051818 autodiff,
0 commit comments