[flang-commits] [flang] c542991 - [flang-rt] Fixed HAVE_LDBL_MANT_DIG_113 detection. (#131010)

via flang-commits flang-commits at lists.llvm.org
Wed Mar 12 16:50:04 PDT 2025


Author: Slava Zakharin
Date: 2025-03-12T16:50:01-07:00
New Revision: c542991703956bdc42ad6ab07b1d47e5db06fb2b

URL: https://github.com/llvm/llvm-project/commit/c542991703956bdc42ad6ab07b1d47e5db06fb2b
DIFF: https://github.com/llvm/llvm-project/commit/c542991703956bdc42ad6ab07b1d47e5db06fb2b.diff

LOG: [flang-rt] Fixed HAVE_LDBL_MANT_DIG_113 detection. (#131010)

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.

Added: 
    

Modified: 
    flang-rt/CMakeLists.txt
    flang/cmake/modules/FlangCommon.cmake

Removed: 
    


################################################################################
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 <cfloat>
-   #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 <cfloat>
+# 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 <float.h>
    #if LDBL_MANT_DIG != 113
    #error LDBL_MANT_DIG != 113
    #endif


        


More information about the flang-commits mailing list