]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fix the selection of the fast CRC32 path in Ceph Luminous. ceph-luminous
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 8 Mar 2018 13:40:17 +0000 (14:40 +0100)
committerKefu Chai <tchaikov@gmail.com>
Mon, 12 Mar 2018 01:58:51 +0000 (09:58 +0800)
This ugly patch selectively adds the `-msse4.2` for compiling
`util/crc32c.cc` file when a building machine's toolchain had
successfully compiled a simple test program. The CXXFLAGS are
enriched even when `WITH_SSE42` is not set as, in Ceph, there
is no possibility to use the global switch because of lack of
proper run-time SSE4.2 check in other places IIUC.

Although the problem is fixed in `master` of RocksDB, the fix
cannot be backported because the CRC32-related stuff diverged
too much (`HAVE_POWER8`, `HAVE_PCLMUL`, `NO_THREEWAY_CRC32C`).

The patch strictly targets Ceph Luminous branch.

Fixes: http://tracker.ceph.com/issues/22534
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
CMakeLists.txt
util/crc32c.cc

index 5f82b33af921badfbfbf7df70b7088a68b8f58d2..983f0be9f70c891b4a3224f43d12cf6310f1a96a 100644 (file)
@@ -156,6 +156,24 @@ else()
   endif()
 endif()
 
+include(CheckCXXSourceCompiles)
+if(NOT MSVC)
+  set(CMAKE_REQUIRED_FLAGS "-msse4.2")
+endif()
+CHECK_CXX_SOURCE_COMPILES("
+#include <cstdint>
+#include <nmmintrin.h>
+int main() {
+  volatile uint32_t x = _mm_crc32_u32(0, 0);
+}
+" HAVE_SSE42)
+unset(CMAKE_REQUIRED_FLAGS)
+if(HAVE_SSE42 AND NOT WITH_SSE42)
+set_source_files_properties(
+  util/crc32c.cc
+  PROPERTIES COMPILE_FLAGS "-msse4.2")
+endif()
+
 option(FAIL_ON_WARNINGS "Treat compile warnings as errors" ON)
 if(FAIL_ON_WARNINGS)
   if(MSVC)
index 2c8cb097d93f2fc0f25c28cba7ba2eed674f7bd5..2fe2d663726c7d43b9cd48b28e185074bf8e25c5 100644 (file)
@@ -327,15 +327,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) {
 #ifdef __SSE4_2__
 #ifdef __LP64__