diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 440c6a5e39f..ff95c75f06b 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -456,7 +456,7 @@ elif test -z "$PORTABLE"; then fi fi -$CXX $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null </dev/null < #include int main() { diff --git a/util/crc32c.cc b/util/crc32c.cc index ae36f82305b..0246ce093e6 100644 --- a/util/crc32c.cc +++ b/util/crc32c.cc @@ -313,6 +313,15 @@ 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); @@ -376,8 +385,7 @@ static bool isSSE42() { 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"); + __asm__("cpuid" : "=c"(c_) : "a"(1) : "ebx", "edx"); return c_ & (1U << 20); // copied from CpuId.h in Folly. #elif defined(_WIN64) int info[4]; @@ -398,7 +406,7 @@ bool IsFastCrc32Supported() { return isSSE42(); } -Function ChosenExtend = Choose_Extend(); +static Function ChosenExtend = Choose_Extend(); uint32_t Extend(uint32_t crc, const char* buf, size_t size) { return ChosenExtend(crc, buf, size);