[flang-commits] [flang] [Flang][Runtime] Handle missing definitions in <cfenv> (PR #101242)

via flang-commits flang-commits at lists.llvm.org
Wed Jul 31 01:11:11 PDT 2024


serge-sans-paille wrote:

NB: alternative patch

```
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 8588af7e16ee..c853c68e7298 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -82,6 +82,23 @@ check_cxx_source_compiles(
   "
   HAVE_LDBL_MANT_DIG_113)
 
+# Check if cfenv defines the expected macro
+foreach(fe_definition IN LISTS FE_UNDERFLOW FE_OVERFLOW FE_INEXACT FE_INVALID
+        FE_DIVBYZERO FE_ALL_EXCEPT)
+    check_cxx_source_compiles(
+        "#include <cfenv>
+         #ifndef ${fe_definition}
+         #error Missing ${fe_definition}
+         #endif
+        "
+        HAVE_${fe_definition}
+    )
+    if(NOT HAVE_${fe_definition})
+        add_compile_definitions(${fe_definition}=0)
+    endif()
+endforeach()
+
+
 check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
 if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
   set(NO_LTO_FLAGS "-fno-lto")



```

https://github.com/llvm/llvm-project/pull/101242


More information about the flang-commits mailing list