@@ -61,7 +61,7 @@ struct LtoData {
6161 tmp_path : TempDir ,
6262}
6363
64- fn prepare_lto ( cgcx : & CodegenContext < GccCodegenBackend > , diag_handler : & DiagCtxt ) -> Result < LtoData , FatalError > {
64+ fn prepare_lto ( cgcx : & CodegenContext < GccCodegenBackend > , dcx : & DiagCtxt ) -> Result < LtoData , FatalError > {
6565 let export_threshold = match cgcx. lto {
6666 // We're just doing LTO for our one crate
6767 Lto :: ThinLocal => SymbolExportLevel :: Rust ,
@@ -106,18 +106,18 @@ fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt
106106 // Make sure we actually can run LTO
107107 for crate_type in cgcx. crate_types . iter ( ) {
108108 if !crate_type_allows_lto ( * crate_type) {
109- diag_handler . emit_err ( LtoDisallowed ) ;
109+ dcx . emit_err ( LtoDisallowed ) ;
110110 return Err ( FatalError ) ;
111111 } else if * crate_type == CrateType :: Dylib {
112112 if !cgcx. opts . unstable_opts . dylib_lto {
113- diag_handler . emit_err ( LtoDylib ) ;
113+ dcx . emit_err ( LtoDylib ) ;
114114 return Err ( FatalError ) ;
115115 }
116116 }
117117 }
118118
119119 if cgcx. opts . cg . prefer_dynamic && !cgcx. opts . unstable_opts . dylib_lto {
120- diag_handler . emit_err ( DynamicLinkingWithLTO ) ;
120+ dcx . emit_err ( DynamicLinkingWithLTO ) ;
121121 return Err ( FatalError ) ;
122122 }
123123
@@ -154,7 +154,7 @@ fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt
154154 upstream_modules. push ( ( module, CString :: new ( name) . unwrap ( ) ) ) ;
155155 }
156156 Err ( e) => {
157- diag_handler . emit_err ( e) ;
157+ dcx . emit_err ( e) ;
158158 return Err ( FatalError ) ;
159159 }
160160 }
@@ -183,16 +183,16 @@ pub(crate) fn run_fat(
183183 modules : Vec < FatLtoInput < GccCodegenBackend > > ,
184184 cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
185185) -> Result < LtoModuleCodegen < GccCodegenBackend > , FatalError > {
186- let diag_handler = cgcx. create_dcx ( ) ;
187- let lto_data = prepare_lto ( cgcx, & diag_handler ) ?;
186+ let dcx = cgcx. create_dcx ( ) ;
187+ let lto_data = prepare_lto ( cgcx, & dcx ) ?;
188188 /*let symbols_below_threshold =
189189 lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
190- fat_lto ( cgcx, & diag_handler , modules, cached_modules, lto_data. upstream_modules , lto_data. tmp_path ,
190+ fat_lto ( cgcx, & dcx , modules, cached_modules, lto_data. upstream_modules , lto_data. tmp_path ,
191191 //&symbols_below_threshold,
192192 )
193193}
194194
195- fn fat_lto ( cgcx : & CodegenContext < GccCodegenBackend > , _diag_handler : & DiagCtxt , modules : Vec < FatLtoInput < GccCodegenBackend > > , cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > , mut serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > , tmp_path : TempDir ,
195+ fn fat_lto ( cgcx : & CodegenContext < GccCodegenBackend > , _dcx : & DiagCtxt , modules : Vec < FatLtoInput < GccCodegenBackend > > , cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > , mut serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > , tmp_path : TempDir ,
196196 //symbols_below_threshold: &[*const libc::c_char],
197197) -> Result < LtoModuleCodegen < GccCodegenBackend > , FatalError > {
198198 let _timer = cgcx. prof . generic_activity ( "GCC_fat_lto_build_monolithic_module" ) ;
@@ -257,7 +257,7 @@ fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &DiagCtxt, m
257257 let (buffer, name) = serialized_modules.remove(0);
258258 info!("no in-memory regular modules to choose from, parsing {:?}", name);
259259 ModuleCodegen {
260- module_llvm: GccContext::parse(cgcx, &name, buffer.data(), diag_handler )?,
260+ module_llvm: GccContext::parse(cgcx, &name, buffer.data(), dcx )?,
261261 name: name.into_string().unwrap(),
262262 kind: ModuleKind::Regular,
263263 }*/
0 commit comments