@@ -169,8 +169,11 @@ fn produce_final_output_artifacts(
169
169
if codegen_results. modules . len ( ) == 1 {
170
170
// 1) Only one codegen unit. In this case it's no difficulty
171
171
// to copy `foo.0.x` to `foo.x`.
172
- let path =
173
- crate_output. temp_path_for_cgu ( output_type, & codegen_results. modules [ 0 ] . name ) ;
172
+ let path = crate_output. temp_path_for_cgu (
173
+ output_type,
174
+ & codegen_results. modules [ 0 ] . name ,
175
+ sess. invocation_temp . as_deref ( ) ,
176
+ ) ;
174
177
let output = crate_output. path ( output_type) ;
175
178
if !output_type. is_text_output ( ) && output. is_tty ( ) {
176
179
sess. dcx ( )
@@ -345,6 +348,7 @@ fn make_module(sess: &Session, name: String) -> UnwindModule<ObjectModule> {
345
348
346
349
fn emit_cgu (
347
350
output_filenames : & OutputFilenames ,
351
+ invocation_temp : Option < & str > ,
348
352
prof : & SelfProfilerRef ,
349
353
name : String ,
350
354
module : UnwindModule < ObjectModule > ,
@@ -360,6 +364,7 @@ fn emit_cgu(
360
364
361
365
let module_regular = emit_module (
362
366
output_filenames,
367
+ invocation_temp,
363
368
prof,
364
369
product. object ,
365
370
ModuleKind :: Regular ,
@@ -385,6 +390,7 @@ fn emit_cgu(
385
390
386
391
fn emit_module (
387
392
output_filenames : & OutputFilenames ,
393
+ invocation_temp : Option < & str > ,
388
394
prof : & SelfProfilerRef ,
389
395
mut object : cranelift_object:: object:: write:: Object < ' _ > ,
390
396
kind : ModuleKind ,
@@ -403,7 +409,7 @@ fn emit_module(
403
409
object. set_section_data ( comment_section, producer, 1 ) ;
404
410
}
405
411
406
- let tmp_file = output_filenames. temp_path_for_cgu ( OutputType :: Object , & name) ;
412
+ let tmp_file = output_filenames. temp_path_for_cgu ( OutputType :: Object , & name, invocation_temp ) ;
407
413
let file = match File :: create ( & tmp_file) {
408
414
Ok ( file) => file,
409
415
Err ( err) => return Err ( format ! ( "error creating object file: {}" , err) ) ,
@@ -443,8 +449,11 @@ fn reuse_workproduct_for_cgu(
443
449
cgu : & CodegenUnit < ' _ > ,
444
450
) -> Result < ModuleCodegenResult , String > {
445
451
let work_product = cgu. previous_work_product ( tcx) ;
446
- let obj_out_regular =
447
- tcx. output_filenames ( ( ) ) . temp_path_for_cgu ( OutputType :: Object , cgu. name ( ) . as_str ( ) ) ;
452
+ let obj_out_regular = tcx. output_filenames ( ( ) ) . temp_path_for_cgu (
453
+ OutputType :: Object ,
454
+ cgu. name ( ) . as_str ( ) ,
455
+ tcx. sess . invocation_temp . as_deref ( ) ,
456
+ ) ;
448
457
let source_file_regular = rustc_incremental:: in_incr_comp_dir_sess (
449
458
& tcx. sess ,
450
459
& work_product. saved_files . get ( "o" ) . expect ( "no saved object file in work product" ) ,
@@ -589,13 +598,19 @@ fn module_codegen(
589
598
590
599
let global_asm_object_file =
591
600
profiler. generic_activity_with_arg ( "compile assembly" , & * cgu_name) . run ( || {
592
- crate :: global_asm:: compile_global_asm ( & global_asm_config, & cgu_name, & cx. global_asm )
601
+ crate :: global_asm:: compile_global_asm (
602
+ & global_asm_config,
603
+ & cgu_name,
604
+ & cx. global_asm ,
605
+ cx. invocation_temp . as_deref ( ) ,
606
+ )
593
607
} ) ?;
594
608
595
609
let codegen_result =
596
610
profiler. generic_activity_with_arg ( "write object file" , & * cgu_name) . run ( || {
597
611
emit_cgu (
598
612
& global_asm_config. output_filenames ,
613
+ cx. invocation_temp . as_deref ( ) ,
599
614
& profiler,
600
615
cgu_name,
601
616
module,
@@ -620,8 +635,11 @@ fn emit_metadata_module(tcx: TyCtxt<'_>, metadata: &EncodedMetadata) -> Compiled
620
635
. as_str ( )
621
636
. to_string ( ) ;
622
637
623
- let tmp_file =
624
- tcx. output_filenames ( ( ) ) . temp_path_for_cgu ( OutputType :: Metadata , & metadata_cgu_name) ;
638
+ let tmp_file = tcx. output_filenames ( ( ) ) . temp_path_for_cgu (
639
+ OutputType :: Metadata ,
640
+ & metadata_cgu_name,
641
+ tcx. sess . invocation_temp . as_deref ( ) ,
642
+ ) ;
625
643
626
644
let symbol_name = rustc_middle:: middle:: exported_symbols:: metadata_symbol_name ( tcx) ;
627
645
let obj = create_compressed_metadata_file ( tcx. sess , metadata, & symbol_name) ;
@@ -651,6 +669,7 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
651
669
652
670
match emit_module (
653
671
tcx. output_filenames ( ( ) ) ,
672
+ tcx. sess . invocation_temp . as_deref ( ) ,
654
673
& tcx. sess . prof ,
655
674
product. object ,
656
675
ModuleKind :: Allocator ,
0 commit comments