From 3f290ab44d31263637053c3c1ef47ad89d2c4c07 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 4 Mar 2025 17:46:50 -0500 Subject: [PATCH] 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. --- testcrate/benches/float_conv.rs | 2 +- testcrate/build.rs | 31 ++++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/testcrate/benches/float_conv.rs b/testcrate/benches/float_conv.rs index 0625a1ae5..7d8549b43 100644 --- a/testcrate/benches/float_conv.rs +++ b/testcrate/benches/float_conv.rs @@ -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 // #[cfg(not(all(target_arch = "powerpc64", target_endian = "little")))] diff --git a/testcrate/build.rs b/testcrate/build.rs index 3e5f780ac..427fa799b 100644 --- a/testcrate/build.rs +++ b/testcrate/build.rs @@ -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::>(), + ); + for feature in features { let (name, warning) = match feature { Feature::NoSysF128 => ("no-sys-f128", "using apfloat fallback for f128"),