Skip to content

Change hardcoded _FloatN support to detect instead #81

@tgross35

Description

@tgross35

It looks like the f16 tests are disabled because of the CI GCC version

# CI GCC is too old to support _Float16
[target.x86_64-unknown-linux-gnu."f16::conv_c"]
random = true
, and support is hardcoded at
match &self.cc_flavor {
CCFlavor::Gcc
if cfg!(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv32",
target_arch = "riscv64",
target_arch = "loongarch64",
// GCC PowerPC support requires the VSX feature, which is only
// enabled by default on powerpc64le. Rust doesn't currently support
// `cfg(target_feature = "vsx").
all(target_arch = "powerpc64", target_endian = "little"),
)) && !cfg!(target_vendor = "apple") =>
{
"_Float128 "
}
CCFlavor::Gcc => Err(UnsupportedError::Other(
"GCC isn't known to support f128 on this target".to_owned(),
))?,
CCFlavor::Clang | CCFlavor::Zigcc
if cfg!(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv32",
target_arch = "riscv64",
// Clang PowerPC support requires the VSX feature, which is only
// enabled by default on powerpc64le. Rust doesn't currently support
// `cfg(target_feature = "vsx").
all(target_arch = "powerpc64", target_endian = "little"),
)) && !cfg!(any(
target_env = "msvc",
target_vendor = "apple",
)) =>
{
"__float128 "
}
CCFlavor::Clang | CCFlavor::Zigcc => Err(UnsupportedError::Other(
"Clang isn't known to support f128 on this target".to_owned(),
))?,
CCFlavor::Msvc => Err(UnsupportedError::Other(
"MSVC doesn't support f128".to_owned(),
))?,
. Could this change to be autodetected instead?

The most obvious way to do this would probably be to test for success/failure of echo "_Float16 x;" | gcc -x c -c - -o/dev/null. Alternatively, run: GCC/Clang with -E -dM -x c /dev/null -o - to grab preprocessor output for this source:

#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>

And look for the following defines:

  • FLT16_MANT_DIG for _Float16
  • FLT128_MANT_DIG for _Float128
  • __SIZEOF_FLOAT128__ for __float128, or on Clang __FLOAT128__

FLT16_IS_IEC_60559 = 1 / FLT128_IS_IEC_60559 = 1 would probably be better than MANT_DIG since they allow you to verify the format is IEEE754, but they're not yet set by Clang.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions