@@ -100,7 +100,10 @@ pub fn write_output_file<'ll>(
100
100
101
101
pub fn create_informational_target_machine ( sess : & Session ) -> & ' static mut llvm:: TargetMachine {
102
102
let config = TargetMachineFactoryConfig { split_dwarf_file : None } ;
103
- target_machine_factory ( sess, config:: OptLevel :: No ) ( config)
103
+ // Can't use query system here quite yet because this function is invoked before the query
104
+ // system/tcx is set up.
105
+ let features = llvm_util:: global_llvm_features ( sess, false ) ;
106
+ target_machine_factory ( sess, config:: OptLevel :: No , & features) ( config)
104
107
. unwrap_or_else ( |err| llvm_err ( sess. diagnostic ( ) , & err) . raise ( ) )
105
108
}
106
109
@@ -115,8 +118,12 @@ pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> &'static mut ll
115
118
None
116
119
} ;
117
120
let config = TargetMachineFactoryConfig { split_dwarf_file } ;
118
- target_machine_factory ( tcx. sess , tcx. backend_optimization_level ( ( ) ) ) ( config)
119
- . unwrap_or_else ( |err| llvm_err ( tcx. sess . diagnostic ( ) , & err) . raise ( ) )
121
+ target_machine_factory (
122
+ & tcx. sess ,
123
+ tcx. backend_optimization_level ( ( ) ) ,
124
+ tcx. global_backend_features ( ( ) ) ,
125
+ ) ( config)
126
+ . unwrap_or_else ( |err| llvm_err ( tcx. sess . diagnostic ( ) , & err) . raise ( ) )
120
127
}
121
128
122
129
pub fn to_llvm_opt_settings (
@@ -171,6 +178,7 @@ pub(crate) fn to_llvm_code_model(code_model: Option<CodeModel>) -> llvm::CodeMod
171
178
pub fn target_machine_factory (
172
179
sess : & Session ,
173
180
optlvl : config:: OptLevel ,
181
+ target_features : & [ String ] ,
174
182
) -> TargetMachineFactoryFn < LlvmCodegenBackend > {
175
183
let reloc_model = to_llvm_relocation_model ( sess. relocation_model ( ) ) ;
176
184
@@ -195,8 +203,7 @@ pub fn target_machine_factory(
195
203
196
204
let triple = SmallCStr :: new ( & sess. target . llvm_target ) ;
197
205
let cpu = SmallCStr :: new ( llvm_util:: target_cpu ( sess) ) ;
198
- let features = llvm_util:: llvm_global_features ( sess) . join ( "," ) ;
199
- let features = CString :: new ( features) . unwrap ( ) ;
206
+ let features = CString :: new ( target_features. join ( "," ) ) . unwrap ( ) ;
200
207
let abi = SmallCStr :: new ( & sess. target . llvm_abiname ) ;
201
208
let trap_unreachable =
202
209
sess. opts . debugging_opts . trap_unreachable . unwrap_or ( sess. target . trap_unreachable ) ;
0 commit comments