@@ -217,18 +217,17 @@ impl CodegenBackend for CraneliftCodegenBackend {
217
217
) -> Result < ( ) , ErrorReported > {
218
218
use rustc_codegen_ssa:: back:: link:: link_binary;
219
219
220
- link_binary :: < crate :: archive:: ArArchiveBuilder < ' _ > > (
221
- sess,
222
- & codegen_results,
223
- outputs,
224
- ) ;
220
+ link_binary :: < crate :: archive:: ArArchiveBuilder < ' _ > > ( sess, & codegen_results, outputs) ;
225
221
226
222
Ok ( ( ) )
227
223
}
228
224
}
229
225
230
226
fn target_triple ( sess : & Session ) -> target_lexicon:: Triple {
231
- sess. target . llvm_target . parse ( ) . unwrap ( )
227
+ match sess. target . llvm_target . parse ( ) {
228
+ Ok ( triple) => triple,
229
+ Err ( err) => sess. fatal ( & format ! ( "target not recognized: {}" , err) ) ,
230
+ }
232
231
}
233
232
234
233
fn build_isa ( sess : & Session , backend_config : & BackendConfig ) -> Box < dyn isa:: TargetIsa + ' static > {
@@ -278,15 +277,21 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
278
277
}
279
278
Some ( value) => {
280
279
let mut builder =
281
- cranelift_codegen:: isa:: lookup_variant ( target_triple, variant) . unwrap ( ) ;
280
+ cranelift_codegen:: isa:: lookup_variant ( target_triple. clone ( ) , variant)
281
+ . unwrap_or_else ( |err| {
282
+ sess. fatal ( & format ! ( "can't compile for {}: {}" , target_triple, err) ) ;
283
+ } ) ;
282
284
if let Err ( _) = builder. enable ( value) {
283
- sess. fatal ( "The specified target cpu isn't currently supported by Cranelift." ) ;
285
+ sess. fatal ( "the specified target cpu isn't currently supported by Cranelift." ) ;
284
286
}
285
287
builder
286
288
}
287
289
None => {
288
290
let mut builder =
289
- cranelift_codegen:: isa:: lookup_variant ( target_triple. clone ( ) , variant) . unwrap ( ) ;
291
+ cranelift_codegen:: isa:: lookup_variant ( target_triple. clone ( ) , variant)
292
+ . unwrap_or_else ( |err| {
293
+ sess. fatal ( & format ! ( "can't compile for {}: {}" , target_triple, err) ) ;
294
+ } ) ;
290
295
if target_triple. architecture == target_lexicon:: Architecture :: X86_64 {
291
296
// Don't use "haswell" as the default, as it implies `has_lzcnt`.
292
297
// macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
0 commit comments