@@ -7,12 +7,13 @@ use std::sync::Arc;
7
7
8
8
use rustc_codegen_ssa:: back:: metadata:: create_compressed_metadata_file;
9
9
use rustc_codegen_ssa:: { CodegenResults , CompiledModule , CrateInfo , ModuleKind } ;
10
+ use rustc_data_structures:: profiling:: SelfProfilerRef ;
10
11
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
11
12
use rustc_metadata:: EncodedMetadata ;
12
13
use rustc_middle:: dep_graph:: { WorkProduct , WorkProductId } ;
13
14
use rustc_middle:: mir:: mono:: { CodegenUnit , MonoItem } ;
14
15
use rustc_session:: cgu_reuse_tracker:: CguReuse ;
15
- use rustc_session:: config:: { DebugInfo , OutputType } ;
16
+ use rustc_session:: config:: { DebugInfo , OutputFilenames , OutputType } ;
16
17
use rustc_session:: Session ;
17
18
18
19
use cranelift_object:: { ObjectBuilder , ObjectModule } ;
@@ -115,7 +116,8 @@ fn make_module(sess: &Session, backend_config: &BackendConfig, name: String) ->
115
116
}
116
117
117
118
fn emit_cgu (
118
- tcx : TyCtxt < ' _ > ,
119
+ output_filenames : & OutputFilenames ,
120
+ prof : & SelfProfilerRef ,
119
121
name : String ,
120
122
module : ObjectModule ,
121
123
debug : Option < DebugContext < ' _ > > ,
@@ -130,7 +132,8 @@ fn emit_cgu(
130
132
131
133
unwind_context. emit ( & mut product) ;
132
134
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 ( ) ) ?;
134
137
135
138
Ok ( ModuleCodegenResult {
136
139
module_regular,
@@ -146,12 +149,13 @@ fn emit_cgu(
146
149
}
147
150
148
151
fn emit_module (
149
- tcx : TyCtxt < ' _ > ,
152
+ output_filenames : & OutputFilenames ,
153
+ prof : & SelfProfilerRef ,
150
154
object : cranelift_object:: object:: write:: Object < ' _ > ,
151
155
kind : ModuleKind ,
152
156
name : String ,
153
157
) -> 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) ) ;
155
159
let mut file = match File :: create ( & tmp_file) {
156
160
Ok ( file) => file,
157
161
Err ( err) => return Err ( format ! ( "error creating object file: {}" , err) ) ,
@@ -161,7 +165,7 @@ fn emit_module(
161
165
return Err ( format ! ( "error writing object file: {}" , err) ) ;
162
166
}
163
167
164
- tcx . sess . prof . artifact_size ( "object_file" , & * name, file. metadata ( ) . unwrap ( ) . len ( ) ) ;
168
+ prof. artifact_size ( "object_file" , & * name, file. metadata ( ) . unwrap ( ) . len ( ) ) ;
165
169
166
170
Ok ( CompiledModule { name, kind, object : Some ( tmp_file) , dwarf_object : None , bytecode : None } )
167
171
}
@@ -288,7 +292,8 @@ fn module_codegen(
288
292
let unwind_context = cx. unwind_context ;
289
293
tcx. sess . time ( "write object file" , || {
290
294
emit_cgu (
291
- tcx,
295
+ & global_asm_config. output_filenames ,
296
+ & tcx. sess . prof ,
292
297
cgu. name ( ) . as_str ( ) . to_string ( ) ,
293
298
module,
294
299
debug_context,
@@ -361,7 +366,13 @@ pub(crate) fn run_aot(
361
366
let mut product = allocator_module. finish ( ) ;
362
367
allocator_unwind_context. emit ( & mut product) ;
363
368
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
+ ) {
365
376
Ok ( allocator_module) => Some ( allocator_module) ,
366
377
Err ( err) => tcx. sess . fatal ( err) ,
367
378
}
0 commit comments