Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

License, Windows and Compatibility Upgrade #18

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,45 @@ else()
endif()
endif()

# Macro from on zlib-ng
# Macro to check if source compiles when cross-compiling
# or runs when compiling natively
include(CheckCSourceRuns)
macro(check_c_source_compile_or_run source flag)
if(CMAKE_CROSSCOMPILING)
check_c_source_compiles("${source}" ${flag})
else()
check_c_source_runs("${source}" ${flag})
endif()
endmacro()

CHECK_C_COMPILER_FLAG(-mpclmul COMPILER_HAS_M_PCLMUL)
if (COMPILER_HAS_M_PCLMUL)
message( STATUS "compiler supports pclmul")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mpclmul")
# check from on zlib-ng
# note zlib-ng does much more thorough test of architecture
check_c_source_runs(
"#include <immintrin.h>
int main(void)
{
__m128i a = _mm_setzero_si128();
__m128i b = _mm_setzero_si128();
__m128i c = _mm_clmulepi64_si128(a, b, 0x10);
(void)c;
return 0;
}"
HAVE_PCLMULQDQ_INTRIN
)
if(HAVE_PCLMULQDQ_INTRIN)
add_definitions(-DHAS_PCLMUL)
endif()
# set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-mpclmul")
else()
message( STATUS "compiler does not have pclmul")
endif()


if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
Expand Down Expand Up @@ -268,3 +307,12 @@ endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND MSVC)
set_target_properties(zlibstatic PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
endif()

#optional: show flags specified
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
MESSAGE(STATUS "Library Type: " ${LIB_TYPE})
MESSAGE(STATUS "Compiler flags:" ${CMAKE_C_COMPILE_FLAGS})
MESSAGE(STATUS "Compiler c debug flags:" ${CMAKE_C_FLAGS_DEBUG})
MESSAGE(STATUS "Compiler c release flags:" ${CMAKE_C_FLAGS_RELEASE})
MESSAGE(STATUS "Compiler c min size flags:" ${CMAKE_C_FLAGS_MINSIZEREL})
MESSAGE(STATUS "Compiler c flags:" ${CMAKE_C_FLAGS})
12 changes: 0 additions & 12 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,6 @@ cover: infcover
./infcover
gcov inf*.c

ifneq ($(findstring -DHAS_PCLMUL, $(CFLAGS)),)
OBJA += crc32-pclmul_asm.o
crc32-pclmul_asm.o : contrib/amd64/crc32-pclmul_asm.S
$(CC) $(CFLAGS) -c $< -o $@
endif

ifneq ($(findstring -DHAS_PCLMUL, $(SFLAGS)),)
PIC_OBJA += crc32-pclmul_asm.lo
crc32-pclmul_asm.lo : contrib/amd64/crc32-pclmul_asm.S
$(CC) $(SFLAGS) -c $< -o $@
endif

libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
Expand Down
14 changes: 9 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,19 @@ EOF
echo "CRC and SSE4.2 support is required" | tee -a configure.log
leave 1
fi

# Check for PCLMUL support
#Project copied from zlib-ng:
# Check for PCLMUL support
cat > $test.c << EOF
#include <immintrin.h>
void foo(void) {
_mm_clmulepi64_si128(_mm_set1_epi16(1), _mm_set1_epi16(2), 0);
#include <wmmintrin.h>
int main(void) {
__m128i a = _mm_setzero_si128();
__m128i b = _mm_setzero_si128();
__m128i c = _mm_clmulepi64_si128(a, b, 0x10);
(void)c;
return 0;
}
EOF

if try $CC -c -mpclmul $CFLAGS $test.c ; then
CFLAGS="-DHAS_PCLMUL -mpclmul $CFLAGS"
SFLAGS="-DHAS_PCLMUL -mpclmul $SFLAGS"
Expand Down
266 changes: 0 additions & 266 deletions contrib/amd64/crc32-pclmul_asm.S

This file was deleted.

Loading