@@ -8,7 +8,6 @@ use std::{assert_matches, fs, io, mem, str, thread};
88use rustc_abi:: Size ;
99use rustc_data_structures:: fx:: FxIndexMap ;
1010use rustc_data_structures:: jobserver:: { self , Acquired } ;
11- use rustc_data_structures:: memmap:: Mmap ;
1211use rustc_data_structures:: profiling:: { SelfProfilerRef , VerboseTimingGuard } ;
1312use rustc_errors:: emitter:: Emitter ;
1413use rustc_errors:: {
@@ -35,9 +34,8 @@ use rustc_span::{FileName, InnerSpan, Span, SpanData};
3534use rustc_target:: spec:: { MergeFunctions , SanitizerSet } ;
3635use tracing:: debug;
3736
38- use super :: link:: { self , ensure_removed} ;
39- use super :: lto:: { self , SerializedModule } ;
40- use crate :: back:: lto:: check_lto_allowed;
37+ use crate :: back:: link:: { self , ensure_removed} ;
38+ use crate :: back:: lto:: { self , SerializedModule , check_lto_allowed} ;
4139use crate :: errors:: ErrorCreatingRemarkDir ;
4240use crate :: traits:: * ;
4341use crate :: {
@@ -774,13 +772,13 @@ pub(crate) enum WorkItemResult<B: WriteBackendMethods> {
774772}
775773
776774pub enum FatLtoInput < B : WriteBackendMethods > {
777- Serialized { name : String , buffer : SerializedModule < B :: ModuleBuffer > } ,
775+ Serialized { name : String , bitcode_path : PathBuf } ,
778776 InMemory ( ModuleCodegen < B :: Module > ) ,
779777}
780778
781779pub enum ThinLtoInput < B : WriteBackendMethods > {
782780 Red { name : String , buffer : SerializedModule < B :: ModuleBuffer > } ,
783- Green { wp : WorkProduct , buffer : SerializedModule < B :: ModuleBuffer > } ,
781+ Green { wp : WorkProduct , bitcode_path : PathBuf } ,
784782}
785783
786784/// Actual LTO type we end up choosing based on multiple factors.
@@ -866,7 +864,7 @@ fn execute_optimize_work_item<B: WriteBackendMethods>(
866864 } ) ;
867865 WorkItemResult :: NeedsFatLto ( FatLtoInput :: Serialized {
868866 name : module. name ,
869- buffer : SerializedModule :: Local ( buffer ) ,
867+ bitcode_path : path ,
870868 } )
871869 }
872870 None => WorkItemResult :: NeedsFatLto ( FatLtoInput :: InMemory ( module) ) ,
@@ -1166,10 +1164,7 @@ pub(crate) enum Message<B: WriteBackendMethods> {
11661164
11671165 /// Similar to `CodegenDone`, but for reusing a pre-LTO artifact
11681166 /// Sent from the main thread.
1169- AddImportOnlyModule {
1170- module_data : SerializedModule < B :: ModuleBuffer > ,
1171- work_product : WorkProduct ,
1172- } ,
1167+ AddImportOnlyModule { bitcode_path : PathBuf , work_product : WorkProduct } ,
11731168
11741169 /// The frontend has finished generating everything for all codegen units.
11751170 /// Sent from the main thread.
@@ -1729,10 +1724,10 @@ fn start_executing_work<B: ExtraBackendMethods>(
17291724 }
17301725 }
17311726
1732- Message :: AddImportOnlyModule { module_data , work_product } => {
1727+ Message :: AddImportOnlyModule { bitcode_path , work_product } => {
17331728 assert_eq ! ( codegen_state, Ongoing ) ;
17341729 assert_eq ! ( main_thread_state, MainThreadState :: Codegenning ) ;
1735- lto_import_only_modules. push ( ( module_data , work_product) ) ;
1730+ lto_import_only_modules. push ( ( bitcode_path , work_product) ) ;
17361731 main_thread_state = MainThreadState :: Idle ;
17371732 }
17381733 }
@@ -1758,8 +1753,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
17581753 needs_fat_lto. push ( FatLtoInput :: InMemory ( allocator_module) ) ;
17591754 }
17601755
1761- for ( module , wp) in lto_import_only_modules {
1762- needs_fat_lto. push ( FatLtoInput :: Serialized { name : wp. cgu_name , buffer : module } )
1756+ for ( bitcode_path , wp) in lto_import_only_modules {
1757+ needs_fat_lto. push ( FatLtoInput :: Serialized { name : wp. cgu_name , bitcode_path } )
17631758 }
17641759
17651760 return Ok ( MaybeLtoModules :: FatLto {
@@ -1772,8 +1767,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
17721767 assert ! ( compiled_modules. is_empty( ) ) ;
17731768 assert ! ( needs_fat_lto. is_empty( ) ) ;
17741769
1775- for ( buffer , wp) in lto_import_only_modules {
1776- needs_thin_lto. push ( ThinLtoInput :: Green { wp, buffer } )
1770+ for ( bitcode_path , wp) in lto_import_only_modules {
1771+ needs_thin_lto. push ( ThinLtoInput :: Green { wp, bitcode_path } )
17771772 }
17781773
17791774 if cgcx. lto == Lto :: ThinLocal {
@@ -2133,14 +2128,14 @@ impl<B: WriteBackendMethods> Drop for Coordinator<B> {
21332128}
21342129
21352130pub struct OngoingCodegen < B : WriteBackendMethods > {
2136- pub backend : B ,
2137- pub output_filenames : Arc < OutputFilenames > ,
2131+ backend : B ,
2132+ output_filenames : Arc < OutputFilenames > ,
21382133 // Field order below is intended to terminate the coordinator thread before two fields below
21392134 // drop and prematurely close channels used by coordinator thread. See `Coordinator`'s
21402135 // `Drop` implementation for more info.
2141- pub coordinator : Coordinator < B > ,
2142- pub codegen_worker_receive : Receiver < CguMessage > ,
2143- pub shared_emitter_main : SharedEmitterMain ,
2136+ pub ( crate ) coordinator : Coordinator < B > ,
2137+ codegen_worker_receive : Receiver < CguMessage > ,
2138+ shared_emitter_main : SharedEmitterMain ,
21442139}
21452140
21462141impl < B : WriteBackendMethods > OngoingCodegen < B > {
@@ -2285,20 +2280,13 @@ pub(crate) fn submit_pre_lto_module_to_llvm<B: WriteBackendMethods>(
22852280 module : CachedModuleCodegen ,
22862281) {
22872282 let filename = pre_lto_bitcode_filename ( & module. name ) ;
2288- let bc_path = in_incr_comp_dir_sess ( tcx. sess , & filename) ;
2289- let file = fs:: File :: open ( & bc_path)
2290- . unwrap_or_else ( |e| panic ! ( "failed to open bitcode file `{}`: {}" , bc_path. display( ) , e) ) ;
2291-
2292- let mmap = unsafe {
2293- Mmap :: map ( file) . unwrap_or_else ( |e| {
2294- panic ! ( "failed to mmap bitcode file `{}`: {}" , bc_path. display( ) , e)
2295- } )
2296- } ;
2283+ let bitcode_path = in_incr_comp_dir_sess ( tcx. sess , & filename) ;
22972284 // Schedule the module to be loaded
2298- drop ( coordinator. sender . send ( Message :: AddImportOnlyModule :: < B > {
2299- module_data : SerializedModule :: FromUncompressedFile ( mmap) ,
2300- work_product : module. source ,
2301- } ) ) ;
2285+ drop (
2286+ coordinator
2287+ . sender
2288+ . send ( Message :: AddImportOnlyModule :: < B > { bitcode_path, work_product : module. source } ) ,
2289+ ) ;
23022290}
23032291
23042292fn pre_lto_bitcode_filename ( module_name : & str ) -> String {
0 commit comments