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

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


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Zorojuro (Sukumarsawant)

<details>
<summary>Changes</summary>

Currently, the MPFR would link unconditionally when we remove the function from the guards to make it available everywhere. This introduces another problem with the function's test, in which MPFR is used, which would also get tested unconditionally now .

The MPFR would use native float128 types internally when built on a compiler with float128 support. But where it doesn't have native support, it would fail .
Thus, to prevent this failure, we only run the MPFR tests for targets with native float128 by adding `NEED_MPFR128`

---
Full diff: https://github.com/llvm/llvm-project/pull/215657.diff


1 Files Affected:

- (modified) libc/test/src/CMakeLists.txt (+11-1) 


``````````diff
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.")

``````````

</details>


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


More information about the libc-commits mailing list