@@ -341,7 +341,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
341
341
pub opts : Arc < config:: Options > ,
342
342
pub crate_types : Vec < CrateType > ,
343
343
pub each_linked_rlib_for_lto : Vec < ( CrateNum , PathBuf ) > ,
344
- pub exported_symbols_for_lto : Arc < Vec < String > > ,
345
344
pub output_filenames : Arc < OutputFilenames > ,
346
345
pub invocation_temp : Option < String > ,
347
346
pub regular_module_config : Arc < ModuleConfig > ,
@@ -396,13 +395,15 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
396
395
397
396
fn generate_thin_lto_work < B : ExtraBackendMethods > (
398
397
cgcx : & CodegenContext < B > ,
398
+ exported_symbols_for_lto : & [ String ] ,
399
399
needs_thin_lto : Vec < ( String , B :: ThinBuffer ) > ,
400
400
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
401
401
) -> Vec < ( WorkItem < B > , u64 ) > {
402
402
let _prof_timer = cgcx. prof . generic_activity ( "codegen_thin_generate_lto_work" ) ;
403
403
404
404
let ( lto_modules, copy_jobs) =
405
- B :: run_thin_lto ( cgcx, needs_thin_lto, import_only_modules) . unwrap_or_else ( |e| e. raise ( ) ) ;
405
+ B :: run_thin_lto ( cgcx, exported_symbols_for_lto, needs_thin_lto, import_only_modules)
406
+ . unwrap_or_else ( |e| e. raise ( ) ) ;
406
407
lto_modules
407
408
. into_iter ( )
408
409
. map ( |module| {
@@ -718,6 +719,7 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
718
719
CopyPostLtoArtifacts ( CachedModuleCodegen ) ,
719
720
/// Performs fat LTO on the given module.
720
721
FatLto {
722
+ exported_symbols_for_lto : Arc < Vec < String > > ,
721
723
needs_fat_lto : Vec < FatLtoInput < B > > ,
722
724
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
723
725
autodiff : Vec < AutoDiffItem > ,
@@ -990,6 +992,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
990
992
991
993
fn execute_fat_lto_work_item < B : ExtraBackendMethods > (
992
994
cgcx : & CodegenContext < B > ,
995
+ exported_symbols_for_lto : & [ String ] ,
993
996
mut needs_fat_lto : Vec < FatLtoInput < B > > ,
994
997
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
995
998
autodiff : Vec < AutoDiffItem > ,
@@ -999,7 +1002,8 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
999
1002
needs_fat_lto. push ( FatLtoInput :: Serialized { name : wp. cgu_name , buffer : module } )
1000
1003
}
1001
1004
1002
- let module = B :: run_and_optimize_fat_lto ( cgcx, needs_fat_lto, autodiff) ?;
1005
+ let module =
1006
+ B :: run_and_optimize_fat_lto ( cgcx, exported_symbols_for_lto, needs_fat_lto, autodiff) ?;
1003
1007
let module = B :: codegen ( cgcx, module, module_config) ?;
1004
1008
Ok ( WorkItemResult :: Finished ( module) )
1005
1009
}
@@ -1160,7 +1164,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
1160
1164
let cgcx = CodegenContext :: < B > {
1161
1165
crate_types : tcx. crate_types ( ) . to_vec ( ) ,
1162
1166
each_linked_rlib_for_lto,
1163
- exported_symbols_for_lto,
1164
1167
lto : sess. lto ( ) ,
1165
1168
fewer_names : sess. fewer_names ( ) ,
1166
1169
save_temps : sess. opts . cg . save_temps ,
@@ -1441,6 +1444,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1441
1444
1442
1445
work_items. push ( (
1443
1446
WorkItem :: FatLto {
1447
+ exported_symbols_for_lto : Arc :: clone ( & exported_symbols_for_lto) ,
1444
1448
needs_fat_lto,
1445
1449
import_only_modules,
1446
1450
autodiff : autodiff_items. clone ( ) ,
@@ -1456,9 +1460,12 @@ fn start_executing_work<B: ExtraBackendMethods>(
1456
1460
dcx. handle ( ) . emit_fatal ( AutodiffWithoutLto { } ) ;
1457
1461
}
1458
1462
1459
- for ( work, cost) in
1460
- generate_thin_lto_work ( & cgcx, needs_thin_lto, import_only_modules)
1461
- {
1463
+ for ( work, cost) in generate_thin_lto_work (
1464
+ & cgcx,
1465
+ & exported_symbols_for_lto,
1466
+ needs_thin_lto,
1467
+ import_only_modules,
1468
+ ) {
1462
1469
let insertion_index = work_items
1463
1470
. binary_search_by_key ( & cost, |& ( _, cost) | cost)
1464
1471
. unwrap_or_else ( |e| e) ;
@@ -1797,12 +1804,18 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
1797
1804
) ;
1798
1805
Ok ( execute_copy_from_cache_work_item ( & cgcx, m, module_config) )
1799
1806
}
1800
- WorkItem :: FatLto { needs_fat_lto, import_only_modules, autodiff } => {
1807
+ WorkItem :: FatLto {
1808
+ exported_symbols_for_lto,
1809
+ needs_fat_lto,
1810
+ import_only_modules,
1811
+ autodiff,
1812
+ } => {
1801
1813
let _timer = cgcx
1802
1814
. prof
1803
1815
. generic_activity_with_arg ( "codegen_module_perform_lto" , "everything" ) ;
1804
1816
execute_fat_lto_work_item (
1805
1817
& cgcx,
1818
+ & exported_symbols_for_lto,
1806
1819
needs_fat_lto,
1807
1820
import_only_modules,
1808
1821
autodiff,
0 commit comments