Skip to content

Commit c542991

Browse files
authored
[flang-rt] Fixed HAVE_LDBL_MANT_DIG_113 detection. (llvm#131010)
I thought I guessed a fix in llvm#130836, but I was wrong. We actually had the same code in `flang/cmake/modules/FlangCommon.cmake`. The check does not pass in flang-rt bootstrap build, because `-nostdinc++` is added for all `runtimes` checks. I decided to make the check with the C header, though, I am still unsure whether it is reliable with a clang that has not been installed (it is taken from the build structure during flang-rt configure step). I verified that this PR enables REAL(16) math entries on aarch64.
1 parent 726ffd3 commit c542991

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

flang-rt/CMakeLists.txt

-11
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,6 @@ elseif (FLANG_RT_GCC_RESOURCE_DIR)
293293
endif ()
294294
endif ()
295295

296-
# Check if 128-bit float computations can be done via long double.
297-
check_cxx_source_compiles(
298-
"#include <cfloat>
299-
#if LDBL_MANT_DIG != 113
300-
#error LDBL_MANT_DIG != 113
301-
#endif
302-
int main() { return 0; }
303-
"
304-
HAVE_LDBL_MANT_DIG_113)
305-
306-
307296
#####################
308297
# Build Preparation #
309298
#####################

flang/cmake/modules/FlangCommon.cmake

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
2525
endif()
2626

2727
# Check if 128-bit float computations can be done via long double
28-
check_cxx_source_compiles(
29-
"#include <cfloat>
28+
# Note that '-nostdinc++' might be implied when this code kicks in
29+
# (see 'runtimes/CMakeLists.txt'), so we cannot use 'cfloat' C++ header
30+
# file in the test below.
31+
# Compile it as C.
32+
check_c_source_compiles(
33+
"#include <float.h>
3034
#if LDBL_MANT_DIG != 113
3135
#error LDBL_MANT_DIG != 113
3236
#endif

0 commit comments

Comments
 (0)