[libc-commits] [libc] [libc] fix unit tests in fullbuild (PR #78864)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Sat Jan 20 13:33:54 PST 2024


https://github.com/SchrodingerZhu updated https://github.com/llvm/llvm-project/pull/78864

>From d98e27a370c73f5d9e4de3efc1f2402f5305271e Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Sat, 20 Jan 2024 16:22:49 -0500
Subject: [PATCH 1/2] [libc] fix unit tests in fullbuild

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 24f543f6e4c132..9b7e9180275414 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -187,7 +187,7 @@ function(create_libc_unittest fq_target_name)
   if(LLVM_LIBC_FULL_BUILD)
     target_compile_options(
       ${fq_build_target_name}
-      PRIVATE -ffreestanding
+      PRIVATE -ffreestanding -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables
     )
   endif()
   if(LIBC_UNITTEST_COMPILE_OPTIONS)

>From bb1897f1ffc44cd719a3cf528773e7f6789e098b Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Sat, 20 Jan 2024 16:33:43 -0500
Subject: [PATCH 2/2] fix: add freestanding flags for MPFR

---
 libc/utils/MPFRWrapper/CMakeLists.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt
index d9fa0e31df0e50..0f935da183198c 100644
--- a/libc/utils/MPFRWrapper/CMakeLists.txt
+++ b/libc/utils/MPFRWrapper/CMakeLists.txt
@@ -1,4 +1,13 @@
 if(LIBC_TESTS_CAN_USE_MPFR)
+  if (LLVM_LIBC_FULL_BUILD)
+    add_compile_options(
+      -ffreestanding
+      -fno-exceptions
+      -fno-rtti
+      -fno-unwind-tables
+      -fno-asynchronous-unwind-tables
+    )
+  endif()
   add_library(libcMPFRWrapper
     MPFRUtils.cpp
     MPFRUtils.h



More information about the libc-commits mailing list