[flang-commits] [flang] 5196269 - [flang] Restrict __float128 support for some build configurations.

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Tue Oct 18 10:06:38 PDT 2022


Author: Slava Zakharin
Date: 2022-10-18T09:58:05-07:00
New Revision: 51962690d8879a13c3ec90e3d0d82b0151710aab

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

LOG: [flang] Restrict __float128 support for some build configurations.

This change is intended to resolve build issues reported in D134503.
A compiler supporting __float128 must define either __FLOAT128__ or
__SIZEOF_FLOAT128__ (or both). Additional check for _LIBCPP_VERSION
was added to disable __float128 for builds with libc++, because
__float128 support is incomplete there.

Differential Revision: https://reviews.llvm.org/D136121

Added: 
    

Modified: 
    flang/include/flang/Runtime/float128.h

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Runtime/float128.h b/flang/include/flang/Runtime/float128.h
index e222c6d2649a3..23629296eab73 100644
--- a/flang/include/flang/Runtime/float128.h
+++ b/flang/include/flang/Runtime/float128.h
@@ -20,7 +20,25 @@
 #ifndef FORTRAN_RUNTIME_FLOAT128_H_
 #define FORTRAN_RUNTIME_FLOAT128_H_
 
+#ifdef __cplusplus
+/*
+ * libc++ does not fully support __float128 right now, e.g.
+ * std::complex<__float128> multiplication ends up calling
+ * copysign() that is not defined for __float128.
+ * In order to check for libc++'s _LIBCPP_VERSION macro
+ * we need to include at least one libc++ header file.
+ */
+#include <cstddef>
+#endif
+
 #undef HAS_FLOAT128
+#if (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)) && \
+    !defined(_LIBCPP_VERSION)
+/*
+ * It may still be worth checking for compiler versions,
+ * since earlier versions may define the macros above, but
+ * still do not support __float128 fully.
+ */
 #if __x86_64__
 #if __GNUC__ >= 7 || __clang_major__ >= 7
 #define HAS_FLOAT128 1
@@ -28,5 +46,7 @@
 #elif defined __PPC__ && __GNUC__ >= 8
 #define HAS_FLOAT128 1
 #endif
+#endif /* (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)) && \
+          !defined(_LIBCPP_VERSION) */
 
 #endif /* FORTRAN_RUNTIME_FLOAT128_H_ */


        


More information about the flang-commits mailing list