@@ -27,16 +27,10 @@ use {ModuleCodegen, ModuleLlvm, ModuleKind, ModuleSource};
2727use libc;
2828
2929use std:: ffi:: { CString , CStr } ;
30- use std:: fs:: File ;
31- use std:: io;
32- use std:: mem;
33- use std:: path:: Path ;
3430use std:: ptr;
3531use std:: slice;
3632use std:: sync:: Arc ;
3733
38- pub const THIN_LTO_IMPORTS_INCR_COMP_FILE_NAME : & str = "thin-lto-imports.bin" ;
39-
4034pub fn crate_type_allows_lto ( crate_type : config:: CrateType ) -> bool {
4135 match crate_type {
4236 config:: CrateTypeExecutable |
@@ -200,7 +194,7 @@ pub(crate) fn run(cgcx: &CodegenContext,
200194 }
201195 Lto :: Thin |
202196 Lto :: ThinLocal => {
203- thin_lto ( cgcx , & diag_handler, modules, upstream_modules, & arr, timeline)
197+ thin_lto ( & diag_handler, modules, upstream_modules, & arr, timeline)
204198 }
205199 Lto :: No => unreachable ! ( ) ,
206200 }
@@ -353,8 +347,7 @@ impl Drop for Linker {
353347/// calculating the *index* for ThinLTO. This index will then be shared amongst
354348/// all of the `LtoModuleCodegen` units returned below and destroyed once
355349/// they all go out of scope.
356- fn thin_lto ( cgcx : & CodegenContext ,
357- diag_handler : & Handler ,
350+ fn thin_lto ( diag_handler : & Handler ,
358351 modules : Vec < ModuleCodegen > ,
359352 serialized_modules : Vec < ( SerializedModule , CString ) > ,
360353 symbol_white_list : & [ * const libc:: c_char ] ,
@@ -432,18 +425,6 @@ fn thin_lto(cgcx: &CodegenContext,
432425 let msg = format ! ( "failed to prepare thin LTO context" ) ;
433426 return Err ( write:: llvm_err ( & diag_handler, msg) )
434427 }
435-
436- // Save the ThinLTO import information for incremental compilation.
437- if let Some ( ref incr_comp_session_dir) = cgcx. incr_comp_session_dir {
438- let path = incr_comp_session_dir. join ( THIN_LTO_IMPORTS_INCR_COMP_FILE_NAME ) ;
439- let imports = ThinLTOImports :: from_thin_lto_data ( data) ;
440- if let Err ( err) = imports. save_to_file ( & path) {
441- let msg = format ! ( "Error while writing ThinLTO import data: {}" ,
442- err) ;
443- return Err ( write:: llvm_err ( & diag_handler, msg) ) ;
444- }
445- }
446-
447428 let data = ThinData ( data) ;
448429 info ! ( "thin LTO data created" ) ;
449430 timeline. record ( "data" ) ;
@@ -806,12 +787,6 @@ pub struct ThinLTOImports {
806787
807788impl ThinLTOImports {
808789
809- pub fn new_empty ( ) -> ThinLTOImports {
810- ThinLTOImports {
811- imports : FxHashMap ( ) ,
812- }
813- }
814-
815790 /// Load the ThinLTO import map from ThinLTOData.
816791 unsafe fn from_thin_lto_data ( data : * const llvm:: ThinLTOData ) -> ThinLTOImports {
817792 let raw_data: * const llvm:: ThinLTOModuleImports =
@@ -867,58 +842,4 @@ impl ThinLTOImports {
867842 imports
868843 }
869844 }
870-
871- pub fn save_to_file ( & self , path : & Path ) -> io:: Result < ( ) > {
872- use std:: io:: Write ;
873-
874- let file = File :: create ( path) ?;
875- let mut writer = io:: BufWriter :: new ( file) ;
876-
877- for ( importing_module_name, imported_modules) in & self . imports {
878- writeln ! ( writer, "{}" , importing_module_name) ?;
879-
880- for imported_module in imported_modules {
881- writeln ! ( writer, " {}" , imported_module) ?;
882- }
883-
884- writeln ! ( writer) ?;
885- }
886-
887- Ok ( ( ) )
888- }
889-
890- pub fn load_from_file ( path : & Path ) -> io:: Result < ThinLTOImports > {
891- use std:: io:: BufRead ;
892-
893- let mut imports = FxHashMap ( ) ;
894- let mut current_module = None ;
895- let mut current_imports = vec ! [ ] ;
896-
897- let file = File :: open ( path) ?;
898-
899- for line in io:: BufReader :: new ( file) . lines ( ) {
900- let line = line?;
901-
902- if line. is_empty ( ) {
903- let importing_module = current_module
904- . take ( )
905- . expect ( "Importing module not set" ) ;
906-
907- imports. insert ( importing_module,
908- mem:: replace ( & mut current_imports, vec ! [ ] ) ) ;
909- } else if line. starts_with ( " " ) {
910- // This is an imported module
911- assert_ne ! ( current_module, None ) ;
912- current_imports. push ( line. trim ( ) . to_string ( ) ) ;
913- } else {
914- // This is the beginning of a new module
915- assert_eq ! ( current_module, None ) ;
916- current_module = Some ( line. trim ( ) . to_string ( ) ) ;
917- }
918- }
919-
920- Ok ( ThinLTOImports {
921- imports
922- } )
923- }
924845}
0 commit comments