Skip to content

Commit be0fa31

Browse files
[libc] fix unit tests in fullbuild (#78864)
fixes #78743 - For normal objects, the patch removes `RTTI` and exceptions in `fullbuild` - For FP tests, the patch adds links to `stdc++` and `gcc_s` if `MPFR` is used.
1 parent 665f913 commit be0fa31

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function(create_libc_unittest fq_target_name)
187187
if(LLVM_LIBC_FULL_BUILD)
188188
target_compile_options(
189189
${fq_build_target_name}
190-
PRIVATE -ffreestanding
190+
PRIVATE -ffreestanding -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables
191191
)
192192
endif()
193193
if(LIBC_UNITTEST_COMPILE_OPTIONS)

libc/utils/MPFRWrapper/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ if(LIBC_TESTS_CAN_USE_MPFR)
44
MPFRUtils.h
55
mpfr_inc.h
66
)
7-
add_compile_options(
8-
-O3
9-
)
7+
target_compile_options(libcMPFRWrapper PRIVATE -O3)
8+
if (LLVM_LIBC_FULL_BUILD)
9+
# It is not easy to make libcMPFRWrapper a standalone library because gmp.h may unconditionally
10+
# pull in some STL headers. As a result, targets using this library will need to link against
11+
# C++ and unwind libraries. Since we are using MPFR anyway, we directly specifies the GNU toolchain.
12+
target_link_libraries(libcMPFRWrapper PUBLIC -lstdc++ -lgcc_s)
13+
endif()
1014
add_dependencies(
1115
libcMPFRWrapper
1216
libc.src.__support.CPP.string_view
@@ -19,7 +23,7 @@ if(LIBC_TESTS_CAN_USE_MPFR)
1923
target_include_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include)
2024
target_link_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/lib)
2125
endif()
22-
target_link_libraries(libcMPFRWrapper LibcFPTestHelpers.unit LibcTest.unit mpfr gmp)
26+
target_link_libraries(libcMPFRWrapper PUBLIC LibcFPTestHelpers.unit LibcTest.unit mpfr gmp)
2327
elseif(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU)
2428
message(WARNING "Math tests using MPFR will be skipped.")
2529
endif()

0 commit comments

Comments
 (0)