[libc-commits] [libc] [libc] Add NEED_MPFR128 arguement (PR #215657)

via libc-commits libc-commits at lists.llvm.org
Wed Aug 12 11:03:05 PDT 2026


https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/215657

>From a3792832d71d6a87a41b64dd8804b19dfb566dd3 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 12 Aug 2026 02:12:18 +0530
Subject: [PATCH 1/3] add NEED_MPFR128

---
 libc/test/src/CMakeLists.txt | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index 2beeb5517ff3e..3101730b8a0e1 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -1,7 +1,7 @@
 function(add_fp_unittest name)
   cmake_parse_arguments(
     "MATH_UNITTEST"
-    "NEED_MPFR;NEED_MPC;FULL_BUILD_ONLY;OVERLAY_BUILD_ONLY" # Optional arguments
+    "NEED_MPFR;NEED_MPFR128;NEED_MPC;FULL_BUILD_ONLY;OVERLAY_BUILD_ONLY" # Optional arguments
     "" # Single value arguments
     "LINK_LIBRARIES;DEPENDS" # Multi-value arguments
     ${ARGN}
@@ -16,6 +16,16 @@ function(add_fp_unittest name)
     list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPCWrapper)
   endif()
 
+  # TODO: To be removed when we find a workaround to run MPFR tests for
+  # emulated type where compiler doesn't support the native float128
+  if(MATH_UNITTEST_NEED_MPFR128)
+    set(MATH_UNITTEST_NEED_MPFR TRUE)
+    if(NOT LIBC_TYPES_HAS_NATIVE_FLOAT128)
+      message(VERBOSE "Math test ${name} will be skipped as native float128 type is not available.")
+      return()
+    endif()
+  endif()
+
   if(MATH_UNITTEST_NEED_MPFR)
     if(NOT LIBC_TESTS_CAN_USE_MPFR)
       message(VERBOSE "Math test ${name} will be skipped as MPFR library is not available.")

>From 71b802aa9b721e44abebb3f4c2232a6921981e37 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 12 Aug 2026 23:06:04 +0530
Subject: [PATCH 2/3] nits

---
 libc/test/src/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index 3101730b8a0e1..a8e1fabc15377 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -1,7 +1,7 @@
 function(add_fp_unittest name)
   cmake_parse_arguments(
     "MATH_UNITTEST"
-    "NEED_MPFR;NEED_MPFR128;NEED_MPC;FULL_BUILD_ONLY;OVERLAY_BUILD_ONLY" # Optional arguments
+    "NEED_MPFR;NEED_MPFR_F128;NEED_MPC;FULL_BUILD_ONLY;OVERLAY_BUILD_ONLY" # Optional arguments
     "" # Single value arguments
     "LINK_LIBRARIES;DEPENDS" # Multi-value arguments
     ${ARGN}
@@ -21,7 +21,7 @@ function(add_fp_unittest name)
   if(MATH_UNITTEST_NEED_MPFR128)
     set(MATH_UNITTEST_NEED_MPFR TRUE)
     if(NOT LIBC_TYPES_HAS_NATIVE_FLOAT128)
-      message(VERBOSE "Math test ${name} will be skipped as native float128 type is not available.")
+      message(VERBOSE "Math test ${name} will be skipped as native float128 support in MPFR is not available.")
       return()
     endif()
   endif()

>From 0b6b7a601569785b4991a5f3d3bf5c97222d5c93 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 12 Aug 2026 23:32:13 +0530
Subject: [PATCH 3/3] use NEED_MPFR_F128 with float128 functions

---
 libc/test/src/CMakeLists.txt            |  2 +-
 libc/test/src/math/CMakeLists.txt       | 18 +++++++++---------
 libc/test/src/math/smoke/CMakeLists.txt |  1 -
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index a8e1fabc15377..b0cde52e32075 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -18,7 +18,7 @@ function(add_fp_unittest name)
 
   # TODO: To be removed when we find a workaround to run MPFR tests for
   # emulated type where compiler doesn't support the native float128
-  if(MATH_UNITTEST_NEED_MPFR128)
+  if(MATH_UNITTEST_NEED_MPFR_F128)
     set(MATH_UNITTEST_NEED_MPFR TRUE)
     if(NOT LIBC_TYPES_HAS_NATIVE_FLOAT128)
       message(VERBOSE "Math test ${name} will be skipped as native float128 support in MPFR is not available.")
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 04a17664a425b..850cf31e8f44f 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -424,7 +424,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   ceilf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -1781,7 +1781,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   sqrtf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -2756,7 +2756,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   scalbnf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -2866,7 +2866,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   atan2f128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -3421,7 +3421,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   bf16addf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -3477,7 +3477,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   bf16divf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -3539,7 +3539,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   bf16fmaf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -3603,7 +3603,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   bf16mulf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
@@ -3661,7 +3661,7 @@ add_fp_unittest(
 
 add_fp_unittest(
   bf16subf128_test
-  NEED_MPFR
+  NEED_MPFR_F128
   SUITE
     libc-math-unittests
   SRCS
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index dfc1e411cdfed..9eb6e687a06c1 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -290,7 +290,6 @@ add_fp_unittest(
 
 add_fp_unittest(
   faddf128_test
-  NEED_MPFR
   SUITE
     libc-math-unittests
   SRCS



More information about the libc-commits mailing list