diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -19,6 +19,7 @@ # Defines LIBC_TARGET_ARCHITECTURE and associated macros. include(LLVMLibCArchitectures) +include(LLVMLibCCheckMPFR) # Flags to pass down to the compiler while building the libc functions. set(LIBC_COMPILE_OPTIONS_DEFAULT "" CACHE STRING "Architecture to tell clang to optimize for (e.g. -march=... or -mcpu=...)") diff --git a/libc/cmake/modules/LLVMLibCCheckMPFR.cmake b/libc/cmake/modules/LLVMLibCCheckMPFR.cmake new file mode 100644 --- /dev/null +++ b/libc/cmake/modules/LLVMLibCCheckMPFR.cmake @@ -0,0 +1,14 @@ +set(LLVM_LIBC_MPFR_INSTALL_PATH "" CACHE PATH "Path to where MPFR was installed (e.g. C:/src/install or ~/src/install)") + +if(LLVM_LIBC_MPFR_INSTALL_PATH) + set(LIBC_TESTS_CAN_USE_MPFR TRUE) +else() + try_compile( + LIBC_TESTS_CAN_USE_MPFR + ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + ${LIBC_SOURCE_DIR}/utils/MPFRWrapper/check_mpfr.cpp + LINK_LIBRARIES + -lmpfr -lgmp + ) +endif() diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt --- a/libc/config/windows/entrypoints.txt +++ b/libc/config/windows/entrypoints.txt @@ -45,30 +45,73 @@ libc.src.math.copysign libc.src.math.copysignf libc.src.math.copysignl - libc.src.math.fdimf + libc.src.math.ceil + libc.src.math.ceilf + libc.src.math.ceill + libc.src.math.fabs + libc.src.math.fabsf + libc.src.math.fabsl libc.src.math.fdim + libc.src.math.fdimf libc.src.math.fdiml + libc.src.math.floor + libc.src.math.floorf + libc.src.math.floorl + libc.src.math.fma + libc.src.math.fmaf libc.src.math.fmin libc.src.math.fminf libc.src.math.fminl libc.src.math.fmax libc.src.math.fmaxf libc.src.math.fmaxl + libc.src.math.frexp + libc.src.math.frexpf + libc.src.math.frexpl + libc.src.math.hypot + libc.src.math.hypotf libc.src.math.ilogb libc.src.math.ilogbf libc.src.math.ilogbl libc.src.math.ldexp libc.src.math.ldexpf libc.src.math.ldexpl + libc.src.math.llround + libc.src.math.llroundf + libc.src.math.llroundl libc.src.math.logb libc.src.math.logbf - libc.src.math.logbl + libc.src.math.logbl + libc.src.math.lround + libc.src.math.lroundf + libc.src.math.lroundl libc.src.math.modf libc.src.math.modff libc.src.math.modfl + libc.src.math.nearbyint + libc.src.math.nearbyintf + libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf libc.src.math.nextafterl + libc.src.math.remainderf + libc.src.math.remainder + libc.src.math.remainderl + libc.src.math.remquof + libc.src.math.remquo + libc.src.math.remquol + libc.src.math.rint + libc.src.math.rintf + libc.src.math.rintl + libc.src.math.round + libc.src.math.roundf + libc.src.math.roundl + libc.src.math.sqrt + libc.src.math.sqrtf + libc.src.math.sqrtl + libc.src.math.trunc + libc.src.math.truncf + libc.src.math.truncl ) set(TARGET_LLVMLIBC_ENTRYPOINTS diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt --- a/libc/utils/MPFRWrapper/CMakeLists.txt +++ b/libc/utils/MPFRWrapper/CMakeLists.txt @@ -1,19 +1,14 @@ -try_compile( - LIBC_TESTS_CAN_USE_MPFR - ${CMAKE_CURRENT_BINARY_DIR} - SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/check_mpfr.cpp - LINK_LIBRARIES - -lmpfr -lgmp -) - if(LIBC_TESTS_CAN_USE_MPFR) add_library(libcMPFRWrapper MPFRUtils.cpp MPFRUtils.h ) add_dependencies(libcMPFRWrapper libc.utils.CPP.standalone_cpp libc.utils.FPUtil.fputil LibcUnitTest) - target_link_libraries(libcMPFRWrapper -lmpfr -lgmp LibcFPTestHelpers LibcUnitTest) + if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH}) + 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 LibcUnitTest mpfr gmp) else() message(WARNING "Math tests using MPFR will be skipped.") endif()