diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index aea3fd62443..9f707dfca05 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -872,93 +872,113 @@ H5ConversionTests (${HDF_PREFIX}_LLONG_TO_LDOUBLE_CORRECT TRUE "Checking IF corr H5ConversionTests (${HDF_PREFIX}_DISABLE_SOME_LDOUBLE_CONV FALSE "Checking IF the cpu is power9 and cannot correctly converting long double values") #----------------------------------------------------------------------------- -# Check if _Float16 type is available +# Options for enabling/disabling support for non-standard features, datatypes, +# etc. These features should still be checked for at configure time, but these +# options allow disabling of support for these features when compiler support +# is incomplete or broken. In this case, configure time checks may not be +# enough to properly enable/disable a feature and can cause library build +# problems. #----------------------------------------------------------------------------- -message (STATUS "Checking if _Float16 support is available") -set (${HDF_PREFIX}_HAVE__FLOAT16 0) -HDF_CHECK_TYPE_SIZE (_Float16 ${HDF_PREFIX}_SIZEOF__FLOAT16) -if (${HDF_PREFIX}_SIZEOF__FLOAT16) - # Request _Float16 support - set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-D__STDC_WANT_IEC_60559_TYPES_EXT__") - - # Some compilers expose the _Float16 datatype, but not the macros and - # functions used with the datatype. We need the macros for proper - # datatype conversion support. Check for these here. - CHECK_SYMBOL_EXISTS (FLT16_EPSILON "float.h" h5_have_flt16_epsilon) - CHECK_SYMBOL_EXISTS (FLT16_MIN "float.h" h5_have_flt16_min) - CHECK_SYMBOL_EXISTS (FLT16_MAX "float.h" h5_have_flt16_max) - CHECK_SYMBOL_EXISTS (FLT16_MIN_10_EXP "float.h" h5_have_flt16_min_10_exp) - CHECK_SYMBOL_EXISTS (FLT16_MAX_10_EXP "float.h" h5_have_flt16_max_10_exp) - CHECK_SYMBOL_EXISTS (FLT16_MANT_DIG "float.h" h5_have_flt16_mant_dig) - - if (h5_have_flt16_epsilon AND h5_have_flt16_min AND - h5_have_flt16_max AND h5_have_flt16_min_10_exp AND - h5_have_flt16_max_10_exp AND h5_have_flt16_mant_dig) - # Some compilers like OneAPI on Windows appear to detect _Float16 support - # properly up to this point, and, in the absence of any architecture-specific - # tuning compiler flags, will generate code for H5Tconv.c that performs - # software conversions on _Float16 variables with compiler-internal functions - # such as __extendhfsf2, __truncsfhf2, or __truncdfhf2. However, these - # compilers will fail to link these functions into the build for currently - # unknown reasons and cause the build to fail. Since these are compiler-internal - # functions that we don't appear to have much control over, let's try to - # compile a program that will generate these functions to check for _Float16 - # support. If we fail to compile this program, we will simply disable - # _Float16 support for the time being. - - # Some compilers, notably AppleClang on MacOS 12, will succeed in the - # configure check below when optimization flags like -O3 are manually - # passed in CMAKE_C_FLAGS. However, the build will then fail when it - # reaches compilation of H5Tconv.c because of the issue mentioned above. - # MacOS 13 appears to have fixed this, but, just to be sure, backup and - # clear CMAKE_C_FLAGS before performing these configure checks. - set (cmake_c_flags_backup "${CMAKE_C_FLAGS}") - set (CMAKE_C_FLAGS "") - - H5ConversionTests ( - ${HDF_PREFIX}_FLOAT16_CONVERSION_FUNCS_LINK - FALSE - "Checking if compiler can convert _Float16 type with casts" - ) - - set (CMAKE_C_FLAGS "${cmake_c_flags_backup}") - - if (${${HDF_PREFIX}_FLOAT16_CONVERSION_FUNCS_LINK}) - # Finally, MacOS 13 appears to have a bug specifically when converting - # long double values to _Float16. Release builds of the dt_arith test - # would cause any assignments to a _Float16 variable to be elided, - # whereas Debug builds would perform incorrect hardware conversions by - # simply chopping off all the bytes of the value except for the first 2. - # These tests pass on MacOS 14, so let's perform a quick test to check - # if the hardware conversion is done correctly. +# Option to enable or disable all non-standard features. Specific features can +# be enabled or disabled with their respective options below +option (HDF5_ENABLE_NONSTANDARD_FEATURES "Enable support for non-standard programming language features" ON) +# Options for enabling or disabling individual features +option (HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16 "Enable support for _Float16 C datatype" ${HDF5_ENABLE_NONSTANDARD_FEATURES}) - # Backup and clear CMAKE_C_FLAGS before performing configure checks +#----------------------------------------------------------------------------- +# Check if _Float16 type is available +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16) + message (STATUS "Checking if _Float16 support is available") + HDF_CHECK_TYPE_SIZE (_Float16 ${HDF_PREFIX}_SIZEOF__FLOAT16) + + if (${HDF_PREFIX}_SIZEOF__FLOAT16) + # Request _Float16 support + set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-D__STDC_WANT_IEC_60559_TYPES_EXT__") + + # Some compilers expose the _Float16 datatype, but not the macros and + # functions used with the datatype. We need the macros for proper + # datatype conversion support. Check for these here. + CHECK_SYMBOL_EXISTS (FLT16_EPSILON "float.h" h5_have_flt16_epsilon) + CHECK_SYMBOL_EXISTS (FLT16_MIN "float.h" h5_have_flt16_min) + CHECK_SYMBOL_EXISTS (FLT16_MAX "float.h" h5_have_flt16_max) + CHECK_SYMBOL_EXISTS (FLT16_MIN_10_EXP "float.h" h5_have_flt16_min_10_exp) + CHECK_SYMBOL_EXISTS (FLT16_MAX_10_EXP "float.h" h5_have_flt16_max_10_exp) + CHECK_SYMBOL_EXISTS (FLT16_MANT_DIG "float.h" h5_have_flt16_mant_dig) + + if (h5_have_flt16_epsilon AND h5_have_flt16_min AND + h5_have_flt16_max AND h5_have_flt16_min_10_exp AND + h5_have_flt16_max_10_exp AND h5_have_flt16_mant_dig) + # Some compilers like OneAPI on Windows appear to detect _Float16 support + # properly up to this point, and, in the absence of any architecture-specific + # tuning compiler flags, will generate code for H5Tconv.c that performs + # software conversions on _Float16 variables with compiler-internal functions + # such as __extendhfsf2, __truncsfhf2, or __truncdfhf2. However, these + # compilers will fail to link these functions into the build for currently + # unknown reasons and cause the build to fail. Since these are compiler-internal + # functions that we don't appear to have much control over, let's try to + # compile a program that will generate these functions to check for _Float16 + # support. If we fail to compile this program, we will simply disable + # _Float16 support for the time being. + + # Some compilers, notably AppleClang on MacOS 12, will succeed in the + # configure check below when optimization flags like -O3 are manually + # passed in CMAKE_C_FLAGS. However, the build will then fail when it + # reaches compilation of H5Tconv.c because of the issue mentioned above. + # MacOS 13 appears to have fixed this, but, just to be sure, backup and + # clear CMAKE_C_FLAGS before performing these configure checks. set (cmake_c_flags_backup "${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "") H5ConversionTests ( - ${HDF_PREFIX}_LDOUBLE_TO_FLOAT16_CORRECT - TRUE - "Checking if correctly converting long double to _Float16 values" + ${HDF_PREFIX}_FLOAT16_CONVERSION_FUNCS_LINK + FALSE + "Checking if compiler can convert _Float16 type with casts" ) set (CMAKE_C_FLAGS "${cmake_c_flags_backup}") - if (NOT ${${HDF_PREFIX}_LDOUBLE_TO_FLOAT16_CORRECT}) - message (VERBOSE "Conversions from long double to _Float16 appear to be incorrect. These will be emulated through a soft conversion function.") - endif () + if (${${HDF_PREFIX}_FLOAT16_CONVERSION_FUNCS_LINK}) + # Finally, MacOS 13 appears to have a bug specifically when converting + # long double values to _Float16. Release builds of the dt_arith test + # would cause any assignments to a _Float16 variable to be elided, + # whereas Debug builds would perform incorrect hardware conversions by + # simply chopping off all the bytes of the value except for the first 2. + # These tests pass on MacOS 14, so let's perform a quick test to check + # if the hardware conversion is done correctly. + + # Backup and clear CMAKE_C_FLAGS before performing configure checks + set (cmake_c_flags_backup "${CMAKE_C_FLAGS}") + set (CMAKE_C_FLAGS "") + + H5ConversionTests ( + ${HDF_PREFIX}_LDOUBLE_TO_FLOAT16_CORRECT + TRUE + "Checking if correctly converting long double to _Float16 values" + ) - set (${HDF_PREFIX}_HAVE__FLOAT16 1) + set (CMAKE_C_FLAGS "${cmake_c_flags_backup}") + + if (NOT ${${HDF_PREFIX}_LDOUBLE_TO_FLOAT16_CORRECT}) + message (VERBOSE "Conversions from long double to _Float16 appear to be incorrect. These will be emulated through a soft conversion function.") + endif () - # Check if we can use fabsf16 - CHECK_FUNCTION_EXISTS (fabsf16 ${HDF_PREFIX}_HAVE_FABSF16) + set (${HDF_PREFIX}_HAVE__FLOAT16 1) + + # Check if we can use fabsf16 + CHECK_FUNCTION_EXISTS (fabsf16 ${HDF_PREFIX}_HAVE_FABSF16) + else () + message (STATUS "_Float16 support has been disabled because the compiler couldn't compile and run a test program for _Float16 conversions") + message (STATUS "Check ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log for information on why the test program couldn't be compiled/run") + endif () else () - message (STATUS "_Float16 support has been disabled because the compiler couldn't compile and run a test program for _Float16 conversions") - message (STATUS "Check ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log for information on why the test program couldn't be compiled/run") + message (STATUS "_Float16 support has been disabled since the required macros (FLT16_MAX, FLT16_EPSILON, etc. were not found)") endif () else () - message (STATUS "_Float16 support has been disabled since the required macros (FLT16_MAX, FLT16_EPSILON, etc. were not found)") + message (STATUS "_Float16 support has been disabled since the _Float16 type was not found") endif () else () - message (STATUS "_Float16 support has been disabled since the _Float16 type was not found") + set (${HDF_PREFIX}_SIZEOF__FLOAT16 0 CACHE INTERNAL "SizeOf for ${HDF_PREFIX}_SIZEOF__FLOAT16") + unset (${HDF_PREFIX}_HAVE__FLOAT16 CACHE) + unset (${HDF_PREFIX}_LDOUBLE_TO_FLOAT16_CORRECT CACHE) endif () diff --git a/config/cmake/hdf5-config.cmake.in b/config/cmake/hdf5-config.cmake.in index 987411533af..ad1c30bcd80 100644 --- a/config/cmake/hdf5-config.cmake.in +++ b/config/cmake/hdf5-config.cmake.in @@ -54,6 +54,8 @@ set (${HDF5_PACKAGE_NAME}_BUILD_TOOLS @HDF5_BUILD_TOOLS@) set (${HDF5_PACKAGE_NAME}_BUILD_HL_GIF_TOOLS @HDF5_BUILD_HL_GIF_TOOLS@) set (${HDF5_PACKAGE_NAME}_BUILD_STATIC_TOOLS @HDF5_BUILD_STATIC_TOOLS@) #----------------------------------------------------------------------------- +set (${HDF5_PACKAGE_NAME}_ENABLE_NONSTANDARD_FEATURE_FLOAT16 @HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16@) +#----------------------------------------------------------------------------- set (${HDF5_PACKAGE_NAME}_ENABLE_Z_LIB_SUPPORT @HDF5_ENABLE_Z_LIB_SUPPORT@) set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_SUPPORT @HDF5_ENABLE_SZIP_SUPPORT@) set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_ENCODING @HDF5_ENABLE_SZIP_ENCODING@) diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index abf33c734f2..bbe6674007d 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -78,6 +78,7 @@ Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@ Default API mapping: @DEFAULT_API_VERSION@ With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@ I/O filters (external): @EXTERNAL_FILTERS@ + _Float16 support: @HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16@ Map (H5M) API: @H5_HAVE_MAP_API@ Direct VFD: @HDF5_ENABLE_DIRECT_VFD@ Mirror VFD: @H5_HAVE_MIRROR_VFD@ diff --git a/configure.ac b/configure.ac index 962405abcf3..4861bf9d976 100644 --- a/configure.ac +++ b/configure.ac @@ -574,104 +574,156 @@ AC_CHECK_SIZEOF([float]) AC_CHECK_SIZEOF([double]) AC_CHECK_SIZEOF([long double]) +#----------------------------------------------------------------------------- +# Option for enabling/disabling support for non-standard features, datatypes, +# etc. These features should still be checked for at configure time, but these +# options allow disabling of support for these features when compiler support +# is incomplete or broken. In this case, configure time checks may not be +# enough to properly enable/disable a feature and can cause library build +# problems. +#----------------------------------------------------------------------------- +AC_MSG_CHECKING([if non-standard feature support is enabled]) +AC_ARG_ENABLE([nonstandard-features], + [AS_HELP_STRING([--enable-nonstandard-features], + [Enable support for non-standard programming language features [default=yes]])], + [NONSTANDARD_FEATURES=$enableval]) + +## Set default +if test "X-$NONSTANDARD_FEATURES" = X- ; then + NONSTANDARD_FEATURES=yes +fi + +case "X-$NONSTANDARD_FEATURES" in + X-yes|X-no) + AC_MSG_RESULT([$NONSTANDARD_FEATURES]) + ;; + *) + AC_MSG_ERROR([Unrecognized value: $NONSTANDARD_FEATURES]) + ;; +esac + ## ---------------------------------------------------------------------- ## Check if _Float16 support is available ## -AC_MSG_NOTICE([checking if _Float16 support is available]) -HAVE__FLOAT16="no" -AC_CHECK_SIZEOF([_Float16]) -if test "$ac_cv_sizeof__Float16" != 0; then - # Some compilers expose the _Float16 datatype, but not the macros and - # functions used with the datatype. We need the macros for proper - # datatype conversion support. Check for these here. - AC_CHECK_DECL([FLT16_EPSILON], [], [], [[ - #define __STDC_WANT_IEC_60559_TYPES_EXT__ - #include ]]) - AC_CHECK_DECL([FLT16_MIN], [], [], [[ - #define __STDC_WANT_IEC_60559_TYPES_EXT__ - #include ]]) - AC_CHECK_DECL([FLT16_MAX], [], [], [[ - #define __STDC_WANT_IEC_60559_TYPES_EXT__ - #include ]]) - AC_CHECK_DECL([FLT16_MIN_10_EXP], [], [], [[ - #define __STDC_WANT_IEC_60559_TYPES_EXT__ - #include ]]) - AC_CHECK_DECL([FLT16_MAX_10_EXP], [], [], [[ - #define __STDC_WANT_IEC_60559_TYPES_EXT__ - #include ]]) - AC_CHECK_DECL([FLT16_MANT_DIG], [], [], [[ - #define __STDC_WANT_IEC_60559_TYPES_EXT__ - #include ]]) - - if test "X$ac_cv_have_decl_FLT16_EPSILON" = "Xyes" && - test "X$ac_cv_have_decl_FLT16_MIN" = "Xyes" && - test "X$ac_cv_have_decl_FLT16_MAX" = "Xyes" && - test "X$ac_cv_have_decl_FLT16_MIN_10_EXP" = "Xyes" && - test "X$ac_cv_have_decl_FLT16_MAX_10_EXP" = "Xyes" && - test "X$ac_cv_have_decl_FLT16_MANT_DIG" = "Xyes" ; then - # Some compilers like OneAPI on Windows appear to detect _Float16 support - # properly up to this point, and, in the absence of any architecture-specific - # tuning compiler flags, will generate code for H5Tconv.c that performs - # software conversions on _Float16 variables with compiler-internal functions - # such as __extendhfsf2, __truncsfhf2, or __truncdfhf2. However, these - # compilers will fail to link these functions into the build for currently - # unknown reasons and cause the build to fail. Since these are compiler-internal - # functions that we don't appear to have much control over, let's try to - # compile a program that will generate these functions to check for _Float16 - # support. If we fail to compile this program, we will simply disable - # _Float16 support for the time being. - AC_MSG_CHECKING([if compiler can correctly compile and run a test program which converts _Float16 to other types with casts]) - TEST_SRC="`(echo \"#define H5_FLOAT16_CONVERSION_FUNCS_LINK_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" - AC_CACHE_VAL([hdf5_cv_float16_conversion_funcs_link], - [AC_RUN_IFELSE( - [AC_LANG_SOURCE([$TEST_SRC])], - [hdf5_cv_float16_conversion_funcs_link=yes], [hdf5_cv_float16_conversion_funcs_link=no], [hdf5_cv_float16_conversion_funcs_link=no])]) - - if test ${hdf5_cv_float16_conversion_funcs_link} = "yes"; then - AC_MSG_RESULT([yes]) +AC_MSG_CHECKING([if _Float16 support is enabled]) +AC_ARG_ENABLE([nonstandard-feature-float16], + [AS_HELP_STRING([--enable-nonstandard-feature-float16], + [Enable support for _Float16 C datatype [default=yes]])], + [ENABLE_FLOAT16=$enableval]) - # Finally, MacOS 13 appears to have a bug specifically when converting - # long double values to _Float16. Release builds of the dt_arith test - # would cause any assignments to a _Float16 variable to be elided, - # whereas Debug builds would perform incorrect hardware conversions by - # simply chopping off all the bytes of the value except for the first 2. - # These tests pass on MacOS 14, so let's perform a quick test to check - # if the hardware conversion is done correctly. - AC_MSG_CHECKING([if compiler can correctly convert long double values to _Float16]) - TEST_SRC="`(echo \"#define H5_LDOUBLE_TO_FLOAT16_CORRECT_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" - if test ${ac_cv_sizeof_long_double} = 0; then - hdf5_cv_ldouble_to_float16_correct=${hdf5_cv_ldouble_to_float16_correct=no} - else - AC_CACHE_VAL([hdf5_cv_ldouble_to_float16_correct], - [AC_RUN_IFELSE( - [AC_LANG_SOURCE([$TEST_SRC])], - [hdf5_cv_ldouble_to_float16_correct=yes], [hdf5_cv_ldouble_to_float16_correct=no], [hdf5_cv_ldouble_to_float16_correct=yes])]) - fi +## Set default +if test "X-$ENABLE_FLOAT16" = X- ; then + ENABLE_FLOAT16=$NONSTANDARD_FEATURES +fi - if test ${hdf5_cv_ldouble_to_float16_correct} = "yes"; then - AC_DEFINE([LDOUBLE_TO_FLOAT16_CORRECT], [1], - [Define if your system can convert long double to _Float16 values correctly.]) +case "X-$ENABLE_FLOAT16" in + X-yes|X-no) + AC_MSG_RESULT([$ENABLE_FLOAT16]) + ;; + *) + AC_MSG_ERROR([Unrecognized value: $ENABLE_FLOAT16]) + ;; +esac + +HAVE__FLOAT16="no" +if test "X$ENABLE_FLOAT16" = "Xyes"; then + AC_MSG_NOTICE([checking if _Float16 support is available]) + AC_CHECK_SIZEOF([_Float16]) + if test "$ac_cv_sizeof__Float16" != 0; then + # Some compilers expose the _Float16 datatype, but not the macros and + # functions used with the datatype. We need the macros for proper + # datatype conversion support. Check for these here. + AC_CHECK_DECL([FLT16_EPSILON], [], [], [[ + #define __STDC_WANT_IEC_60559_TYPES_EXT__ + #include ]]) + AC_CHECK_DECL([FLT16_MIN], [], [], [[ + #define __STDC_WANT_IEC_60559_TYPES_EXT__ + #include ]]) + AC_CHECK_DECL([FLT16_MAX], [], [], [[ + #define __STDC_WANT_IEC_60559_TYPES_EXT__ + #include ]]) + AC_CHECK_DECL([FLT16_MIN_10_EXP], [], [], [[ + #define __STDC_WANT_IEC_60559_TYPES_EXT__ + #include ]]) + AC_CHECK_DECL([FLT16_MAX_10_EXP], [], [], [[ + #define __STDC_WANT_IEC_60559_TYPES_EXT__ + #include ]]) + AC_CHECK_DECL([FLT16_MANT_DIG], [], [], [[ + #define __STDC_WANT_IEC_60559_TYPES_EXT__ + #include ]]) + + if test "X$ac_cv_have_decl_FLT16_EPSILON" = "Xyes" && + test "X$ac_cv_have_decl_FLT16_MIN" = "Xyes" && + test "X$ac_cv_have_decl_FLT16_MAX" = "Xyes" && + test "X$ac_cv_have_decl_FLT16_MIN_10_EXP" = "Xyes" && + test "X$ac_cv_have_decl_FLT16_MAX_10_EXP" = "Xyes" && + test "X$ac_cv_have_decl_FLT16_MANT_DIG" = "Xyes" ; then + # Some compilers like OneAPI on Windows appear to detect _Float16 support + # properly up to this point, and, in the absence of any architecture-specific + # tuning compiler flags, will generate code for H5Tconv.c that performs + # software conversions on _Float16 variables with compiler-internal functions + # such as __extendhfsf2, __truncsfhf2, or __truncdfhf2. However, these + # compilers will fail to link these functions into the build for currently + # unknown reasons and cause the build to fail. Since these are compiler-internal + # functions that we don't appear to have much control over, let's try to + # compile a program that will generate these functions to check for _Float16 + # support. If we fail to compile this program, we will simply disable + # _Float16 support for the time being. + AC_MSG_CHECKING([if compiler can correctly compile and run a test program which converts _Float16 to other types with casts]) + TEST_SRC="`(echo \"#define H5_FLOAT16_CONVERSION_FUNCS_LINK_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" + AC_CACHE_VAL([hdf5_cv_float16_conversion_funcs_link], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([$TEST_SRC])], + [hdf5_cv_float16_conversion_funcs_link=yes], [hdf5_cv_float16_conversion_funcs_link=no], [hdf5_cv_float16_conversion_funcs_link=no])]) + + if test ${hdf5_cv_float16_conversion_funcs_link} = "yes"; then AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - AC_MSG_NOTICE([Conversions from long double to _Float16 appear to be incorrect. These will be emulated through a soft conversion function.]) - fi - HAVE__FLOAT16="yes" + # Finally, MacOS 13 appears to have a bug specifically when converting + # long double values to _Float16. Release builds of the dt_arith test + # would cause any assignments to a _Float16 variable to be elided, + # whereas Debug builds would perform incorrect hardware conversions by + # simply chopping off all the bytes of the value except for the first 2. + # These tests pass on MacOS 14, so let's perform a quick test to check + # if the hardware conversion is done correctly. + AC_MSG_CHECKING([if compiler can correctly convert long double values to _Float16]) + TEST_SRC="`(echo \"#define H5_LDOUBLE_TO_FLOAT16_CORRECT_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`" + if test ${ac_cv_sizeof_long_double} = 0; then + hdf5_cv_ldouble_to_float16_correct=${hdf5_cv_ldouble_to_float16_correct=no} + else + AC_CACHE_VAL([hdf5_cv_ldouble_to_float16_correct], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([$TEST_SRC])], + [hdf5_cv_ldouble_to_float16_correct=yes], [hdf5_cv_ldouble_to_float16_correct=no], [hdf5_cv_ldouble_to_float16_correct=yes])]) + fi + + if test ${hdf5_cv_ldouble_to_float16_correct} = "yes"; then + AC_DEFINE([LDOUBLE_TO_FLOAT16_CORRECT], [1], + [Define if your system can convert long double to _Float16 values correctly.]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_NOTICE([Conversions from long double to _Float16 appear to be incorrect. These will be emulated through a soft conversion function.]) + fi + + HAVE__FLOAT16="yes" - # Check if we can use fabsf16 - AC_CHECK_FUNC([fabsf16], [AC_DEFINE([HAVE_FABSF16], [1], - [Define if has fabsf16 function])], []) + # Check if we can use fabsf16 + AC_CHECK_FUNC([fabsf16], [AC_DEFINE([HAVE_FABSF16], [1], + [Define if has fabsf16 function])], []) - # Define HAVE__FLOAT16 macro for H5pubconf.h if _Float16 is available. - AC_DEFINE([HAVE__FLOAT16], [1], [Determine if _Float16 is available]) - else - AC_MSG_RESULT([no]) + # Define HAVE__FLOAT16 macro for H5pubconf.h if _Float16 is available. + AC_DEFINE([HAVE__FLOAT16], [1], [Determine if _Float16 is available]) + else + AC_MSG_RESULT([no]) + fi fi - fi - AC_MSG_CHECKING([if _Float16 support is enabled]) - AC_MSG_RESULT([$HAVE__FLOAT16]) + AC_MSG_CHECKING([if _Float16 support is enabled]) + AC_MSG_RESULT([$HAVE__FLOAT16]) + fi +else + AC_DEFINE([SIZEOF__FLOAT16], [0]) fi # Define HAVE__FLOAT16 value to substitute into other files for conditional testing diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 04472243097..4a160df6294 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -47,6 +47,36 @@ New Features Configuration: ------------- + - Added configure options for enabling/disabling non-standard programming + language features + + * Added a new configuration option that allows enabling or disabling of + support for features that are extensions to programming languages, such + as support for the _Float16 datatype: + + CMake: HDF5_ENABLE_NONSTANDARD_FEATURES (ON/OFF) (Default: ON) + Autotools: --enable-nonstandard-features (yes/no) (Default: yes) + + When this option is enabled, configure time checks are still performed + to ensure that a feature can be used properly, but these checks may not + be sufficient when compiler support for a feature is incomplete or broken, + resulting in library build failures. When set to OFF/no, this option + provides a way to disable support for all non-standard features to avoid + these issues. Individual features can still be re-enabled with their + respective configuration options. + + * Added a new configuration option that allows enabling or disabling of + support for the _Float16 C datatype: + + CMake: HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16 (ON/OFF) (Default: ON) + Autotools: --enable-nonstandard-feature-float16 (yes/no) (Default: yes) + + While support for the _Float16 C datatype can generally be detected and + used properly, some compilers have incomplete support for the datatype + and will pass configure time checks while still failing to build HDF5. + This option provides a way to disable support for the _Float16 datatype + when the compiler doesn't have the proper support for it. + - Deprecate bin/cmakehdf5 script With the improvements made in CMake since version 3.23 and the addition diff --git a/src/H5build_settings.autotools.c.in b/src/H5build_settings.autotools.c.in index abdc53a9cd3..edde377b43a 100644 --- a/src/H5build_settings.autotools.c.in +++ b/src/H5build_settings.autotools.c.in @@ -99,6 +99,7 @@ const char H5build_settings[]= " Default API mapping: @DEFAULT_API_VERSION@\n" " With deprecated public symbols: @DEPRECATED_SYMBOLS@\n" " I/O filters (external): @EXTERNAL_FILTERS@\n" + " _Float16 support: @HAVE__FLOAT16@\n" " Map (H5M) API: @MAP_API@\n" " Direct VFD: @DIRECT_VFD@\n" " Mirror VFD: @MIRROR_VFD@\n" diff --git a/src/H5build_settings.cmake.c.in b/src/H5build_settings.cmake.c.in index 67ebec7e45d..c1139b465e6 100644 --- a/src/H5build_settings.cmake.c.in +++ b/src/H5build_settings.cmake.c.in @@ -98,6 +98,7 @@ const char H5build_settings[]= " Default API mapping: @DEFAULT_API_VERSION@\n" " With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@\n" " I/O filters (external): @EXTERNAL_FILTERS@\n" + " _Float16 support: @HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16@\n" " Map (H5M) API: @H5_HAVE_MAP_API@\n" " Direct VFD: @H5_HAVE_DIRECT@\n" " Mirror VFD: @H5_HAVE_MIRROR_VFD@\n" diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index f9e7928e7e1..87219969bf3 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -80,6 +80,7 @@ Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@ Default API mapping: @DEFAULT_API_VERSION@ With deprecated public symbols: @DEPRECATED_SYMBOLS@ I/O filters (external): @EXTERNAL_FILTERS@ + _Float16 support: @HAVE__FLOAT16@ Map (H5M) API: @MAP_API@ Direct VFD: @DIRECT_VFD@ Mirror VFD: @MIRROR_VFD@