File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -226,12 +226,10 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
226
226
}
227
227
} ;
228
228
229
- unsafe {
230
- sess. targ_cfg
231
- . target_strs
232
- . target_triple
233
- . as_slice ( )
234
- . with_c_str ( |t| {
229
+ let triple = sess. targ_cfg . target_strs . target_triple . as_slice ( ) ;
230
+
231
+ let tm = unsafe {
232
+ triple. with_c_str ( |t| {
235
233
sess. opts . cg . target_cpu . as_slice ( ) . with_c_str ( |cpu| {
236
234
target_feature ( sess) . with_c_str ( |features| {
237
235
llvm:: LLVMRustCreateTargetMachine (
@@ -249,7 +247,15 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
249
247
} )
250
248
} )
251
249
} )
252
- }
250
+ } ;
251
+
252
+ if tm. is_null ( ) {
253
+ llvm_err ( sess. diagnostic ( ) . handler ( ) ,
254
+ format ! ( "Could not create LLVM TargetMachine for triple: {}" ,
255
+ triple) . to_string ( ) ) ;
256
+ } else {
257
+ return tm;
258
+ } ;
253
259
}
254
260
255
261
You can’t perform that action at this time.
0 commit comments