@@ -26,11 +26,11 @@ use std::sync::atomic::Ordering;
2626use gccjit:: { Context , OutputKind } ;
2727use object:: read:: archive:: ArchiveFile ;
2828use rustc_codegen_ssa:: back:: lto:: { SerializedModule , ThinModule , ThinShared } ;
29- use rustc_codegen_ssa:: back:: write:: { CodegenContext , FatLtoInput } ;
29+ use rustc_codegen_ssa:: back:: write:: { CodegenContext , FatLtoInput , SharedEmitter } ;
3030use rustc_codegen_ssa:: traits:: * ;
3131use rustc_codegen_ssa:: { ModuleCodegen , ModuleKind , looks_like_rust_object_file} ;
3232use rustc_data_structures:: memmap:: Mmap ;
33- use rustc_errors:: DiagCtxtHandle ;
33+ use rustc_errors:: { DiagCtxt , DiagCtxtHandle } ;
3434use rustc_log:: tracing:: info;
3535use rustc_middle:: bug;
3636use rustc_middle:: dep_graph:: WorkProduct ;
@@ -112,10 +112,11 @@ fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
112112/// for further optimization.
113113pub ( crate ) fn run_fat (
114114 cgcx : & CodegenContext < GccCodegenBackend > ,
115+ shared_emitter : & SharedEmitter ,
115116 each_linked_rlib_for_lto : & [ PathBuf ] ,
116117 modules : Vec < FatLtoInput < GccCodegenBackend > > ,
117118) -> ModuleCodegen < GccContext > {
118- let dcx = cgcx . create_dcx ( ) ;
119+ let dcx = DiagCtxt :: new ( Box :: new ( shared_emitter . clone ( ) ) ) ;
119120 let dcx = dcx. handle ( ) ;
120121 let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ;
121122 /*let symbols_below_threshold =
@@ -283,14 +284,13 @@ impl ModuleBufferMethods for ModuleBuffer {
283284/// can simply be copied over from the incr. comp. cache.
284285pub ( crate ) fn run_thin (
285286 cgcx : & CodegenContext < GccCodegenBackend > ,
287+ dcx : DiagCtxtHandle < ' _ > ,
286288 each_linked_rlib_for_lto : & [ PathBuf ] ,
287289 modules : Vec < ( String , ThinBuffer ) > ,
288290 cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
289291) -> ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) {
290- let dcx = cgcx. create_dcx ( ) ;
291- let dcx = dcx. handle ( ) ;
292292 let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ;
293- if cgcx. opts . cg . linker_plugin_lto . enabled ( ) {
293+ if cgcx. use_linker_plugin_lto {
294294 unreachable ! (
295295 "We should never reach this case if the LTO step \
296296 is deferred to the linker"
@@ -522,8 +522,6 @@ pub fn optimize_thin_module(
522522 thin_module : ThinModule < GccCodegenBackend > ,
523523 _cgcx : & CodegenContext < GccCodegenBackend > ,
524524) -> ModuleCodegen < GccContext > {
525- //let dcx = cgcx.create_dcx();
526-
527525 //let module_name = &thin_module.shared.module_names[thin_module.idx];
528526 /*let tm_factory_config = TargetMachineFactoryConfig::new(cgcx, module_name.to_str().unwrap());
529527 let tm = (cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(&dcx, e))?;*/
0 commit comments