noloader / cryptopp-cmake

CMake files for Crypto++ project
BSD 3-Clause "New" or "Revised" License
92 stars 68 forks source link

Apple Silicon support - cryptest-cmake.sh fails #64

Closed TheSlowGrowth closed 3 years ago

TheSlowGrowth commented 3 years ago

cryptest-cmake.sh fails compiling Crypto++/crc_simd.cpp

error: use of undeclared identifier 'crc32b' error: use of undeclared identifier 'crc32w' error: use of undeclared identifier 'crc32cb' error: use of undeclared identifier 'crc32cw'

Not sure what to check, tbh. Suspecting a configuration error, so I'm asking here. Any hints would be much appreciated!

TheSlowGrowth commented 3 years ago

After further investigation it seems like this should actually be solved in Crypto++ not in the cmake integration. Disabling all intrinsics with CRYPTOPP_DISABLE_ASM makes the error go away.

noloader commented 3 years ago

Thanks @TheSlowGrowth.

error: use of undeclared identifier '__crc32b' ...

It looks like the Cmake files are getting into the x86 code paths.

I'm not sure how to fix it. I don't have access to the environment. I planned on waiting until I found an used M1 machine.

I suspect the problem is in CmakeFileList.txt : 298 (modulo Clang):

# Thanks to Anonimal for MinGW; see http://github.com/weidai11/cryptopp/issues/466
DumpMachine(CRYPTOPP_AMD64 "(x86_64)|(AMD64|amd64)")
DumpMachine(CRYPTOPP_I386 "^i.86$")
DumpMachine(CRYPTOPP_MINGW32 "^mingw32")
DumpMachine(CRYPTOPP_MINGW64 "(w64-mingw32)|(mingw64)")
DumpMachine(CRYPTOPP_X32 "(x32)")
DumpMachine(CRYPTOPP_AARCH32 "^aarch32")
DumpMachine(CRYPTOPP_AARCH64 "^aarch64")
DumpMachine(CRYPTOPP_ARMHF "(armhf)|(arm7l)|(eabihf)")
DumpMachine(CRYPTOPP_ARM "^arm")

Clang factors into the equation because the compiler does not identify itself properly. I seem to recall clang -dumpmachine lies to us. This is a recurring problem with Apple and Clang.

noloader commented 3 years ago

@TheSlowGrowth,

I bought an Apple M1. I be testing/fixing this shortly.

We already fixed the makefiles.

noloader commented 3 years ago

It looks like we have cleared this issue already.

If possible, use Crypto++ 8.5 or Master. Master is stable.