@@ -120,13 +120,17 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
120120 tcx. sess . split_debuginfo ( ) ,
121121 tcx. sess . opts . unstable_opts . split_dwarf_kind ,
122122 mod_name,
123+ tcx. sess . invocation_temp . as_deref ( ) ,
123124 )
124125 } else {
125126 None
126127 } ;
127128
128- let output_obj_file =
129- Some ( tcx. output_filenames ( ( ) ) . temp_path_for_cgu ( OutputType :: Object , mod_name) ) ;
129+ let output_obj_file = Some ( tcx. output_filenames ( ( ) ) . temp_path_for_cgu (
130+ OutputType :: Object ,
131+ mod_name,
132+ tcx. sess . invocation_temp . as_deref ( ) ,
133+ ) ) ;
130134 let config = TargetMachineFactoryConfig { split_dwarf_file, output_obj_file } ;
131135
132136 target_machine_factory (
@@ -330,7 +334,11 @@ pub(crate) fn save_temp_bitcode(
330334 return ;
331335 }
332336 let ext = format ! ( "{name}.bc" ) ;
333- let path = cgcx. output_filenames . temp_path_ext_for_cgu ( & ext, & module. name ) ;
337+ let path = cgcx. output_filenames . temp_path_ext_for_cgu (
338+ & ext,
339+ & module. name ,
340+ cgcx. invocation_temp . as_deref ( ) ,
341+ ) ;
334342 write_bitcode_to_file ( module, & path)
335343}
336344
@@ -697,7 +705,11 @@ pub(crate) unsafe fn optimize(
697705 let _handlers = DiagnosticHandlers :: new ( cgcx, dcx, llcx, module, CodegenDiagnosticsStage :: Opt ) ;
698706
699707 if config. emit_no_opt_bc {
700- let out = cgcx. output_filenames . temp_path_ext_for_cgu ( "no-opt.bc" , & module. name ) ;
708+ let out = cgcx. output_filenames . temp_path_ext_for_cgu (
709+ "no-opt.bc" ,
710+ & module. name ,
711+ cgcx. invocation_temp . as_deref ( ) ,
712+ ) ;
701713 write_bitcode_to_file ( module, & out)
702714 }
703715
@@ -742,8 +754,11 @@ pub(crate) unsafe fn optimize(
742754 if let Some ( thin_lto_buffer) = thin_lto_buffer {
743755 let thin_lto_buffer = unsafe { ThinBuffer :: from_raw_ptr ( thin_lto_buffer) } ;
744756 module. thin_lto_buffer = Some ( thin_lto_buffer. data ( ) . to_vec ( ) ) ;
745- let bc_summary_out =
746- cgcx. output_filenames . temp_path_for_cgu ( OutputType :: ThinLinkBitcode , & module. name ) ;
757+ let bc_summary_out = cgcx. output_filenames . temp_path_for_cgu (
758+ OutputType :: ThinLinkBitcode ,
759+ & module. name ,
760+ cgcx. invocation_temp . as_deref ( ) ,
761+ ) ;
747762 if config. emit_thin_lto_summary
748763 && let Some ( thin_link_bitcode_filename) = bc_summary_out. file_name ( )
749764 {
@@ -811,8 +826,16 @@ pub(crate) unsafe fn codegen(
811826 // copy it to the .o file, and delete the bitcode if it wasn't
812827 // otherwise requested.
813828
814- let bc_out = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Bitcode , & module. name ) ;
815- let obj_out = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Object , & module. name ) ;
829+ let bc_out = cgcx. output_filenames . temp_path_for_cgu (
830+ OutputType :: Bitcode ,
831+ & module. name ,
832+ cgcx. invocation_temp . as_deref ( ) ,
833+ ) ;
834+ let obj_out = cgcx. output_filenames . temp_path_for_cgu (
835+ OutputType :: Object ,
836+ & module. name ,
837+ cgcx. invocation_temp . as_deref ( ) ,
838+ ) ;
816839
817840 if config. bitcode_needed ( ) {
818841 if config. emit_bc || config. emit_obj == EmitObj :: Bitcode {
@@ -854,8 +877,11 @@ pub(crate) unsafe fn codegen(
854877 if config. emit_ir {
855878 let _timer =
856879 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_ir" , & * module. name ) ;
857- let out =
858- cgcx. output_filenames . temp_path_for_cgu ( OutputType :: LlvmAssembly , & module. name ) ;
880+ let out = cgcx. output_filenames . temp_path_for_cgu (
881+ OutputType :: LlvmAssembly ,
882+ & module. name ,
883+ cgcx. invocation_temp . as_deref ( ) ,
884+ ) ;
859885 let out_c = path_to_c_string ( & out) ;
860886
861887 extern "C" fn demangle_callback (
@@ -897,7 +923,11 @@ pub(crate) unsafe fn codegen(
897923 if config. emit_asm {
898924 let _timer =
899925 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_asm" , & * module. name ) ;
900- let path = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Assembly , & module. name ) ;
926+ let path = cgcx. output_filenames . temp_path_for_cgu (
927+ OutputType :: Assembly ,
928+ & module. name ,
929+ cgcx. invocation_temp . as_deref ( ) ,
930+ ) ;
901931
902932 // We can't use the same module for asm and object code output,
903933 // because that triggers various errors like invalid IR or broken
@@ -927,7 +957,9 @@ pub(crate) unsafe fn codegen(
927957 . prof
928958 . generic_activity_with_arg ( "LLVM_module_codegen_emit_obj" , & * module. name ) ;
929959
930- let dwo_out = cgcx. output_filenames . temp_path_dwo_for_cgu ( & module. name ) ;
960+ let dwo_out = cgcx
961+ . output_filenames
962+ . temp_path_dwo_for_cgu ( & module. name , cgcx. invocation_temp . as_deref ( ) ) ;
931963 let dwo_out = match ( cgcx. split_debuginfo , cgcx. split_dwarf_kind ) {
932964 // Don't change how DWARF is emitted when disabled.
933965 ( SplitDebuginfo :: Off , _) => None ,
@@ -992,6 +1024,7 @@ pub(crate) unsafe fn codegen(
9921024 config. emit_asm ,
9931025 config. emit_ir ,
9941026 & cgcx. output_filenames ,
1027+ cgcx. invocation_temp . as_deref ( ) ,
9951028 ) )
9961029}
9971030
0 commit comments