Skip to content

Commit 45d8c12

Browse files
committed
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 #1438
1 parent c427754 commit 45d8c12

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/lib.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use rustc_metadata::EncodedMetadata;
4242
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
4343
use rustc_session::config::OutputFilenames;
4444
use rustc_session::Session;
45-
use rustc_span::Symbol;
45+
use rustc_span::{sym, Symbol};
4646

4747
pub use crate::config::*;
4848
use crate::prelude::*;
@@ -190,8 +190,17 @@ impl CodegenBackend for CraneliftCodegenBackend {
190190
}
191191
}
192192

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

197206
fn print_version(&self) {

0 commit comments

Comments
 (0)