Skip to content

Commit

Permalink
[cmake] Add preliminary support for MinGW (#176)
Browse files Browse the repository at this point in the history
This patch adds preliminary support for MinGW.
Only building static libm is possible at this time.
This patch also adds build-only testing on Appveyor.
  • Loading branch information
shibatch authored Feb 23, 2018
1 parent d71955b commit c278925
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
12 changes: 5 additions & 7 deletions Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ else()
set(DFT_C_FLAGS "${FLAGS_WALL} ${FLAGS_FASTMATH}")
endif()

if(CYGWIN OR MINGW)
set(SLEEF_C_FLAGS "${SLEEF_C_FLAGS} -fno-asynchronous-unwind-tables")
set(DFT_C_FLAGS "${DFT_C_FLAGS} -fno-asynchronous-unwind-tables")
endif()

# FEATURE DETECTION

Expand Down Expand Up @@ -336,7 +340,7 @@ CHECK_C_SOURCE_COMPILES("
return g(2);
}"
COMPILER_SUPPORTS_WEAK_ALIASES)
if (COMPILER_SUPPORTS_WEAK_ALIASES AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
if (COMPILER_SUPPORTS_WEAK_ALIASES AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND NOT MINGW)
set(ENABLE_GNUABI ${COMPILER_SUPPORTS_WEAK_ALIASES})
endif()

Expand Down Expand Up @@ -369,12 +373,6 @@ if(SLEEF_SHOW_ERROR_LOG)
endif()
endif(SLEEF_SHOW_ERROR_LOG)

# Compiling AVX512F code on Cygwin does not succeed

if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
set(COMPILER_SUPPORTS_AVX512F FALSE)
endif()

# Detect if cmake is running on Travis
string(COMPARE NOTEQUAL "" "$ENV{TRAVIS}" RUNNING_ON_TRAVIS)

Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ install:
- if "%DO_TEST%" == "TRUE" set ORGPATH="%PATH%"
- if "%DO_TEST%" == "TRUE" "C:\\Cygwin64\\setup-x86_64.exe" -q -g -P libmpfr-devel,libgmp-devel,cmake
- if "%DO_TEST%" == "TRUE" PATH c:\Cygwin64\bin;c:\Cygwin64\usr\bin;c:\projects\sleef\build-cygwin\bin;"%PATH%"
- if "%DO_TEST%" == "TRUE" "C:\\Cygwin64\\bin\\bash" -c 'mkdir build-mingw;cd build-mingw;CC=x86_64-w64-mingw32-gcc cmake -g\"Unix Makefiles\" .. -DBUILD_SHARED_LIBS=FALSE;make -j 2'
- if "%DO_TEST%" == "TRUE" cd "c:\\projects\\sleef"
- if "%DO_TEST%" == "TRUE" "C:\\Cygwin64\\bin\\bash" -c 'mkdir build-cygwin;cd build-cygwin;cmake -g\"Unix Makefiles\" ..;make -j 2'
- if "%DO_TEST%" == "TRUE" del /Q /F c:\projects\sleef\build-cygwin\bin\iut*
- if "%DO_TEST%" == "TRUE" PATH "%ORGPATH%";c:\Cygwin64\bin;c:\Cygwin64\usr\bin;c:\projects\sleef\build-cygwin\bin;c:\projects\sleef\build\bin
Expand Down
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ include_directories("arch")
add_subdirectory("libm")
add_subdirectory("libm-tester")
add_subdirectory("common")
add_subdirectory("dft")
add_subdirectory("dft-tester")

if (NOT MINGW)
add_subdirectory("dft")
add_subdirectory("dft-tester")
endif()
2 changes: 1 addition & 1 deletion src/common/arraymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

//

#ifndef _MSC_VER
#if !(defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER))
#include <unistd.h>
#include <sys/types.h>
#include <sys/file.h>
Expand Down
2 changes: 1 addition & 1 deletion src/common/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static INLINE CONST int isnanl(long double x) { return x != x; }

#endif // defined(_MSC_VER)

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__)
static INLINE CONST int isinff(float x) { return x == SLEEF_INFINITYf || x == -SLEEF_INFINITYf; }
static INLINE CONST int isinfl(long double x) { return x == SLEEF_INFINITYl || x == -SLEEF_INFINITYl; }
static INLINE CONST int isnanf(float x) { return x != x; }
Expand Down
8 changes: 3 additions & 5 deletions src/libm-tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ macro(test_extension SIMD)
add_test_iut(${TARGET_IUT${SIMD}})
list(APPEND IUT_LIST ${TARGET_IUT${SIMD}})

if(LIB_MPFR AND NOT ${SIMD} STREQUAL NEON32)
if(LIB_MPFR AND NOT ${SIMD} STREQUAL NEON32 AND NOT MINGW)
# Build tester2 SIMD
string(TOLOWER ${SIMD} SCSIMD)
foreach(P dp sp)
Expand Down Expand Up @@ -154,7 +154,7 @@ if (SLEEF_ARCH_X86)
list(APPEND IUT_LIST iutdsp256)
endif(SLEEF_ARCH_X86)

if(LIB_MPFR)
if(LIB_MPFR AND NOT MINGW)
# Build tester2 scalar
foreach(P dp sp)
set(T "tester2${P}")
Expand Down Expand Up @@ -183,9 +183,7 @@ if(LIB_MPFR)
target_include_directories(${TARGET_TESTER} PRIVATE ${MPFR_INCLUDE_DIR})
endif()
endif()
endif(LIB_MPFR)

# Set C standard requirement (-std=gnu99 for gcc)
endif(LIB_MPFR AND NOT MINGW)

# Tests depends on the library
add_dependencies(${TARGET_IUT} ${TARGET_HEADERS})
4 changes: 4 additions & 0 deletions src/libm-tester/testerutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <signal.h>
#endif

#if defined(__MINGW32__) || defined(__MINGW64__)
#include <unistd.h>
#endif

#include "misc.h"

#define DENORMAL_DBL_MIN (4.9406564584124654418e-324)
Expand Down

0 comments on commit c278925

Please sign in to comment.