@@ -34,7 +34,7 @@ use rustc_span::{FileName, InnerSpan, Span, SpanData};
3434use rustc_target:: spec:: { MergeFunctions , SanitizerSet } ;
3535use tracing:: debug;
3636
37- use crate :: back:: link:: { self , ensure_removed} ;
37+ use crate :: back:: link:: ensure_removed;
3838use crate :: back:: lto:: { self , SerializedModule , check_lto_allowed} ;
3939use crate :: errors:: ErrorCreatingRemarkDir ;
4040use crate :: traits:: * ;
@@ -389,18 +389,8 @@ fn generate_thin_lto_work<B: WriteBackendMethods>(
389389
390390enum MaybeLtoModules < B : WriteBackendMethods > {
391391 NoLto ( CompiledModules ) ,
392- FatLto {
393- cgcx : CodegenContext ,
394- exported_symbols_for_lto : Arc < Vec < String > > ,
395- each_linked_rlib_file_for_lto : Vec < PathBuf > ,
396- needs_fat_lto : Vec < FatLtoInput < B > > ,
397- } ,
398- ThinLto {
399- cgcx : CodegenContext ,
400- exported_symbols_for_lto : Arc < Vec < String > > ,
401- each_linked_rlib_file_for_lto : Vec < PathBuf > ,
402- needs_thin_lto : Vec < ThinLtoInput < B > > ,
403- } ,
392+ FatLto { cgcx : CodegenContext , needs_fat_lto : Vec < FatLtoInput < B > > } ,
393+ ThinLto { cgcx : CodegenContext , needs_thin_lto : Vec < ThinLtoInput < B > > } ,
404394}
405395
406396fn need_bitcode_in_object ( tcx : TyCtxt < ' _ > ) -> bool {
@@ -424,7 +414,6 @@ fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool {
424414pub ( crate ) fn start_async_codegen < B : ExtraBackendMethods > (
425415 backend : B ,
426416 tcx : TyCtxt < ' _ > ,
427- crate_info : & CrateInfo ,
428417 allocator_module : Option < ModuleCodegen < B :: Module > > ,
429418) -> OngoingCodegen < B > {
430419 let ( coordinator_send, coordinator_receive) = channel ( ) ;
@@ -440,7 +429,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
440429 let coordinator_thread = start_executing_work (
441430 backend. clone ( ) ,
442431 tcx,
443- crate_info,
444432 shared_emitter,
445433 codegen_worker_send,
446434 coordinator_receive,
@@ -992,8 +980,8 @@ fn do_thin_lto<B: WriteBackendMethods>(
992980 prof : & SelfProfilerRef ,
993981 shared_emitter : SharedEmitter ,
994982 tm_factory : TargetMachineFactoryFn < B > ,
995- exported_symbols_for_lto : Arc < Vec < String > > ,
996- each_linked_rlib_for_lto : Vec < PathBuf > ,
983+ exported_symbols_for_lto : & [ String ] ,
984+ each_linked_rlib_for_lto : & [ PathBuf ] ,
997985 needs_thin_lto : Vec < ThinLtoInput < B > > ,
998986) -> Vec < CompiledModule > {
999987 let _timer = prof. verbose_generic_activity ( "LLVM_thinlto" ) ;
@@ -1231,7 +1219,6 @@ enum MainThreadState {
12311219fn start_executing_work < B : ExtraBackendMethods > (
12321220 backend : B ,
12331221 tcx : TyCtxt < ' _ > ,
1234- crate_info : & CrateInfo ,
12351222 shared_emitter : SharedEmitter ,
12361223 codegen_worker_send : Sender < CguMessage > ,
12371224 coordinator_receive : Receiver < Message < B > > ,
@@ -1243,22 +1230,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
12431230 let sess = tcx. sess ;
12441231 let prof = sess. prof . clone ( ) ;
12451232
1246- let mut each_linked_rlib_for_lto = Vec :: new ( ) ;
1247- let mut each_linked_rlib_file_for_lto = Vec :: new ( ) ;
1248- if sess. lto ( ) != Lto :: No && sess. lto ( ) != Lto :: ThinLocal {
1249- drop ( link:: each_linked_rlib ( crate_info, None , & mut |cnum, path| {
1250- if link:: ignored_for_lto ( sess, crate_info, cnum) {
1251- return ;
1252- }
1253-
1254- each_linked_rlib_for_lto. push ( cnum) ;
1255- each_linked_rlib_file_for_lto. push ( path. to_path_buf ( ) ) ;
1256- } ) ) ;
1257- }
1258-
1259- // Compute the set of symbols we need to retain when doing LTO (if we need to)
1233+ // Compute the set of symbols we need to retain when doing thin local LTO (if we need to)
12601234 let exported_symbols_for_lto =
1261- Arc :: new ( lto:: exported_symbols_for_lto ( tcx, & each_linked_rlib_for_lto ) ) ;
1235+ if sess . lto ( ) == Lto :: ThinLocal { lto:: exported_symbols_for_lto ( tcx, & [ ] ) } else { vec ! [ ] } ;
12621236
12631237 // First up, convert our jobserver into a helper thread so we can use normal
12641238 // mpsc channels to manage our messages and such.
@@ -1757,12 +1731,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
17571731 needs_fat_lto. push ( FatLtoInput :: Serialized { name : wp. cgu_name , bitcode_path } )
17581732 }
17591733
1760- return Ok ( MaybeLtoModules :: FatLto {
1761- cgcx,
1762- exported_symbols_for_lto,
1763- each_linked_rlib_file_for_lto,
1764- needs_fat_lto,
1765- } ) ;
1734+ return Ok ( MaybeLtoModules :: FatLto { cgcx, needs_fat_lto } ) ;
17661735 } else if !needs_thin_lto. is_empty ( ) || !lto_import_only_modules. is_empty ( ) {
17671736 assert ! ( compiled_modules. is_empty( ) ) ;
17681737 assert ! ( needs_fat_lto. is_empty( ) ) ;
@@ -1777,8 +1746,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
17771746 & prof,
17781747 shared_emitter. clone ( ) ,
17791748 tm_factory,
1780- exported_symbols_for_lto,
1781- each_linked_rlib_file_for_lto ,
1749+ & exported_symbols_for_lto,
1750+ & [ ] ,
17821751 needs_thin_lto,
17831752 ) ) ;
17841753 } else {
@@ -1790,12 +1759,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
17901759 } ) ;
17911760 }
17921761
1793- return Ok ( MaybeLtoModules :: ThinLto {
1794- cgcx,
1795- exported_symbols_for_lto,
1796- each_linked_rlib_file_for_lto,
1797- needs_thin_lto,
1798- } ) ;
1762+ return Ok ( MaybeLtoModules :: ThinLto { cgcx, needs_thin_lto } ) ;
17991763 }
18001764 }
18011765
@@ -2139,7 +2103,11 @@ pub struct OngoingCodegen<B: WriteBackendMethods> {
21392103}
21402104
21412105impl < B : WriteBackendMethods > OngoingCodegen < B > {
2142- pub fn join ( self , sess : & Session ) -> ( CompiledModules , FxIndexMap < WorkProductId , WorkProduct > ) {
2106+ pub fn join (
2107+ self ,
2108+ sess : & Session ,
2109+ crate_info : & CrateInfo ,
2110+ ) -> ( CompiledModules , FxIndexMap < WorkProductId , WorkProduct > ) {
21432111 self . shared_emitter_main . check ( sess, true ) ;
21442112
21452113 let maybe_lto_modules = sess. time ( "join_worker_thread" , || match self . coordinator . join ( ) {
@@ -2163,12 +2131,7 @@ impl<B: WriteBackendMethods> OngoingCodegen<B> {
21632131 drop ( shared_emitter) ;
21642132 compiled_modules
21652133 }
2166- MaybeLtoModules :: FatLto {
2167- cgcx,
2168- exported_symbols_for_lto,
2169- each_linked_rlib_file_for_lto,
2170- needs_fat_lto,
2171- } => {
2134+ MaybeLtoModules :: FatLto { cgcx, needs_fat_lto } => {
21722135 let tm_factory = self . backend . target_machine_factory (
21732136 sess,
21742137 cgcx. opt_level ,
@@ -2181,19 +2144,14 @@ impl<B: WriteBackendMethods> OngoingCodegen<B> {
21812144 & cgcx,
21822145 shared_emitter,
21832146 tm_factory,
2184- & exported_symbols_for_lto,
2185- & each_linked_rlib_file_for_lto,
2147+ & crate_info . exported_symbols_for_lto,
2148+ & crate_info . each_linked_rlib_file_for_lto,
21862149 needs_fat_lto,
21872150 ) ] ,
21882151 allocator_module : None ,
21892152 }
21902153 }
2191- MaybeLtoModules :: ThinLto {
2192- cgcx,
2193- exported_symbols_for_lto,
2194- each_linked_rlib_file_for_lto,
2195- needs_thin_lto,
2196- } => {
2154+ MaybeLtoModules :: ThinLto { cgcx, needs_thin_lto } => {
21972155 let tm_factory = self . backend . target_machine_factory (
21982156 sess,
21992157 cgcx. opt_level ,
@@ -2206,8 +2164,8 @@ impl<B: WriteBackendMethods> OngoingCodegen<B> {
22062164 & sess. prof ,
22072165 shared_emitter,
22082166 tm_factory,
2209- exported_symbols_for_lto,
2210- each_linked_rlib_file_for_lto,
2167+ & crate_info . exported_symbols_for_lto ,
2168+ & crate_info . each_linked_rlib_file_for_lto ,
22112169 needs_thin_lto,
22122170 ) ,
22132171 allocator_module : None ,
0 commit comments