Skip to content

Commit

Permalink
ensure that aarch64 hardfloat targets do not disable neon or fp-armv8
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 23, 2024
1 parent 8fccb92 commit 36c055c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,18 @@ impl TargetOptions {
.collect();
}
}

pub(crate) fn has_neg_feature(&self, search_feature: &str) -> bool {
self.features.split(',').any(|f| {
if let Some(f) = f.strip_prefix('-')
&& f == search_feature
{
true
} else {
false
}
})
}
}

impl Default for TargetOptions {
Expand Down Expand Up @@ -3108,6 +3120,15 @@ impl Target {
_ => {}
}

// Check that aarch64 hardfloat targets do not disable neon or fp-armv8 (which are
// on-by-default).
if self.arch == "aarch64" && self.abi != "softfloat" {
check!(
!self.has_neg_feature("neon") && !self.has_neg_feature("fp-armv8"),
"aarch64 hardfloat targets must not disable the `neon` or `fp-armv8` target features"
);
}

Ok(())
}

Expand Down

0 comments on commit 36c055c

Please sign in to comment.