Don't panic when the target is not supported by Cranelift
This commit is contained in:
parent
ede41d1b98
commit
60340d44d8
23
src/lib.rs
23
src/lib.rs
@ -217,18 +217,17 @@ fn link(
|
||||
) -> Result<(), ErrorReported> {
|
||||
use rustc_codegen_ssa::back::link::link_binary;
|
||||
|
||||
link_binary::<crate::archive::ArArchiveBuilder<'_>>(
|
||||
sess,
|
||||
&codegen_results,
|
||||
outputs,
|
||||
);
|
||||
link_binary::<crate::archive::ArArchiveBuilder<'_>>(sess, &codegen_results, outputs);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn target_triple(sess: &Session) -> target_lexicon::Triple {
|
||||
sess.target.llvm_target.parse().unwrap()
|
||||
match sess.target.llvm_target.parse() {
|
||||
Ok(triple) => triple,
|
||||
Err(err) => sess.fatal(&format!("target not recognized: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
Some(value) => {
|
||||
let mut builder =
|
||||
cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
|
||||
cranelift_codegen::isa::lookup_variant(target_triple.clone(), variant)
|
||||
.unwrap_or_else(|err| {
|
||||
sess.fatal(&format!("can't compile for {}: {}", target_triple, err));
|
||||
});
|
||||
if let Err(_) = builder.enable(value) {
|
||||
sess.fatal("The specified target cpu isn't currently supported by Cranelift.");
|
||||
sess.fatal("the specified target cpu isn't currently supported by Cranelift.");
|
||||
}
|
||||
builder
|
||||
}
|
||||
None => {
|
||||
let mut builder =
|
||||
cranelift_codegen::isa::lookup_variant(target_triple.clone(), variant).unwrap();
|
||||
cranelift_codegen::isa::lookup_variant(target_triple.clone(), variant)
|
||||
.unwrap_or_else(|err| {
|
||||
sess.fatal(&format!("can't compile for {}: {}", target_triple, err));
|
||||
});
|
||||
if target_triple.architecture == target_lexicon::Architecture::X86_64 {
|
||||
// Don't use "haswell" as the default, as it implies `has_lzcnt`.
|
||||
// macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
|
||||
|
Loading…
Reference in New Issue
Block a user