@@ -119,14 +119,14 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
119119 tcx. output_filenames ( ( ) ) . split_dwarf_path (
120120 tcx. sess . split_debuginfo ( ) ,
121121 tcx. sess . opts . unstable_opts . split_dwarf_kind ,
122- Some ( mod_name) ,
122+ mod_name,
123123 )
124124 } else {
125125 None
126126 } ;
127127
128128 let output_obj_file =
129- Some ( tcx. output_filenames ( ( ) ) . temp_path ( OutputType :: Object , Some ( mod_name) ) ) ;
129+ Some ( tcx. output_filenames ( ( ) ) . temp_path_for_cgu ( OutputType :: Object , mod_name) ) ;
130130 let config = TargetMachineFactoryConfig { split_dwarf_file, output_obj_file } ;
131131
132132 target_machine_factory (
@@ -330,8 +330,7 @@ pub(crate) fn save_temp_bitcode(
330330 return ;
331331 }
332332 let ext = format ! ( "{name}.bc" ) ;
333- let cgu = Some ( & module. name [ ..] ) ;
334- let path = cgcx. output_filenames . temp_path_ext ( & ext, cgu) ;
333+ let path = cgcx. output_filenames . temp_path_ext_for_cgu ( & ext, & module. name ) ;
335334 write_bitcode_to_file ( module, & path)
336335}
337336
@@ -694,11 +693,8 @@ pub(crate) unsafe fn optimize(
694693 let llcx = & * module. module_llvm . llcx ;
695694 let _handlers = DiagnosticHandlers :: new ( cgcx, dcx, llcx, module, CodegenDiagnosticsStage :: Opt ) ;
696695
697- let module_name = module. name . clone ( ) ;
698- let module_name = Some ( & module_name[ ..] ) ;
699-
700696 if config. emit_no_opt_bc {
701- let out = cgcx. output_filenames . temp_path_ext ( "no-opt.bc" , module_name ) ;
697+ let out = cgcx. output_filenames . temp_path_ext_for_cgu ( "no-opt.bc" , & module . name ) ;
702698 write_bitcode_to_file ( module, & out)
703699 }
704700
@@ -744,7 +740,7 @@ pub(crate) unsafe fn optimize(
744740 let thin_lto_buffer = unsafe { ThinBuffer :: from_raw_ptr ( thin_lto_buffer) } ;
745741 module. thin_lto_buffer = Some ( thin_lto_buffer. data ( ) . to_vec ( ) ) ;
746742 let bc_summary_out =
747- cgcx. output_filenames . temp_path ( OutputType :: ThinLinkBitcode , module_name ) ;
743+ cgcx. output_filenames . temp_path_for_cgu ( OutputType :: ThinLinkBitcode , & module . name ) ;
748744 if config. emit_thin_lto_summary
749745 && let Some ( thin_link_bitcode_filename) = bc_summary_out. file_name ( )
750746 {
@@ -801,8 +797,6 @@ pub(crate) unsafe fn codegen(
801797 let llmod = module. module_llvm . llmod ( ) ;
802798 let llcx = & * module. module_llvm . llcx ;
803799 let tm = & * module. module_llvm . tm ;
804- let module_name = module. name . clone ( ) ;
805- let module_name = Some ( & module_name[ ..] ) ;
806800 let _handlers =
807801 DiagnosticHandlers :: new ( cgcx, dcx, llcx, & module, CodegenDiagnosticsStage :: Codegen ) ;
808802
@@ -814,8 +808,8 @@ pub(crate) unsafe fn codegen(
814808 // copy it to the .o file, and delete the bitcode if it wasn't
815809 // otherwise requested.
816810
817- let bc_out = cgcx. output_filenames . temp_path ( OutputType :: Bitcode , module_name ) ;
818- let obj_out = cgcx. output_filenames . temp_path ( OutputType :: Object , module_name ) ;
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 ) ;
819813
820814 if config. bitcode_needed ( ) {
821815 if config. emit_bc || config. emit_obj == EmitObj :: Bitcode {
@@ -857,7 +851,8 @@ pub(crate) unsafe fn codegen(
857851 if config. emit_ir {
858852 let _timer =
859853 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_ir" , & * module. name ) ;
860- let out = cgcx. output_filenames . temp_path ( OutputType :: LlvmAssembly , module_name) ;
854+ let out =
855+ cgcx. output_filenames . temp_path_for_cgu ( OutputType :: LlvmAssembly , & module. name ) ;
861856 let out_c = path_to_c_string ( & out) ;
862857
863858 extern "C" fn demangle_callback (
@@ -899,7 +894,7 @@ pub(crate) unsafe fn codegen(
899894 if config. emit_asm {
900895 let _timer =
901896 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_asm" , & * module. name ) ;
902- let path = cgcx. output_filenames . temp_path ( OutputType :: Assembly , module_name ) ;
897+ let path = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Assembly , & module . name ) ;
903898
904899 // We can't use the same module for asm and object code output,
905900 // because that triggers various errors like invalid IR or broken
@@ -929,7 +924,7 @@ pub(crate) unsafe fn codegen(
929924 . prof
930925 . generic_activity_with_arg ( "LLVM_module_codegen_emit_obj" , & * module. name ) ;
931926
932- let dwo_out = cgcx. output_filenames . temp_path_dwo ( module_name ) ;
927+ let dwo_out = cgcx. output_filenames . temp_path_dwo_for_cgu ( & module . name ) ;
933928 let dwo_out = match ( cgcx. split_debuginfo , cgcx. split_dwarf_kind ) {
934929 // Don't change how DWARF is emitted when disabled.
935930 ( SplitDebuginfo :: Off , _) => None ,
0 commit comments