Simplify test crate build features

Since we have a handful of different float-related configuration in
testcrate, track a list of which are implied by others rather than
repeating the config.
This commit is contained in:
Trevor Gross 2025-03-04 17:46:50 -05:00 committed by Trevor Gross
parent 2de09ac46a
commit 340d3d4bd7
2 changed files with 25 additions and 8 deletions

View file

@ -665,7 +665,7 @@ pub fn float_conv() {
conv_f64_i64(&mut criterion);
conv_f64_i128(&mut criterion);
#[cfg(all(f128_enabled))]
#[cfg(f128_enabled)]
// FIXME: ppc64le has a sporadic overflow panic in the crate functions
// <https://github.com/rust-lang/compiler-builtins/issues/617#issuecomment-2125914639>
#[cfg(not(all(target_arch = "powerpc64", target_endian = "little")))]

View file

@ -1,7 +1,11 @@
use std::collections::HashSet;
mod builtins_configure {
include!("../configure.rs");
}
/// Features to enable
#[derive(Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
enum Feature {
NoSysF128,
NoSysF128IntConvert,
@ -10,8 +14,16 @@ enum Feature {
NoSysF16F128Convert,
}
mod builtins_configure {
include!("../configure.rs");
impl Feature {
fn implies(self) -> &'static [Self] {
match self {
Self::NoSysF128 => [Self::NoSysF128IntConvert, Self::NoSysF16F128Convert].as_slice(),
Self::NoSysF128IntConvert => [].as_slice(),
Self::NoSysF16 => [Self::NoSysF16F64Convert, Self::NoSysF16F128Convert].as_slice(),
Self::NoSysF16F64Convert => [].as_slice(),
Self::NoSysF16F128Convert => [].as_slice(),
}
}
}
fn main() {
@ -40,8 +52,6 @@ fn main() {
|| target.arch == "powerpc64"
{
features.insert(Feature::NoSysF128);
features.insert(Feature::NoSysF128IntConvert);
features.insert(Feature::NoSysF16F128Convert);
}
if target.arch == "x86" {
@ -67,8 +77,6 @@ fn main() {
|| target.arch == "wasm64"
{
features.insert(Feature::NoSysF16);
features.insert(Feature::NoSysF16F64Convert);
features.insert(Feature::NoSysF16F128Convert);
}
// These platforms are missing either `__extendhfdf2` or `__truncdfhf2`.
@ -76,6 +84,15 @@ fn main() {
features.insert(Feature::NoSysF16F64Convert);
}
// Add implied features. Collection is required for borrows.
features.extend(
features
.iter()
.flat_map(|x| x.implies())
.copied()
.collect::<Vec<_>>(),
);
for feature in features {
let (name, warning) = match feature {
Feature::NoSysF128 => ("no-sys-f128", "using apfloat fallback for f128"),