diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e9670188e3395652cfeff630ae8917a7b529437..8db1c763eb41e1d7e6fd8c77d9ca2ac71d93a09e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,8 +179,10 @@ else() endif() endif() -set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS}) include(CheckCXXSourceCompiles) +if(NOT MSVC) + set(CMAKE_REQUIRED_FLAGS "-msse4.2") +endif() CHECK_CXX_SOURCE_COMPILES(" #include #include @@ -188,6 +190,7 @@ int main() { volatile uint32_t x = _mm_crc32_u32(0, 0); } " HAVE_SSE42) +unset(CMAKE_REQUIRED_FLAGS) if(HAVE_SSE42) add_definitions(-DHAVE_SSE42) elseif(FORCE_SSE42) @@ -556,6 +559,12 @@ set(SOURCES utilities/write_batch_with_index/write_batch_with_index_internal.cc $) +if(HAVE_SSE42 AND NOT FORCE_SSE42) +set_source_files_properties( + util/crc32c.cc + PROPERTIES COMPILE_FLAGS "-msse4.2") +endif() + if(WIN32) list(APPEND SOURCES port/win/io_win.cc diff --git a/util/crc32c.cc b/util/crc32c.cc index 321b1e45c6b5b56f7caabde556cc81f8bf865eb7..8a087a043fe3dbd5522555f4ec995da83b28288d 100644 --- a/util/crc32c.cc +++ b/util/crc32c.cc @@ -336,15 +336,6 @@ static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) { table0_[c >> 24]; } -#if defined(HAVE_SSE42) && defined(__GNUC__) -#if defined(__clang__) -#if __has_cpp_attribute(gnu::target) -__attribute__ ((target ("sse4.2"))) -#endif -#else // gcc supports this since 4.4 -__attribute__ ((target ("sse4.2"))) -#endif -#endif static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) { #ifndef HAVE_SSE42 Slow_CRC32(l, p);