[flang-commits] [flang] [flang] Adjust _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT for Solaris (PR #74590)

Rainer Orth via flang-commits flang-commits at lists.llvm.org
Thu Dec 14 01:23:09 PST 2023


https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/74590

>From 8a2b40ae63b19d085d3c12f82059a7f0bcc0f128 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Wed, 6 Dec 2023 14:46:21 +0100
Subject: [PATCH 1/2] [flang] Adjust _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT for
 Solaris

Even after 13e2200fa426faffb62bdaf8b2f1f5699eee1511 (Solaris lacks
`femode_t`, too), the Solaris flang build is still broken:

/vol/llvm/src/llvm-project/local/flang/runtime/exceptions.cpp:87:5: error: static assertion failed due to requirement 'sizeof(fenv_t) <= sizeof(int) * 8': increase ieee_status_type size
   87 |     sizeof(fenv_t) <= sizeof(int) * _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT,      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/vol/llvm/src/llvm-project/local/flang/runtime/exceptions.cpp:87:20: note: expression evaluates to '200 <= 32'
   87 |     sizeof(fenv_t) <= sizeof(int) * _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT,      |     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch fixes this by adjusting `_FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT`
accordingly.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.
---
 flang/include/flang/Runtime/magic-numbers.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/include/flang/Runtime/magic-numbers.h b/flang/include/flang/Runtime/magic-numbers.h
index d00d5027d4ed27..cebf9f3a65478d 100644
--- a/flang/include/flang/Runtime/magic-numbers.h
+++ b/flang/include/flang/Runtime/magic-numbers.h
@@ -107,6 +107,6 @@ as int arrays with the following extents to allow build time validation of
 these sizes in cross compilation environments.
 #endif
 #define _FORTRAN_RUNTIME_IEEE_FEMODE_T_EXTENT 2
-#define _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT 8
+#define _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT 50
 
 #endif

>From 49fa1c93ecf08d34968f3c4072876868387a94a6 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Thu, 14 Dec 2023 10:22:22 +0100
Subject: [PATCH 2/2] Disable assertion with explanatory comment.

---
 flang/include/flang/Runtime/magic-numbers.h | 2 +-
 flang/runtime/exceptions.cpp                | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/flang/include/flang/Runtime/magic-numbers.h b/flang/include/flang/Runtime/magic-numbers.h
index cebf9f3a65478d..d00d5027d4ed27 100644
--- a/flang/include/flang/Runtime/magic-numbers.h
+++ b/flang/include/flang/Runtime/magic-numbers.h
@@ -107,6 +107,6 @@ as int arrays with the following extents to allow build time validation of
 these sizes in cross compilation environments.
 #endif
 #define _FORTRAN_RUNTIME_IEEE_FEMODE_T_EXTENT 2
-#define _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT 50
+#define _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT 8
 
 #endif
diff --git a/flang/runtime/exceptions.cpp b/flang/runtime/exceptions.cpp
index 1dbee833884fbc..dfd3b812e22a13 100644
--- a/flang/runtime/exceptions.cpp
+++ b/flang/runtime/exceptions.cpp
@@ -78,10 +78,10 @@ std::int32_t RTNAME(MapException)(int32_t except) {
 // Verify that the size of ieee_modes_type and ieee_status_type objects from
 // intrinsic module file __fortran_ieee_exceptions.f90 are large enough to
 // hold fenv_t object.
+// TODO: fenv_t can be way larger than
+//	sizeof(int) * _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT
+// on some systems, e.g. Solaris, so omit object size comparison for now.
 // TODO: consider femode_t object size comparison once its more mature.
-static_assert(
-    sizeof(fenv_t) <= sizeof(int) * _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT,
-    "increase ieee_status_type size");
 
 } // extern "C"
 } // namespace Fortran::runtime



More information about the flang-commits mailing list