noloader / cryptopp-cmake

CMake files for Crypto++ project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cryptopp 8 fails to build on macOS Xcode 10

bdb opened this issue · comments

crypto++8.0.0 release

macOS 10.14.2, Xcode 10.1
$ clang --version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0

Cmake (from cryptopp-cmake project) static lib
$ cmake --version
cmake version 3.12.2

Building for macOS target. Not iPhone simulator.

Copied from weidei/cryptopp issue

crypto++7 built fine

cryptopp/crc_simd.cpp:148:13: error: always_inline function '_mm_crc32_u8' requires target feature 'popcnt', but would be inlined into function 'CRC32C_Update_SSE42' that is compiled without support for 'popcnt'
        c = _mm_crc32_u8(c, *s);
            ^
cryptopp/crc_simd.cpp:151:13: error: always_inline function '_mm_crc32_u32' requires target feature 'popcnt', but would be inlined into function 'CRC32C_Update_SSE42' that is compiled without support for 'popcnt'
        c = _mm_crc32_u32(c, *(const word32 *)(void*)s);
            ^
/cryptopp/crc_simd.cpp:154:13: error: always_inline function '_mm_crc32_u8' requires target feature 'popcnt', but would be inlined into function 'CRC32C_Update_SSE42' that is compiled without support for 'popcnt'
        c = _mm_crc32_u8(c, *s);
            ^
3 errors generated.

Source for the function is wrapped by CRYPTOPP_SSE42_AVAILABLE and that checks for CRYPTOPP_APPLE_CLANG_VERSION >= 40000.

However, compiler flags do not have SSE4.2 enabled by default:

$ c++ -arch x86_64 -std=c++14 -dM -E -x c++ - < /dev/null | grep SSE
#define __SSE2_MATH__ 1
#define __SSE2__ 1
#define __SSE3__ 1
#define __SSE4_1__ 1
#define __SSE_MATH__ 1
#define __SSE__ 1
#define __SSSE3__ 1

In Xcode this can be overrode with the "Enable Additional Vector Extensions" whose raw name is "CLANG_X86_VECTOR_INSTRUCTIONS".

Potentially related to weidai11/cryptopp#933 ?

I think we cleared this at Crypto++ 8.5.