Skip to content

Commit 36c055c

Browse files
committed
ensure that aarch64 hardfloat targets do not disable neon or fp-armv8
1 parent 8fccb92 commit 36c055c

File tree

1 file changed

+21
-0
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+21
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

+21
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,18 @@ impl TargetOptions {
25932593
.collect();
25942594
}
25952595
}
2596+
2597+
pub(crate) fn has_neg_feature(&self, search_feature: &str) -> bool {
2598+
self.features.split(',').any(|f| {
2599+
if let Some(f) = f.strip_prefix('-')
2600+
&& f == search_feature
2601+
{
2602+
true
2603+
} else {
2604+
false
2605+
}
2606+
})
2607+
}
25962608
}
25972609

25982610
impl Default for TargetOptions {
@@ -3108,6 +3120,15 @@ impl Target {
31083120
_ => {}
31093121
}
31103122

3123+
// Check that aarch64 hardfloat targets do not disable neon or fp-armv8 (which are
3124+
// on-by-default).
3125+
if self.arch == "aarch64" && self.abi != "softfloat" {
3126+
check!(
3127+
!self.has_neg_feature("neon") && !self.has_neg_feature("fp-armv8"),
3128+
"aarch64 hardfloat targets must not disable the `neon` or `fp-armv8` target features"
3129+
);
3130+
}
3131+
31113132
Ok(())
31123133
}
31133134

0 commit comments

Comments
 (0)