[compiler-rt] Found one more delta to unbreak build for z/os (PR #82789)

Sean Perry via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 11:12:25 PDT 2024


https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/82789

>From 66989a1d5937d2eadcf7658a16a8fd8eced23a00 Mon Sep 17 00:00:00 2001
From: Sean Perry <perry at ca.ibm.com>
Date: Fri, 23 Feb 2024 10:32:52 -0600
Subject: [PATCH 1/3] fix build for z/os

---
 compiler-rt/lib/builtins/fp_lib.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h
index c4f0a5b9587f77..48adea3619cf44 100644
--- a/compiler-rt/lib/builtins/fp_lib.h
+++ b/compiler-rt/lib/builtins/fp_lib.h
@@ -383,10 +383,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) {
 #endif
 }
 
-#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE)
+#elif defined(QUAD_PRECISION)
+#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF)
 // The generic implementation only works for ieee754 floating point. For other
 // floating point types, continue to rely on the libm implementation for now.
-#if defined(CRT_HAS_IEEE_TF)
 static __inline tf_float __compiler_rt_logbtf(tf_float x) {
   return __compiler_rt_logbX(x);
 }

>From 6c45d601a845035f297973a7bc928be21dfe16cc Mon Sep 17 00:00:00 2001
From: Sean Perry <perry at ca.ibm.com>
Date: Fri, 6 Sep 2024 09:14:04 -0500
Subject: [PATCH 2/3] Fix files so div & mult are included for z/OS and
 excluded for 32-bit sparc

---
 compiler-rt/lib/builtins/CMakeLists.txt | 11 +++++++++--
 compiler-rt/lib/builtins/divtc3.c       |  2 +-
 compiler-rt/lib/builtins/multc3.c       |  2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 2c3b0fa84a4782..0b3ed34c37c055 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -755,8 +755,15 @@ set(riscv64_SOURCES
   ${riscv_SOURCES}
 )
 
-set(sparc_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
-set(sparcv9_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
+# Exclude the FT sources for 32-bit SPARC.  Clang doesn't
+# support 128-bit long double on 32-bit SPARC.
+if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "sparc")
+  set(sparc_SOURCES ${GENERIC_SOURCES})
+  set(sparcv9_SOURCES ${GENERIC_SOURCES})
+else()
+  set(sparc_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
+  set(sparcv9_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
+endif()
 
 set(wasm32_SOURCES
   ${GENERIC_TF_SOURCES}
diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c
index c393de815337ef..099de5802daf0e 100644
--- a/compiler-rt/lib/builtins/divtc3.c
+++ b/compiler-rt/lib/builtins/divtc3.c
@@ -13,7 +13,7 @@
 #define QUAD_PRECISION
 #include "fp_lib.h"
 
-#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
+#if defined(CRT_HAS_F128)
 
 // Returns: the quotient of (a + ib) / (c + id)
 
diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c
index a89832f0e883e5..61a3f45e47279c 100644
--- a/compiler-rt/lib/builtins/multc3.c
+++ b/compiler-rt/lib/builtins/multc3.c
@@ -15,7 +15,7 @@
 #include "int_lib.h"
 #include "int_math.h"
 
-#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
+#if defined(CRT_HAS_F128)
 
 // Returns: the product of a + ib and c + id
 

>From b151da0745fb409ab542161af77b3bbeb0471426 Mon Sep 17 00:00:00 2001
From: Sean Perry <perry at ca.ibm.com>
Date: Wed, 25 Sep 2024 10:15:26 -0500
Subject: [PATCH 3/3] reorg some more so sparc doesn't get error when
 CRT_HAS_TF_MODE isn't defined

---
 compiler-rt/lib/builtins/fp_lib.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h
index d0e1c2637fa007..e4a330d84ecf9c 100644
--- a/compiler-rt/lib/builtins/fp_lib.h
+++ b/compiler-rt/lib/builtins/fp_lib.h
@@ -369,7 +369,8 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) {
 }
 
 #elif defined(QUAD_PRECISION)
-#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF)
+#if defined(CRT_HAS_TF_MODE)
+#if defined(CRT_HAS_IEEE_TF)
 // The generic implementation only works for ieee754 floating point. For other
 // floating point types, continue to rely on the libm implementation for now.
 static __inline tf_float __compiler_rt_logbtf(tf_float x) {
@@ -386,6 +387,9 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) {
 #define __compiler_rt_fmaxl __compiler_rt_fmaxtf
 #define crt_fabstf crt_fabsf128
 #define crt_copysigntf crt_copysignf128
+#else
+#error Unsupported TF mode type
+#endif
 #elif defined(CRT_LDBL_128BIT)
 static __inline tf_float __compiler_rt_logbtf(tf_float x) {
   return crt_logbl(x);
@@ -401,8 +405,6 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) {
 #define __compiler_rt_fmaxl crt_fmaxl
 #define crt_fabstf crt_fabsl
 #define crt_copysigntf crt_copysignl
-#else
-#error Unsupported TF mode type
 #endif
 
 #endif // *_PRECISION



More information about the llvm-commits mailing list