@@ -100,7 +100,7 @@ pub fn write_output_file<'ll>(
100
100
}
101
101
102
102
pub fn create_informational_target_machine ( sess : & Session ) -> OwnedTargetMachine {
103
- let config = TargetMachineFactoryConfig { split_dwarf_file : None } ;
103
+ let config = TargetMachineFactoryConfig { split_dwarf_file : None , output_obj_file : None } ;
104
104
// Can't use query system here quite yet because this function is invoked before the query
105
105
// system/tcx is set up.
106
106
let features = llvm_util:: global_llvm_features ( sess, false ) ;
@@ -118,7 +118,11 @@ pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTargetMach
118
118
} else {
119
119
None
120
120
} ;
121
- let config = TargetMachineFactoryConfig { split_dwarf_file } ;
121
+
122
+ let output_obj_file =
123
+ Some ( tcx. output_filenames ( ( ) ) . temp_path ( OutputType :: Object , Some ( mod_name) ) ) ;
124
+ let config = TargetMachineFactoryConfig { split_dwarf_file, output_obj_file } ;
125
+
122
126
target_machine_factory (
123
127
& tcx. sess ,
124
128
tcx. backend_optimization_level ( ( ) ) ,
@@ -256,9 +260,13 @@ pub fn target_machine_factory(
256
260
let debuginfo_compression = SmallCStr :: new ( & debuginfo_compression) ;
257
261
258
262
Arc :: new ( move |config : TargetMachineFactoryConfig | {
259
- let split_dwarf_file =
260
- path_mapping. map_prefix ( config. split_dwarf_file . unwrap_or_default ( ) ) . 0 ;
261
- let split_dwarf_file = CString :: new ( split_dwarf_file. to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
263
+ let path_to_cstring_helper = |path : Option < PathBuf > | -> CString {
264
+ let path = path_mapping. map_prefix ( path. unwrap_or_default ( ) ) . 0 ;
265
+ CString :: new ( path. to_str ( ) . unwrap ( ) ) . unwrap ( )
266
+ } ;
267
+
268
+ let split_dwarf_file = path_to_cstring_helper ( config. split_dwarf_file ) ;
269
+ let output_obj_file = path_to_cstring_helper ( config. output_obj_file ) ;
262
270
263
271
OwnedTargetMachine :: new (
264
272
& triple,
@@ -279,6 +287,7 @@ pub fn target_machine_factory(
279
287
relax_elf_relocations,
280
288
use_init_array,
281
289
& split_dwarf_file,
290
+ & output_obj_file,
282
291
& debuginfo_compression,
283
292
force_emulated_tls,
284
293
& args_cstr_buff,
0 commit comments