test: Turn feature = "no-sys-f128" and similar into plain cfg

These are internal configuration that Cargo doesn't need to be aware of.
Clean them up from the Cargo.toml feature list.
This commit is contained in:
Trevor Gross
2026-03-31 20:44:51 -04:00
parent 22579364d8
commit ed1274749d
17 changed files with 106 additions and 98 deletions
@@ -27,14 +27,6 @@ paste.workspace = true
default = []
c = ["compiler_builtins/c"]
no-asm = ["compiler_builtins/no-asm"]
# Skip tests that rely on f128 symbols being available on the system
no-sys-f128 = ["no-sys-f128-int-convert", "no-sys-f16-f128-convert"]
# Some platforms have some f128 functions but everything except integer conversions
no-sys-f128-int-convert = []
no-sys-f16-f128-convert = []
no-sys-f16-f64-convert = []
# Skip tests that rely on f16 symbols being available on the system
no-sys-f16 = ["no-sys-f16-f64-convert"]
# Enable icount benchmarks (requires gungraun-runner and valgrind locally)
icount = ["dep:gungraun"]
@@ -74,7 +74,7 @@
crate_fn_ppc: add::__addkf3,
sys_fn: __addtf3,
sys_fn_ppc: __addkf3,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: []
}
@@ -185,7 +185,7 @@ fn gt_res_eq(mut a: CmpResult, mut b: CmpResult) -> bool {
crate_fn_ppc: cmp::__gtkf2,
sys_fn: __gttf2,
sys_fn_ppc: __gtkf2,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
output_eq: gt_res_eq,
asm: []
}
@@ -198,7 +198,7 @@ fn gt_res_eq(mut a: CmpResult, mut b: CmpResult) -> bool {
crate_fn_ppc: cmp::__unordkf2,
sys_fn: __unordtf2,
sys_fn_ppc: __unordkf2,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: []
}
@@ -84,7 +84,7 @@
crate_fn_ppc: conv::__floatunsikf,
sys_fn: __floatunsitf,
sys_fn_ppc: __floatunsikf,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -138,7 +138,7 @@
crate_fn_ppc: conv::__floatundikf,
sys_fn: __floatunditf,
sys_fn_ppc: __floatundikf,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -168,7 +168,7 @@
crate_fn_ppc: conv::__floatuntikf,
sys_fn: __floatuntitf,
sys_fn_ppc: __floatuntikf,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -249,7 +249,7 @@
crate_fn_ppc: conv::__floatsikf,
sys_fn: __floatsitf,
sys_fn_ppc: __floatsikf,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -328,7 +328,7 @@
crate_fn_ppc: conv::__floatdikf,
sys_fn: __floatditf,
sys_fn_ppc: __floatdikf,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -358,7 +358,7 @@
crate_fn_ppc: conv::__floattikf,
sys_fn: __floattitf,
sys_fn_ppc: __floattikf,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -473,7 +473,7 @@
crate_fn: conv::__fixunstfsi,
crate_fn_ppc: conv::__fixunskfsi,
sys_fn: __fixunstfsi,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -484,7 +484,7 @@
crate_fn: conv::__fixunstfdi,
crate_fn_ppc: conv::__fixunskfdi,
sys_fn: __fixunstfdi,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -495,7 +495,7 @@
crate_fn: conv::__fixunstfti,
crate_fn_ppc: conv::__fixunskfti,
sys_fn: __fixunstfti,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -610,7 +610,7 @@
crate_fn: conv::__fixtfsi,
crate_fn_ppc: conv::__fixkfsi,
sys_fn: __fixtfsi,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -621,7 +621,7 @@
crate_fn: conv::__fixtfdi,
crate_fn_ppc: conv::__fixkfdi,
sys_fn: __fixtfdi,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -632,7 +632,7 @@
crate_fn: conv::__fixtfti,
crate_fn_ppc: conv::__fixkfti,
sys_fn: __fixtfti,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: []
}
@@ -74,7 +74,7 @@
crate_fn_ppc: div::__divkf3,
sys_fn: __divtf3,
sys_fn_ppc: __divkf3,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: []
}
@@ -12,7 +12,7 @@
sig: (a: f16) -> f32,
crate_fn: extend::__extendhfsf2,
sys_fn: __extendhfsf2,
sys_available: not(feature = "no-sys-f16"),
sys_available: not(no_sys_f16),
asm: [
#[cfg(target_arch = "aarch64")] {
let ret: f32;
@@ -34,7 +34,7 @@
sig: (a: f16) -> f64,
crate_fn: extend::__extendhfdf2,
sys_fn: __extendhfdf2,
sys_available: not(feature = "no-sys-f16-f64-convert"),
sys_available: not(no_sys_f16_f64_convert),
asm: [
#[cfg(target_arch = "aarch64")] {
let ret: f64;
@@ -58,7 +58,7 @@
crate_fn_ppc: extend::__extendhfkf2,
sys_fn: __extendhftf2,
sys_fn_ppc: __extendhfkf2,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: [],
}
@@ -91,7 +91,7 @@
crate_fn_ppc: extend::__extendsfkf2,
sys_fn: __extendsftf2,
sys_fn_ppc: __extendsfkf2,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: [],
}
@@ -103,7 +103,7 @@
crate_fn_ppc: extend::__extenddfkf2,
sys_fn: __extenddftf2,
sys_fn_ppc: __extenddfkf2,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: [],
}
@@ -74,7 +74,7 @@
crate_fn_ppc: mul::__mulkf3,
sys_fn: __multf3,
sys_fn_ppc: __mulkf3,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: []
}
@@ -24,7 +24,7 @@
// FIXME(f16_f128): can be changed to only `f128_enabled` once `__multf3` and `__divtf3` are
// distributed by nightly.
#[cfg(all(f128_enabled, not(feature = "no-sys-f128")))]
#[cfg(all(f128_enabled, not(no_sys_f128)))]
float_bench! {
name: powi_f128,
sig: (a: f128, b: i32) -> f128,
@@ -32,7 +32,7 @@
crate_fn_ppc: pow::__powikf2,
sys_fn: __powitf2,
sys_fn_ppc: __powikf2,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: []
}
@@ -42,7 +42,7 @@ pub fn float_pow() {
powi_f32(&mut criterion);
powi_f64(&mut criterion);
#[cfg(all(f128_enabled, not(feature = "no-sys-f128")))]
#[cfg(all(f128_enabled, not(no_sys_f128)))]
powi_f128(&mut criterion);
}
@@ -74,7 +74,7 @@
crate_fn_ppc: sub::__subkf3,
sys_fn: __subtf3,
sys_fn_ppc: __subkf3,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: []
}
@@ -11,7 +11,7 @@
sig: (a: f32) -> f16,
crate_fn: trunc::__truncsfhf2,
sys_fn: __truncsfhf2,
sys_available: not(feature = "no-sys-f16"),
sys_available: not(no_sys_f16),
asm: [
#[cfg(target_arch = "aarch64")] {
let ret: f16;
@@ -33,7 +33,7 @@
sig: (a: f64) -> f16,
crate_fn: trunc::__truncdfhf2,
sys_fn: __truncdfhf2,
sys_available: not(feature = "no-sys-f16-f64-convert"),
sys_available: not(no_sys_f16_f64_convert),
asm: [
#[cfg(target_arch = "aarch64")] {
let ret: f16;
@@ -90,7 +90,7 @@
crate_fn_ppc: trunc::__trunckfhf2,
sys_fn: __trunctfhf2,
sys_fn_ppc: __trunckfhf2,
sys_available: not(feature = "no-sys-f16-f128-convert"),
sys_available: not(no_sys_f16_f128_convert),
asm: [],
}
@@ -102,7 +102,7 @@
crate_fn_ppc: trunc::__trunckfsf2,
sys_fn: __trunctfsf2,
sys_fn_ppc: __trunckfsf2,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: [],
}
@@ -114,7 +114,7 @@
crate_fn_ppc: trunc::__trunckfdf2,
sys_fn: __trunctfdf2,
sys_fn_ppc: __trunckfdf2,
sys_available: not(feature = "no-sys-f128"),
sys_available: not(no_sys_f128),
asm: [],
}
@@ -6,7 +6,7 @@ mod builtins_configure {
/// Features to enable
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
enum Feature {
enum SetCfg {
NoSysF128,
NoSysF128IntConvert,
NoSysF16,
@@ -14,7 +14,15 @@ enum Feature {
NoSysF16F128Convert,
}
impl Feature {
impl SetCfg {
const ALL: &[Self] = &[
Self::NoSysF128,
Self::NoSysF128IntConvert,
Self::NoSysF16,
Self::NoSysF16F64Convert,
Self::NoSysF16F128Convert,
];
fn implies(self) -> &'static [Self] {
match self {
Self::NoSysF128 => [Self::NoSysF128IntConvert, Self::NoSysF16F128Convert].as_slice(),
@@ -24,13 +32,33 @@ fn implies(self) -> &'static [Self] {
Self::NoSysF16F128Convert => [].as_slice(),
}
}
fn name(self) -> &'static str {
match self {
Self::NoSysF128 => "no_sys_f128",
Self::NoSysF128IntConvert => "no_sys_f128_int_convert",
Self::NoSysF16F64Convert => "no_sys_f16_f64_convert",
Self::NoSysF16F128Convert => "no_sys_f16_f128_convert",
Self::NoSysF16 => "no_sys_f16",
}
}
fn warning(self) -> &'static str {
match self {
SetCfg::NoSysF128 => "using apfloat fallback for f128",
SetCfg::NoSysF128IntConvert => "using apfloat fallback for f128 <-> int conversions",
SetCfg::NoSysF16F64Convert => "using apfloat fallback for f16 <-> f64 conversions",
SetCfg::NoSysF16F128Convert => "using apfloat fallback for f16 <-> f128 conversions",
SetCfg::NoSysF16 => "using apfloat fallback for f16",
}
}
}
fn main() {
println!("cargo::rerun-if-changed=../configure.rs");
let target = builtins_configure::Target::from_env();
let mut features = HashSet::new();
let mut to_set = HashSet::new();
// These platforms do not have f128 symbols available in their system libraries, so
// skip related tests.
@@ -51,14 +79,14 @@ fn main() {
// <https://github.com/rust-lang/compiler-builtins/pull/606#issuecomment-2105657287>.
|| target.arch == "powerpc64"
{
features.insert(Feature::NoSysF128);
to_set.insert(SetCfg::NoSysF128);
}
if target.arch == "x86" {
// 32-bit x86 does not have `__fixunstfti`/`__fixtfti` but does have everything else
features.insert(Feature::NoSysF128IntConvert);
to_set.insert(SetCfg::NoSysF128IntConvert);
// FIXME: 32-bit x86 has a bug in `f128 -> f16` system libraries
features.insert(Feature::NoSysF16F128Convert);
to_set.insert(SetCfg::NoSysF16F128Convert);
}
// These platforms do not have f16 symbols available in their system libraries, so
@@ -77,42 +105,30 @@ fn main() {
|| target.arch == "wasm32"
|| target.arch == "wasm64"
{
features.insert(Feature::NoSysF16);
to_set.insert(SetCfg::NoSysF16);
}
// These platforms are missing either `__extendhfdf2` or `__truncdfhf2`.
if target.vendor == "apple" || target.os == "windows" {
features.insert(Feature::NoSysF16F64Convert);
to_set.insert(SetCfg::NoSysF16F64Convert);
}
// Add implied features. Collection is required for borrows.
features.extend(
features
to_set.extend(
to_set
.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"),
Feature::NoSysF128IntConvert => (
"no-sys-f128-int-convert",
"using apfloat fallback for f128 <-> int conversions",
),
Feature::NoSysF16F64Convert => (
"no-sys-f16-f64-convert",
"using apfloat fallback for f16 <-> f64 conversions",
),
Feature::NoSysF16F128Convert => (
"no-sys-f16-f128-convert",
"using apfloat fallback for f16 <-> f128 conversions",
),
Feature::NoSysF16 => ("no-sys-f16", "using apfloat fallback for f16"),
};
println!("cargo:warning={warning}");
println!("cargo:rustc-cfg=feature=\"{name}\"");
for cfg in SetCfg::ALL {
println!("cargo:rustc-check-cfg=cfg({})", cfg.name());
}
for cfg in to_set {
println!("cargo:warning={}", cfg.warning());
println!("cargo:rustc-cfg={}", cfg.name());
}
builtins_configure::configure_aliases(&target);
@@ -131,12 +131,12 @@ mod float_addsub {
#[cfg(not(x86_no_sse2))]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
float_sum! {
f128, __addtf3, __subtf3, Quad, not(feature = "no-sys-f128");
f128, __addtf3, __subtf3, Quad, not(no_sys_f128);
}
#[cfg(f128_enabled)]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
float_sum! {
f128, __addkf3, __subkf3, Quad, not(feature = "no-sys-f128");
f128, __addkf3, __subkf3, Quad, not(no_sys_f128);
}
}
@@ -125,19 +125,19 @@ fn cmp_f128() {
fuzz_float_2(N, |x: f128, y: f128| {
let x_is_nan = apfloat_fallback!(
f128, Quad, not(feature = "no-sys-f128"),
f128, Quad, not(no_sys_f128),
|x: FloatTy| x.is_nan() => no_convert,
x
);
let y_is_nan = apfloat_fallback!(
f128, Quad, not(feature = "no-sys-f128"),
f128, Quad, not(no_sys_f128),
|x: FloatTy| x.is_nan() => no_convert,
y
);
assert_eq!(__unordtf2(x, y) != 0, x_is_nan || y_is_nan);
cmp!(f128, x, y, Quad, not(feature = "no-sys-f128"),
cmp!(f128, x, y, Quad, not(no_sys_f128),
1, __lttf2;
1, __letf2;
1, __eqtf2;
@@ -117,7 +117,7 @@ fn $fn() {
#[cfg(f128_enabled)]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
i_to_f! { f128, Quad, not(feature = "no-sys-f128-int-convert"),
i_to_f! { f128, Quad, not(no_sys_f128_int_convert),
u32, __floatunsitf;
i32, __floatsitf;
u64, __floatunditf;
@@ -128,7 +128,7 @@ fn $fn() {
#[cfg(f128_enabled)]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
i_to_f! { f128, Quad, not(feature = "no-sys-f128-int-convert"),
i_to_f! { f128, Quad, not(no_sys_f128_int_convert),
u32, __floatunsikf;
i32, __floatsikf;
u64, __floatundikf;
@@ -236,7 +236,7 @@ fn f128_to_int() {
x,
f128,
Quad,
not(feature = "no-sys-f128-int-convert"),
not(no_sys_f128_int_convert),
u32, __fixunstfsi;
u64, __fixunstfdi;
u128, __fixunstfti;
@@ -309,12 +309,12 @@ mod extend {
)))]
f_to_f! {
extend,
f16 => f32, Half => Single, __extendhfsf2, not(feature = "no-sys-f16");
f16 => f32, Half => Single, __gnu_h2f_ieee, not(feature = "no-sys-f16");
f16 => f64, Half => Double, __extendhfdf2, not(feature = "no-sys-f16-f64-convert");
f16 => f128, Half => Quad, __extendhftf2, not(feature = "no-sys-f16-f128-convert");
f32 => f128, Single => Quad, __extendsftf2, not(feature = "no-sys-f128");
f64 => f128, Double => Quad, __extenddftf2, not(feature = "no-sys-f128");
f16 => f32, Half => Single, __extendhfsf2, not(no_sys_f16);
f16 => f32, Half => Single, __gnu_h2f_ieee, not(no_sys_f16);
f16 => f64, Half => Double, __extendhfdf2, not(no_sys_f16_f64_convert);
f16 => f128, Half => Quad, __extendhftf2, not(no_sys_f16_f128_convert);
f32 => f128, Single => Quad, __extendsftf2, not(no_sys_f128);
f64 => f128, Double => Quad, __extenddftf2, not(no_sys_f128);
}
#[cfg(f128_enabled)]
@@ -322,8 +322,8 @@ mod extend {
f_to_f! {
extend,
// FIXME(#655): `f16` tests disabled until we can bootstrap symbols
f32 => f128, Single => Quad, __extendsfkf2, not(feature = "no-sys-f128");
f64 => f128, Double => Quad, __extenddfkf2, not(feature = "no-sys-f128");
f32 => f128, Single => Quad, __extendsfkf2, not(no_sys_f128);
f64 => f128, Double => Quad, __extenddfkf2, not(no_sys_f128);
}
}
@@ -343,12 +343,12 @@ mod trunc {
)))]
f_to_f! {
trunc,
f32 => f16, Single => Half, __truncsfhf2, not(feature = "no-sys-f16");
f32 => f16, Single => Half, __gnu_f2h_ieee, not(feature = "no-sys-f16");
f64 => f16, Double => Half, __truncdfhf2, not(feature = "no-sys-f16-f64-convert");
f128 => f16, Quad => Half, __trunctfhf2, not(feature = "no-sys-f16-f128-convert");
f128 => f32, Quad => Single, __trunctfsf2, not(feature = "no-sys-f128");
f128 => f64, Quad => Double, __trunctfdf2, not(feature = "no-sys-f128");
f32 => f16, Single => Half, __truncsfhf2, not(no_sys_f16);
f32 => f16, Single => Half, __gnu_f2h_ieee, not(no_sys_f16);
f64 => f16, Double => Half, __truncdfhf2, not(no_sys_f16_f64_convert);
f128 => f16, Quad => Half, __trunctfhf2, not(no_sys_f16_f128_convert);
f128 => f32, Quad => Single, __trunctfsf2, not(no_sys_f128);
f128 => f64, Quad => Double, __trunctfdf2, not(no_sys_f128);
}
#[cfg(f128_enabled)]
@@ -356,7 +356,7 @@ mod trunc {
f_to_f! {
trunc,
// FIXME(#655): `f16` tests disabled until we can bootstrap symbols
f128 => f32, Quad => Single, __trunckfsf2, not(feature = "no-sys-f128");
f128 => f64, Quad => Double, __trunckfdf2, not(feature = "no-sys-f128");
f128 => f32, Quad => Single, __trunckfsf2, not(no_sys_f128);
f128 => f64, Quad => Double, __trunckfdf2, not(no_sys_f128);
}
}
@@ -154,12 +154,12 @@ mod float_div {
f128, __divtf3, Quad,
// FIXME(llvm): there is a bug in LLVM rt.
// See <https://github.com/llvm/llvm-project/issues/91840>.
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
not(any(no_sys_f128, all(target_arch = "aarch64", target_os = "linux")));
}
#[cfg(f128_enabled)]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
float! {
f128, __divkf3, Quad, not(feature = "no-sys-f128");
f128, __divkf3, Quad, not(no_sys_f128);
}
}
@@ -62,11 +62,11 @@ fn $fn() {
#[cfg(f128_enabled)]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pow! {
f128, 1e-36, __powitf2, not(feature = "no-sys-f128");
f128, 1e-36, __powitf2, not(no_sys_f128);
}
#[cfg(f128_enabled)]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pow! {
f128, 1e-36, __powikf2, not(feature = "no-sys-f128");
f128, 1e-36, __powikf2, not(no_sys_f128);
}
@@ -142,7 +142,7 @@ mod float_mul_f128 {
f128, __multf3, Quad,
// FIXME(llvm): there is a bug in LLVM rt.
// See <https://github.com/llvm/llvm-project/issues/91840>.
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
not(any(no_sys_f128, all(target_arch = "aarch64", target_os = "linux")));
}
}
@@ -152,6 +152,6 @@ mod float_mul_f128_ppc {
use super::*;
float_mul! {
f128, __mulkf3, Quad, not(feature = "no-sys-f128");
f128, __mulkf3, Quad, not(no_sys_f128);
}
}