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