Return architecturally mandated target features to rustc

In the future the actual target features that Cranelift enables should
be returned here, but for now this works.

Fixes rust-lang/rustc_codegen_cranelift#1438
This commit is contained in:
bjorn3 2024-01-02 21:17:00 +00:00
parent c427754b52
commit 45d8c121ba

View File

@ -42,7 +42,7 @@
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::*;
@ -190,8 +190,17 @@ fn init(&self, sess: &Session) {
}
}
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) {