Skip to content

Commit 94a8f2e

Browse files
committed
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.
1 parent 9ed21c4 commit 94a8f2e

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

testcrate/benches/float_conv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ pub fn float_conv() {
665665
conv_f64_i64(&mut criterion);
666666
conv_f64_i128(&mut criterion);
667667

668-
#[cfg(all(f128_enabled))]
668+
#[cfg(f128_enabled)]
669669
// FIXME: ppc64le has a sporadic overflow panic in the crate functions
670670
// <https://github.com/rust-lang/compiler-builtins/issues/617#issuecomment-2125914639>
671671
#[cfg(not(all(target_arch = "powerpc64", target_endian = "little")))]

testcrate/build.rs

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
use std::collections::HashSet;
22

3+
mod builtins_configure {
4+
include!("../configure.rs");
5+
}
6+
37
/// Features to enable
4-
#[derive(Debug, PartialEq, Eq, Hash)]
8+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
59
enum Feature {
610
NoSysF128,
711
NoSysF128IntConvert,
@@ -10,8 +14,16 @@ enum Feature {
1014
NoSysF16F128Convert,
1115
}
1216

13-
mod builtins_configure {
14-
include!("../configure.rs");
17+
impl Feature {
18+
fn implies(self) -> &'static [Self] {
19+
match self {
20+
Self::NoSysF128 => [Self::NoSysF128IntConvert, Self::NoSysF16F128Convert].as_slice(),
21+
Self::NoSysF128IntConvert => [].as_slice(),
22+
Self::NoSysF16 => [Self::NoSysF16F64Convert, Self::NoSysF16F128Convert].as_slice(),
23+
Self::NoSysF16F64Convert => [].as_slice(),
24+
Self::NoSysF16F128Convert => [].as_slice(),
25+
}
26+
}
1527
}
1628

1729
fn main() {
@@ -40,8 +52,6 @@ fn main() {
4052
|| target.arch == "powerpc64"
4153
{
4254
features.insert(Feature::NoSysF128);
43-
features.insert(Feature::NoSysF128IntConvert);
44-
features.insert(Feature::NoSysF16F128Convert);
4555
}
4656

4757
if target.arch == "x86" {
@@ -67,15 +77,22 @@ fn main() {
6777
|| target.arch == "wasm64"
6878
{
6979
features.insert(Feature::NoSysF16);
70-
features.insert(Feature::NoSysF16F64Convert);
71-
features.insert(Feature::NoSysF16F128Convert);
7280
}
7381

7482
// These platforms are missing either `__extendhfdf2` or `__truncdfhf2`.
7583
if target.vendor == "apple" || target.os == "windows" {
7684
features.insert(Feature::NoSysF16F64Convert);
7785
}
7886

87+
// Add implied features. Collection is required for borrows.
88+
features.extend(
89+
features
90+
.iter()
91+
.flat_map(|x| x.implies())
92+
.copied()
93+
.collect::<Vec<_>>(),
94+
);
95+
7996
for feature in features {
8097
let (name, warning) = match feature {
8198
Feature::NoSysF128 => ("no-sys-f128", "using apfloat fallback for f128"),

0 commit comments

Comments
 (0)