From 54626b98b69e3c4d33dd692e200972b0f1dcde42 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Wed, 12 Mar 2025 11:34:55 -0700 Subject: [PATCH] [flang-rt] Fixed HAVE_LDBL_MANT_DIG_113 detection. I thought I guessed a fix in #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. --- flang-rt/CMakeLists.txt | 11 ----------- flang/cmake/modules/FlangCommon.cmake | 8 ++++++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt index 70b114041b7fd..9bc40e111c6bb 100644 --- a/flang-rt/CMakeLists.txt +++ b/flang-rt/CMakeLists.txt @@ -293,17 +293,6 @@ elseif (FLANG_RT_GCC_RESOURCE_DIR) endif () endif () -# Check if 128-bit float computations can be done via long double. -check_cxx_source_compiles( - "#include - #if LDBL_MANT_DIG != 113 - #error LDBL_MANT_DIG != 113 - #endif - int main() { return 0; } - " - HAVE_LDBL_MANT_DIG_113) - - ##################### # Build Preparation # ##################### diff --git a/flang/cmake/modules/FlangCommon.cmake b/flang/cmake/modules/FlangCommon.cmake index 1b8606843b224..bb2a76cb19453 100644 --- a/flang/cmake/modules/FlangCommon.cmake +++ b/flang/cmake/modules/FlangCommon.cmake @@ -25,8 +25,12 @@ if (FLANG_RUNTIME_F128_MATH_LIB) endif() # Check if 128-bit float computations can be done via long double -check_cxx_source_compiles( - "#include +# Note that '-nostdinc++' might be implied when this code kicks in +# (see 'runtimes/CMakeLists.txt'), so we cannot use 'cfloat' C++ header +# file in the test below. +# Compile it as C. +check_c_source_compiles( + "#include #if LDBL_MANT_DIG != 113 #error LDBL_MANT_DIG != 113 #endif