diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ab54c500..44417b100 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,6 +250,8 @@ option(FORCE_SSE42 "force building with SSE4.2, even when PORTABLE=ON" OFF) option(FORCE_AVX "force building with AVX, even when PORTABLE=ON" OFF) option(FORCE_AVX2 "force building with AVX2, even when PORTABLE=ON" OFF) if(PORTABLE) + add_definitions(-DROCKSDB_PORTABLE) + # MSVC does not need a separate compiler flag to enable SSE4.2; if nmmintrin.h # is available, it is available by default. if(FORCE_SSE42 AND NOT MSVC) @@ -292,8 +294,7 @@ if(NOT MSVC) set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul") endif() -if (NOT PORTABLE OR FORCE_SSE42) - CHECK_CXX_SOURCE_COMPILES(" +CHECK_CXX_SOURCE_COMPILES(" #include #include #include @@ -305,12 +306,11 @@ int main() { auto d = _mm_cvtsi128_si64(c); } " HAVE_SSE42) - if(HAVE_SSE42) - add_definitions(-DHAVE_SSE42) - add_definitions(-DHAVE_PCLMUL) - elseif(FORCE_SSE42) - message(FATAL_ERROR "FORCE_SSE42=ON but unable to compile with SSE4.2 enabled") - endif() +if(HAVE_SSE42) + add_definitions(-DHAVE_SSE42) + add_definitions(-DHAVE_PCLMUL) +elseif(FORCE_SSE42) + message(FATAL_ERROR "FORCE_SSE42=ON but unable to compile with SSE4.2 enabled") endif() # Check if -latomic is required or not diff --git a/util/crc32c.cc b/util/crc32c.cc index 9deaf7fc6..d71c71c2e 100644 --- a/util/crc32c.cc +++ b/util/crc32c.cc @@ -1167,7 +1167,7 @@ static inline Function Choose_Extend() { #else if (isSSE42()) { if (isPCLMULQDQ()) { -#if defined HAVE_SSE42 && defined HAVE_PCLMUL && !defined NO_THREEWAY_CRC32C +#if (defined HAVE_SSE42 && defined HAVE_PCLMUL) && !defined NO_THREEWAY_CRC32C return crc32c_3way; #else return ExtendImpl; // Fast_CRC32 will check HAVE_SSE42 itself