@@ -7,12 +7,13 @@ use std::sync::Arc;
77
88use rustc_codegen_ssa:: back:: metadata:: create_compressed_metadata_file;
99use rustc_codegen_ssa:: { CodegenResults , CompiledModule , CrateInfo , ModuleKind } ;
10+ use rustc_data_structures:: profiling:: SelfProfilerRef ;
1011use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1112use rustc_metadata:: EncodedMetadata ;
1213use rustc_middle:: dep_graph:: { WorkProduct , WorkProductId } ;
1314use rustc_middle:: mir:: mono:: { CodegenUnit , MonoItem } ;
1415use rustc_session:: cgu_reuse_tracker:: CguReuse ;
15- use rustc_session:: config:: { DebugInfo , OutputType } ;
16+ use rustc_session:: config:: { DebugInfo , OutputFilenames , OutputType } ;
1617use rustc_session:: Session ;
1718
1819use cranelift_object:: { ObjectBuilder , ObjectModule } ;
@@ -115,7 +116,8 @@ fn make_module(sess: &Session, backend_config: &BackendConfig, name: String) ->
115116}
116117
117118fn emit_cgu (
118- tcx : TyCtxt < ' _ > ,
119+ output_filenames : & OutputFilenames ,
120+ prof : & SelfProfilerRef ,
119121 name : String ,
120122 module : ObjectModule ,
121123 debug : Option < DebugContext < ' _ > > ,
@@ -130,7 +132,8 @@ fn emit_cgu(
130132
131133 unwind_context. emit ( & mut product) ;
132134
133- let module_regular = emit_module ( tcx, product. object , ModuleKind :: Regular , name. clone ( ) ) ?;
135+ let module_regular =
136+ emit_module ( output_filenames, prof, product. object , ModuleKind :: Regular , name. clone ( ) ) ?;
134137
135138 Ok ( ModuleCodegenResult {
136139 module_regular,
@@ -146,12 +149,13 @@ fn emit_cgu(
146149}
147150
148151fn emit_module (
149- tcx : TyCtxt < ' _ > ,
152+ output_filenames : & OutputFilenames ,
153+ prof : & SelfProfilerRef ,
150154 object : cranelift_object:: object:: write:: Object < ' _ > ,
151155 kind : ModuleKind ,
152156 name : String ,
153157) -> Result < CompiledModule , String > {
154- let tmp_file = tcx . output_filenames ( ( ) ) . temp_path ( OutputType :: Object , Some ( & name) ) ;
158+ let tmp_file = output_filenames. temp_path ( OutputType :: Object , Some ( & name) ) ;
155159 let mut file = match File :: create ( & tmp_file) {
156160 Ok ( file) => file,
157161 Err ( err) => return Err ( format ! ( "error creating object file: {}" , err) ) ,
@@ -161,7 +165,7 @@ fn emit_module(
161165 return Err ( format ! ( "error writing object file: {}" , err) ) ;
162166 }
163167
164- tcx . sess . prof . artifact_size ( "object_file" , & * name, file. metadata ( ) . unwrap ( ) . len ( ) ) ;
168+ prof. artifact_size ( "object_file" , & * name, file. metadata ( ) . unwrap ( ) . len ( ) ) ;
165169
166170 Ok ( CompiledModule { name, kind, object : Some ( tmp_file) , dwarf_object : None , bytecode : None } )
167171}
@@ -288,7 +292,8 @@ fn module_codegen(
288292 let unwind_context = cx. unwind_context ;
289293 tcx. sess . time ( "write object file" , || {
290294 emit_cgu (
291- tcx,
295+ & global_asm_config. output_filenames ,
296+ & tcx. sess . prof ,
292297 cgu. name ( ) . as_str ( ) . to_string ( ) ,
293298 module,
294299 debug_context,
@@ -361,7 +366,13 @@ pub(crate) fn run_aot(
361366 let mut product = allocator_module. finish ( ) ;
362367 allocator_unwind_context. emit ( & mut product) ;
363368
364- match emit_module ( tcx, product. object , ModuleKind :: Allocator , "allocator_shim" . to_owned ( ) ) {
369+ match emit_module (
370+ tcx. output_filenames ( ( ) ) ,
371+ & tcx. sess . prof ,
372+ product. object ,
373+ ModuleKind :: Allocator ,
374+ "allocator_shim" . to_owned ( ) ,
375+ ) {
365376 Ok ( allocator_module) => Some ( allocator_module) ,
366377 Err ( err) => tcx. sess . fatal ( err) ,
367378 }
0 commit comments