@@ -112,8 +112,10 @@ pub(crate) fn create_informational_target_machine(
112
112
// Can't use query system here quite yet because this function is invoked before the query
113
113
// system/tcx is set up.
114
114
let features = llvm_util:: global_llvm_features ( sess, false , only_base_features) ;
115
- target_machine_factory ( sess, config:: OptLevel :: No , & features) ( config)
116
- . unwrap_or_else ( |err| llvm_err ( sess. dcx ( ) , err) )
115
+ target_machine_factory ( sess, config:: OptLevel :: No , & features, TargetMachineRole :: Informational ) (
116
+ config,
117
+ )
118
+ . unwrap_or_else ( |err| llvm_err ( sess. dcx ( ) , err) )
117
119
}
118
120
119
121
pub ( crate ) fn create_target_machine ( tcx : TyCtxt < ' _ > , mod_name : & str ) -> OwnedTargetMachine {
@@ -139,6 +141,7 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
139
141
tcx. sess ,
140
142
tcx. backend_optimization_level ( ( ) ) ,
141
143
tcx. global_backend_features ( ( ) ) ,
144
+ TargetMachineRole :: Codegen ,
142
145
) ( config)
143
146
. unwrap_or_else ( |err| llvm_err ( tcx. dcx ( ) , err) )
144
147
}
@@ -199,10 +202,17 @@ fn to_llvm_float_abi(float_abi: Option<FloatAbi>) -> llvm::FloatAbi {
199
202
}
200
203
}
201
204
205
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
206
+ pub ( crate ) enum TargetMachineRole {
207
+ Informational ,
208
+ Codegen ,
209
+ }
210
+
202
211
pub ( crate ) fn target_machine_factory (
203
212
sess : & Session ,
204
213
optlvl : config:: OptLevel ,
205
214
target_features : & [ String ] ,
215
+ tm_role : TargetMachineRole ,
206
216
) -> TargetMachineFactoryFn < LlvmCodegenBackend > {
207
217
let reloc_model = to_llvm_relocation_model ( sess. relocation_model ( ) ) ;
208
218
@@ -253,12 +263,21 @@ pub(crate) fn target_machine_factory(
253
263
// Command-line information to be included in the target machine.
254
264
// This seems to only be used for embedding in PDB debuginfo files.
255
265
// FIXME(Zalathar): Maybe skip this for non-PDB targets?
256
- let argv0 = std:: env:: current_exe ( )
257
- . unwrap_or_default ( )
258
- . into_os_string ( )
259
- . into_string ( )
260
- . unwrap_or_default ( ) ;
261
- let command_line_args = quote_command_line_args ( & sess. expanded_args ) ;
266
+ let ( argv0, command_line_args) ;
267
+ match tm_role {
268
+ TargetMachineRole :: Informational => {
269
+ argv0 = String :: new ( ) ;
270
+ command_line_args = String :: new ( )
271
+ }
272
+ TargetMachineRole :: Codegen => {
273
+ argv0 = std:: env:: current_exe ( )
274
+ . unwrap_or_default ( )
275
+ . into_os_string ( )
276
+ . into_string ( )
277
+ . unwrap_or_default ( ) ;
278
+ command_line_args = quote_command_line_args ( & sess. expanded_args ) ;
279
+ }
280
+ }
262
281
263
282
let debuginfo_compression = sess. opts . debuginfo_compression . to_string ( ) ;
264
283
match sess. opts . debuginfo_compression {
0 commit comments