Skip to content

Commit

Permalink
Return architecturally mandated target features to rustc
Browse files Browse the repository at this point in the history
In the future the actual target features that Cranelift enables should
be returned here, but for now this works.

Fixes #1438
  • Loading branch information
bjorn3 committed Jan 2, 2024
1 parent c427754 commit 45d8c12
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_session::config::OutputFilenames;
use rustc_session::Session;
use rustc_span::Symbol;
use rustc_span::{sym, Symbol};

pub use crate::config::*;
use crate::prelude::*;
Expand Down Expand Up @@ -190,8 +190,17 @@ impl CodegenBackend for CraneliftCodegenBackend {
}
}

fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
vec![] // FIXME necessary for #[cfg(target_feature]
fn target_features(&self, sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
if sess.target.arch == "x86_64" && sess.target.os != "none" {
// x86_64 mandates SSE2 support
vec![Symbol::intern("fxsr"), sym::sse, Symbol::intern("sse2")]
} else if sess.target.arch == "aarch64" && sess.target.os != "none" {
// AArch64 mandates Neon support
vec![sym::neon]
} else {
vec![]
}
}

fn print_version(&self) {
Expand Down

0 comments on commit 45d8c12

Please sign in to comment.