@@ -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
@@ -694,7 +702,11 @@ pub(crate) unsafe fn optimize(
694702 let _handlers = DiagnosticHandlers :: new ( cgcx, dcx, llcx, module, CodegenDiagnosticsStage :: Opt ) ;
695703
696704 if config. emit_no_opt_bc {
697- let out = cgcx. output_filenames . temp_path_ext_for_cgu ( "no-opt.bc" , & module. name ) ;
705+ let out = cgcx. output_filenames . temp_path_ext_for_cgu (
706+ "no-opt.bc" ,
707+ & module. name ,
708+ cgcx. invocation_temp . as_deref ( ) ,
709+ ) ;
698710 write_bitcode_to_file ( module, & out)
699711 }
700712
@@ -739,8 +751,11 @@ pub(crate) unsafe fn optimize(
739751 if let Some ( thin_lto_buffer) = thin_lto_buffer {
740752 let thin_lto_buffer = unsafe { ThinBuffer :: from_raw_ptr ( thin_lto_buffer) } ;
741753 module. thin_lto_buffer = Some ( thin_lto_buffer. data ( ) . to_vec ( ) ) ;
742- let bc_summary_out =
743- cgcx. output_filenames . temp_path_for_cgu ( OutputType :: ThinLinkBitcode , & module. name ) ;
754+ let bc_summary_out = cgcx. output_filenames . temp_path_for_cgu (
755+ OutputType :: ThinLinkBitcode ,
756+ & module. name ,
757+ cgcx. invocation_temp . as_deref ( ) ,
758+ ) ;
744759 if config. emit_thin_lto_summary
745760 && let Some ( thin_link_bitcode_filename) = bc_summary_out. file_name ( )
746761 {
@@ -808,8 +823,16 @@ pub(crate) unsafe fn codegen(
808823 // copy it to the .o file, and delete the bitcode if it wasn't
809824 // otherwise requested.
810825
811- let bc_out = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Bitcode , & module. name ) ;
812- let obj_out = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Object , & module. name ) ;
826+ let bc_out = cgcx. output_filenames . temp_path_for_cgu (
827+ OutputType :: Bitcode ,
828+ & module. name ,
829+ cgcx. invocation_temp . as_deref ( ) ,
830+ ) ;
831+ let obj_out = cgcx. output_filenames . temp_path_for_cgu (
832+ OutputType :: Object ,
833+ & module. name ,
834+ cgcx. invocation_temp . as_deref ( ) ,
835+ ) ;
813836
814837 if config. bitcode_needed ( ) {
815838 if config. emit_bc || config. emit_obj == EmitObj :: Bitcode {
@@ -851,8 +874,11 @@ pub(crate) unsafe fn codegen(
851874 if config. emit_ir {
852875 let _timer =
853876 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_ir" , & * module. name ) ;
854- let out =
855- cgcx. output_filenames . temp_path_for_cgu ( OutputType :: LlvmAssembly , & module. name ) ;
877+ let out = cgcx. output_filenames . temp_path_for_cgu (
878+ OutputType :: LlvmAssembly ,
879+ & module. name ,
880+ cgcx. invocation_temp . as_deref ( ) ,
881+ ) ;
856882 let out_c = path_to_c_string ( & out) ;
857883
858884 extern "C" fn demangle_callback (
@@ -894,7 +920,11 @@ pub(crate) unsafe fn codegen(
894920 if config. emit_asm {
895921 let _timer =
896922 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_asm" , & * module. name ) ;
897- let path = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Assembly , & module. name ) ;
923+ let path = cgcx. output_filenames . temp_path_for_cgu (
924+ OutputType :: Assembly ,
925+ & module. name ,
926+ cgcx. invocation_temp . as_deref ( ) ,
927+ ) ;
898928
899929 // We can't use the same module for asm and object code output,
900930 // because that triggers various errors like invalid IR or broken
@@ -924,7 +954,9 @@ pub(crate) unsafe fn codegen(
924954 . prof
925955 . generic_activity_with_arg ( "LLVM_module_codegen_emit_obj" , & * module. name ) ;
926956
927- let dwo_out = cgcx. output_filenames . temp_path_dwo_for_cgu ( & module. name ) ;
957+ let dwo_out = cgcx
958+ . output_filenames
959+ . temp_path_dwo_for_cgu ( & module. name , cgcx. invocation_temp . as_deref ( ) ) ;
928960 let dwo_out = match ( cgcx. split_debuginfo , cgcx. split_dwarf_kind ) {
929961 // Don't change how DWARF is emitted when disabled.
930962 ( SplitDebuginfo :: Off , _) => None ,
@@ -989,6 +1021,7 @@ pub(crate) unsafe fn codegen(
9891021 config. emit_asm ,
9901022 config. emit_ir ,
9911023 & cgcx. output_filenames ,
1024+ cgcx. invocation_temp . as_deref ( ) ,
9921025 ) )
9931026}
9941027
0 commit comments