From afbef65187b4bbeb6ec0125789954b0643b55ae8 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Wed, 28 Jun 2017 21:37:55 -0700 Subject: [PATCH] Bug fix: Fast CRC Support printing is not honest Summary: 11c5d4741a1e11a1315d5ca644ce555e07e91f61 introduces a bug that IsFastCrc32Supported() returns wrong result. Fix it. Also fix some FB internal scripts. Closes https://github.com/facebook/rocksdb/pull/2513 Differential Revision: D5343802 Pulled By: yiwu-arbug fbshipit-source-id: 057dc7ae3b262fe951413d1190ce60afc788cc05 --- TARGETS | 3 ++- buckifier/targets_cfg.py | 1 + build_tools/fbcode_config.sh | 2 +- build_tools/fbcode_config4.8.1.sh | 2 +- util/crc32c.cc | 8 +++----- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TARGETS b/TARGETS index f577662c5..74de1608b 100644 --- a/TARGETS +++ b/TARGETS @@ -11,7 +11,8 @@ rocksdb_compiler_flags = [ "-DROCKSDB_MALLOC_USABLE_SIZE", "-DROCKSDB_RANGESYNC_PRESENT", "-DROCKSDB_SCHED_GETCPU_PRESENT", - "-DROCKSDB_SUPPORT_THREAD_LOCAL", + "-DROCKSDB_SUPPORT_THREAD_LOCAL", + "-DHAVE_SSE42", "-DOS_LINUX", # Flags to enable libs we include "-DSNAPPY", diff --git a/buckifier/targets_cfg.py b/buckifier/targets_cfg.py index 3a97b247c..de504e4d9 100644 --- a/buckifier/targets_cfg.py +++ b/buckifier/targets_cfg.py @@ -16,6 +16,7 @@ rocksdb_compiler_flags = [ "-DROCKSDB_RANGESYNC_PRESENT", "-DROCKSDB_SCHED_GETCPU_PRESENT", "-DROCKSDB_SUPPORT_THREAD_LOCAL", + "-DHAVE_SSE42", "-DOS_LINUX", # Flags to enable libs we include "-DSNAPPY", diff --git a/build_tools/fbcode_config.sh b/build_tools/fbcode_config.sh index 1138dae3f..b8609a11c 100644 --- a/build_tools/fbcode_config.sh +++ b/build_tools/fbcode_config.sh @@ -128,7 +128,7 @@ else fi CFLAGS+=" $DEPS_INCLUDE" -CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_SUPPORT_THREAD_LOCAL" +CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_SUPPORT_THREAD_LOCAL -DHAVE_SSE42" CXXFLAGS+=" $CFLAGS" EXEC_LDFLAGS=" $SNAPPY_LIBS $ZLIB_LIBS $BZIP_LIBS $LZ4_LIBS $ZSTD_LIBS $GFLAGS_LIBS $NUMA_LIB $TBB_LIBS" diff --git a/build_tools/fbcode_config4.8.1.sh b/build_tools/fbcode_config4.8.1.sh index 58b7ae25b..f5b8334db 100644 --- a/build_tools/fbcode_config4.8.1.sh +++ b/build_tools/fbcode_config4.8.1.sh @@ -93,7 +93,7 @@ else fi CFLAGS+=" $DEPS_INCLUDE" -CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_SUPPORT_THREAD_LOCAL" +CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_SUPPORT_THREAD_LOCAL -DHAVE_SSE42" CFLAGS+=" -DSNAPPY -DGFLAGS=google -DZLIB -DBZIP2 -DLZ4 -DZSTD -DNUMA -DTBB" CXXFLAGS+=" $CFLAGS" diff --git a/util/crc32c.cc b/util/crc32c.cc index a171b409e..b12f2c7bf 100644 --- a/util/crc32c.cc +++ b/util/crc32c.cc @@ -374,7 +374,9 @@ uint32_t ExtendImpl(uint32_t crc, const char* buf, size_t size) { // Detect if SS42 or not. static bool isSSE42() { -#if defined(__GNUC__) && defined(__x86_64__) && !defined(IOS_CROSS_COMPILE) +#ifndef HAVE_SSE42 + return false; +#elif defined(__GNUC__) && defined(__x86_64__) && !defined(IOS_CROSS_COMPILE) uint32_t c_; uint32_t d_; __asm__("cpuid" : "=c"(c_), "=d"(d_) : "a"(1) : "ebx"); @@ -395,11 +397,7 @@ static inline Function Choose_Extend() { } bool IsFastCrc32Supported() { -#if defined(__SSE4_2__) || defined(_WIN64) return isSSE42(); -#else - return false; -#endif } Function ChosenExtend = Choose_Extend();