@@ -22,6 +22,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
22
22
use rustc_data_structures:: small_c_str:: SmallCStr ;
23
23
use rustc_errors:: { DiagCtxtHandle , Level } ;
24
24
use rustc_fs_util:: { link_or_copy, path_to_c_string} ;
25
+ use rustc_middle:: middle:: debuginfo:: CommandLineArgsForDebuginfo ;
25
26
use rustc_middle:: ty:: TyCtxt ;
26
27
use rustc_session:: Session ;
27
28
use rustc_session:: config:: {
@@ -31,7 +32,6 @@ use rustc_span::{BytePos, InnerSpan, Pos, SpanData, SyntaxContext, sym};
31
32
use rustc_target:: spec:: { CodeModel , FloatAbi , RelocModel , SanitizerSet , SplitDebuginfo , TlsModel } ;
32
33
use tracing:: { debug, trace} ;
33
34
34
- use crate :: back:: command_line_args:: quote_command_line_args;
35
35
use crate :: back:: lto:: ThinBuffer ;
36
36
use crate :: back:: owned_target_machine:: OwnedTargetMachine ;
37
37
use crate :: back:: profiling:: {
@@ -108,7 +108,11 @@ pub(crate) fn create_informational_target_machine(
108
108
sess : & Session ,
109
109
only_base_features : bool ,
110
110
) -> OwnedTargetMachine {
111
- let config = TargetMachineFactoryConfig { split_dwarf_file : None , output_obj_file : None } ;
111
+ let config = TargetMachineFactoryConfig {
112
+ split_dwarf_file : None ,
113
+ output_obj_file : None ,
114
+ args_for_debuginfo : None ,
115
+ } ;
112
116
// Can't use query system here quite yet because this function is invoked before the query
113
117
// system/tcx is set up.
114
118
let features = llvm_util:: global_llvm_features ( sess, false , only_base_features) ;
@@ -133,7 +137,12 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
133
137
mod_name,
134
138
tcx. sess . invocation_temp . as_deref ( ) ,
135
139
) ) ;
136
- let config = TargetMachineFactoryConfig { split_dwarf_file, output_obj_file } ;
140
+
141
+ let config = TargetMachineFactoryConfig {
142
+ split_dwarf_file,
143
+ output_obj_file,
144
+ args_for_debuginfo : Some ( Arc :: clone ( tcx. args_for_debuginfo ( ) ) ) ,
145
+ } ;
137
146
138
147
target_machine_factory (
139
148
tcx. sess ,
@@ -253,19 +262,6 @@ pub(crate) fn target_machine_factory(
253
262
254
263
let use_emulated_tls = matches ! ( sess. tls_model( ) , TlsModel :: Emulated ) ;
255
264
256
- // Command-line information to be included in the target machine.
257
- // This seems to only be used for embedding in PDB debuginfo files.
258
- // FIXME(Zalathar): Maybe skip this for non-PDB targets?
259
- let argv0 = std:: env:: current_exe ( )
260
- . unwrap_or_default ( )
261
- . into_os_string ( )
262
- . into_string ( )
263
- . unwrap_or_default ( ) ;
264
- let command_line_args = quote_command_line_args ( & sess. expanded_args ) ;
265
- // Self-profile counter for the number of bytes produced by command-line quoting.
266
- // Values are summed, so the summary result is cumulative across all TM factories.
267
- sess. prof . artifact_size ( "quoted_command_line_args" , "-" , command_line_args. len ( ) as u64 ) ;
268
-
269
265
let debuginfo_compression = sess. opts . debuginfo_compression . to_string ( ) ;
270
266
match sess. opts . debuginfo_compression {
271
267
rustc_session:: config:: DebugInfoCompression :: Zlib => {
@@ -304,6 +300,14 @@ pub(crate) fn target_machine_factory(
304
300
let split_dwarf_file = path_to_cstring_helper ( config. split_dwarf_file ) ;
305
301
let output_obj_file = path_to_cstring_helper ( config. output_obj_file ) ;
306
302
303
+ let ( argv0, quoted_args) = config
304
+ . args_for_debuginfo
305
+ . as_deref ( )
306
+ . map ( |CommandLineArgsForDebuginfo { argv0, quoted_args } | {
307
+ ( argv0. as_str ( ) , quoted_args. as_str ( ) )
308
+ } )
309
+ . unwrap_or_default ( ) ;
310
+
307
311
OwnedTargetMachine :: new (
308
312
& triple,
309
313
& cpu,
@@ -326,8 +330,8 @@ pub(crate) fn target_machine_factory(
326
330
& output_obj_file,
327
331
& debuginfo_compression,
328
332
use_emulated_tls,
329
- & argv0,
330
- & command_line_args ,
333
+ argv0,
334
+ quoted_args ,
331
335
use_wasm_eh,
332
336
)
333
337
} )
0 commit comments