@@ -112,8 +112,10 @@ pub(crate) fn create_informational_target_machine(
112112 // Can't use query system here quite yet because this function is invoked before the query
113113 // system/tcx is set up.
114114 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) )
117119}
118120
119121pub ( 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
139141 tcx. sess ,
140142 tcx. backend_optimization_level ( ( ) ) ,
141143 tcx. global_backend_features ( ( ) ) ,
144+ TargetMachineRole :: Codegen ,
142145 ) ( config)
143146 . unwrap_or_else ( |err| llvm_err ( tcx. dcx ( ) , err) )
144147}
@@ -199,10 +202,17 @@ fn to_llvm_float_abi(float_abi: Option<FloatAbi>) -> llvm::FloatAbi {
199202 }
200203}
201204
205+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
206+ pub ( crate ) enum TargetMachineRole {
207+ Informational ,
208+ Codegen ,
209+ }
210+
202211pub ( crate ) fn target_machine_factory (
203212 sess : & Session ,
204213 optlvl : config:: OptLevel ,
205214 target_features : & [ String ] ,
215+ tm_role : TargetMachineRole ,
206216) -> TargetMachineFactoryFn < LlvmCodegenBackend > {
207217 let reloc_model = to_llvm_relocation_model ( sess. relocation_model ( ) ) ;
208218
@@ -253,12 +263,21 @@ pub(crate) fn target_machine_factory(
253263 // Command-line information to be included in the target machine.
254264 // This seems to only be used for embedding in PDB debuginfo files.
255265 // 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+ }
262281
263282 let debuginfo_compression = sess. opts . debuginfo_compression . to_string ( ) ;
264283 match sess. opts . debuginfo_compression {
0 commit comments