Do not define __SSE4_2__ unconditionally in clang
Summary: Clang defines `_MSC_VER` on Windows, but it is not MSC. ``` % ./third-party/toolchains/llvm/8.0.0/bin/windows/clang.exe -march=corei7 -dM -E -x c empty | grep MSC #define _MSC_BUILD 1 #define _MSC_EXTENSIONS 1 #define _MSC_FULL_VER 191225835 #define _MSC_VER 1912 ``` We are not allowed to define `__SSE4_2__` in clang when clang assumes older arch, because in that case it refuses to compile SSE intrinsics, there is a couple of places in folly where we assume defined `__SSE4_2__` to use SSE4.2 intrinsics. On the other hand clang defines `__SSE4_2__` itself when it is available: ``` % ./third-party/toolchains/llvm/8.0.0/bin/windows/clang.exe -march=corei7 -dM -E -x c empty | grep SSE #define __SSE2_MATH__ 1 #define __SSE2__ 1 #define __SSE3__ 1 #define __SSE4_1__ 1 #define __SSE4_2__ 1 #define __SSE_MATH__ 1 #define __SSE__ 1 #define __SSSE3__ 1 ``` This is an example clang error on Windows: ``` folly/container/detail/F14Table.h:1098:23: error: always_inline function '_mm_crc32_u64' requires target feature 'sse4.2', but would be inlined into function 'splitHash' that is compiled without support for 'sse4.2' std::size_t c = _mm_crc32_u64(0, hash); ``` Reviewed By: vener91 Differential Revision: D16038436 fbshipit-source-id: 8728a8d91cadb936c9e244795c9270943fe005ad
Showing
Please register or sign in to comment