diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2023-11-15 04:36:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 04:36:47 (GMT) |
commit | e807dee0fd6c007d7c41327c1ed0e8f5bc617f72 (patch) | |
tree | 1215d6c4865a60a40a74e96dbcfb80c284ae12d1 /config/cmake/ConfigureChecks.cmake | |
parent | f39b228a4cda701c363d4c32dced4065dd86dc3e (diff) | |
download | hdf5-e807dee0fd6c007d7c41327c1ed0e8f5bc617f72.zip hdf5-e807dee0fd6c007d7c41327c1ed0e8f5bc617f72.tar.gz hdf5-e807dee0fd6c007d7c41327c1ed0e8f5bc617f72.tar.bz2 |
Add CMake long double cross-compile defaults (#3683)
HDF5 performs a couple of checks at build time to see if long double
values can be converted correctly (IBM's Power architecture uses a
special format for long doubles). These checks were performed using
TRY_RUN, which is a problem when cross-compiling.
These checks now use default values appropriate for most non-Power
systems when cross-compiling. The cache values can be pre-set if
necessary, which will preempt both the TRY_RUN and the default.
Affected values:
H5_LDOUBLE_TO_LONG_SPECIAL (default no)
H5_LONG_TO_LDOUBLE_SPECIAL (default no)
H5_LDOUBLE_TO_LLONG_ACCURATE (default yes)
H5_LLONG_TO_LDOUBLE_CORRECT (default yes)
H5_DISABLE_SOME_LDOUBLE_CONV (default no)
Fixes GitHub #3585
Diffstat (limited to 'config/cmake/ConfigureChecks.cmake')
-rw-r--r-- | config/cmake/ConfigureChecks.cmake | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 3d4c23b..8013363 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -872,35 +872,46 @@ if (HDF5_BUILD_FORTRAN) endif() #----------------------------------------------------------------------------- -# Macro to determine the various conversion capabilities +# Macro to determine long double conversion properties #----------------------------------------------------------------------------- -macro (H5ConversionTests TEST msg) +macro (H5ConversionTests TEST def msg) if (NOT DEFINED ${TEST}) - TRY_RUN (${TEST}_RUN ${TEST}_COMPILE - ${CMAKE_BINARY_DIR} - ${HDF_RESOURCES_DIR}/ConversionTests.c - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-D${TEST}_TEST - OUTPUT_VARIABLE OUTPUT - ) - if (${TEST}_COMPILE) - if (${TEST}_RUN EQUAL "0") - set (${TEST} 1 CACHE INTERNAL ${msg}) - message (VERBOSE "${msg}... yes") + if (NOT CMAKE_CROSSCOMPILING) + # Build and run the test code if not cross-compiling + TRY_RUN (${TEST}_RUN ${TEST}_COMPILE + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_DIR}/ConversionTests.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-D${TEST}_TEST + OUTPUT_VARIABLE OUTPUT + ) + if (${TEST}_COMPILE) + if (${TEST}_RUN EQUAL "0") + set (${TEST} 1 CACHE INTERNAL ${msg}) + message (VERBOSE "${msg}... yes") + else () + set (${TEST} "" CACHE INTERNAL ${msg}) + message (VERBOSE "${msg}... no") + file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Test ${TEST} Run failed with the following output and exit code:\n ${OUTPUT}\n" + ) + endif () else () set (${TEST} "" CACHE INTERNAL ${msg}) message (VERBOSE "${msg}... no") file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log - "Test ${TEST} Run failed with the following output and exit code:\n ${OUTPUT}\n" + "Test ${TEST} Compile failed with the following output:\n ${OUTPUT}\n" ) endif () else () - set (${TEST} "" CACHE INTERNAL ${msg}) - message (VERBOSE "${msg}... no") - file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log - "Test ${TEST} Compile failed with the following output:\n ${OUTPUT}\n" - ) + # Use the default if there's no cache variable and cross-compiling + if (${def}) + message (VERBOSE "${msg}... yes (cross-compile default)") + set (${TEST} 1 CACHE INTERNAL ${msg}) + else () + message (VERBOSE "${msg}... no (cross-compile default)") + set (${TEST} "" CACHE INTERNAL ${msg}) + endif () endif () - endif () endmacro () @@ -917,7 +928,7 @@ endmacro () # The machine's conversion gets the correct value. We define the macro and disable # this kind of test until we figure out what algorithm they use. #----------------------------------------------------------------------------- -H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LONG_SPECIAL "Checking IF your system converts long double to (unsigned) long values with special algorithm") +H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LONG_SPECIAL FALSE "Checking IF your system converts long double to (unsigned) long values with special algorithm") # ---------------------------------------------------------------------- # Set the flag to indicate that the machine is using a special algorithm # to convert some values of '(unsigned) long' to 'long double' values. @@ -926,7 +937,7 @@ H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LONG_SPECIAL "Checking IF your syst # ..., 7fffff..., the compiler uses a unknown algorithm. We define a # macro and skip the test for now until we know about the algorithm. #----------------------------------------------------------------------------- -H5ConversionTests (${HDF_PREFIX}_LONG_TO_LDOUBLE_SPECIAL "Checking IF your system can convert (unsigned) long to long double values with special algorithm") +H5ConversionTests (${HDF_PREFIX}_LONG_TO_LDOUBLE_SPECIAL FALSE "Checking IF your system can convert (unsigned) long to long double values with special algorithm") # ---------------------------------------------------------------------- # Set the flag to indicate that the machine can accurately convert # 'long double' to '(unsigned) long long' values. (This flag should be set for @@ -936,7 +947,7 @@ H5ConversionTests (${HDF_PREFIX}_LONG_TO_LDOUBLE_SPECIAL "Checking IF your syste # 0x4351ccf385ebc8a0dfcc... or 0x4351ccf385ebc8a0ffcc... will make the converted # values wildly wrong. This test detects this wrong behavior and disable the test. #----------------------------------------------------------------------------- -H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LLONG_ACCURATE "Checking IF correctly converting long double to (unsigned) long long values") +H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LLONG_ACCURATE TRUE "Checking IF correctly converting long double to (unsigned) long long values") # ---------------------------------------------------------------------- # Set the flag to indicate that the machine can accurately convert # '(unsigned) long long' to 'long double' values. (This flag should be set for @@ -944,9 +955,9 @@ H5ConversionTests (${HDF_PREFIX}_LDOUBLE_TO_LLONG_ACCURATE "Checking IF correctl # 007fff..., 00ffff..., 01ffff..., ..., 7fffff..., the converted values are twice # as big as they should be. #----------------------------------------------------------------------------- -H5ConversionTests (${HDF_PREFIX}_LLONG_TO_LDOUBLE_CORRECT "Checking IF correctly converting (unsigned) long long to long double values") +H5ConversionTests (${HDF_PREFIX}_LLONG_TO_LDOUBLE_CORRECT TRUE "Checking IF correctly converting (unsigned) long long to long double values") # ---------------------------------------------------------------------- # Set the flag to indicate that the machine can accurately convert # some long double values #----------------------------------------------------------------------------- -H5ConversionTests (${HDF_PREFIX}_DISABLE_SOME_LDOUBLE_CONV "Checking IF the cpu is power9 and cannot correctly converting long double values") +H5ConversionTests (${HDF_PREFIX}_DISABLE_SOME_LDOUBLE_CONV FALSE "Checking IF the cpu is power9 and cannot correctly converting long double values") |