diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 24f543f6e4c13..9b7e918027541 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) diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt index d9fa0e31df0e5..adc073c9a91f5 100644 --- a/libc/utils/MPFRWrapper/CMakeLists.txt +++ b/libc/utils/MPFRWrapper/CMakeLists.txt @@ -4,9 +4,13 @@ if(LIBC_TESTS_CAN_USE_MPFR) MPFRUtils.h mpfr_inc.h ) - add_compile_options( - -O3 - ) + target_compile_options(libcMPFRWrapper PRIVATE -O3) + if (LLVM_LIBC_FULL_BUILD) + # It is not easy to make libcMPFRWrapper a standalone library because gmp.h may unconditionally + # pull in some STL headers. As a result, targets using this library will need to link against + # C++ and unwind libraries. Since we are using MPFR anyway, we directly specifies the GNU toolchain. + target_link_libraries(libcMPFRWrapper PUBLIC -lstdc++ -lgcc_s) + endif() add_dependencies( libcMPFRWrapper libc.src.__support.CPP.string_view @@ -19,7 +23,7 @@ if(LIBC_TESTS_CAN_USE_MPFR) target_include_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include) target_link_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/lib) endif() - target_link_libraries(libcMPFRWrapper LibcFPTestHelpers.unit LibcTest.unit mpfr gmp) + target_link_libraries(libcMPFRWrapper PUBLIC LibcFPTestHelpers.unit LibcTest.unit mpfr gmp) elseif(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU) message(WARNING "Math tests using MPFR will be skipped.") endif()