noloader / cryptopp-cmake

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

Building on cortex-a53 #69

Closed durdo closed 2 years ago

durdo commented 3 years ago

I ran in this error while trying to build Crypto++ on cortex A53

[ 39%] Building CXX object 3rdparty/cryptopp/CMakeFiles/cryptopp-object.dir/gf2n.cpp.o
cd <redacted> && <redacted>$
-gnu-g++ -mcpu=cortex-a53 -ldl -lrt -lpthread -fPIC -static-libstdc++ -fvisibili
ty-inlines-hidden -fvisibility=hidden -fdata-sections -ffunction-sections  -DUSE
_NEON -DZYNQ_FPGA -DZYNQ_ULTRASCALE -I<redacted> -I<redacted> -I<redacted> -I<re
dacted> -W -Wall -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter
 -O3 -g -fno-omit-frame-pointer -lm -lrt -pthread  -Wno-reorder -Wno-missing-fie
ld-initializers -std=c++14 -lm -lrt -pthread -Wno-reorder -Wno-missing-field-ini
tializers -Wno-class-memaccess -Wno-deprecated  -fPIC   -o CMakeFiles/cryptopp-o
bject.dir/gf2n.cpp.o -c <redacted>/cryptopp/gf2n.cpp
/tmp/ccZ8ov9y.s: Assembler messages:
/tmp/ccZ8ov9y.s:216: Error: selected processor does not support `pmull v0.1q,v0.1d,v3.1d'
/tmp/ccZ8ov9y.s:251: Error: selected processor does not support `pmull2 v1.1q,v1.2d,v2.2d'
/tmp/ccZ8ov9y.s:487: Error: selected processor does not support `pmull v5.1q,v0.1d,v5.1d'
/tmp/ccZ8ov9y.s:569: Error: selected processor does not support `pmull v0.1q,v0.1d,v6.1d'
/tmp/ccZ8ov9y.s:754: Error: selected processor does not support `pmull v2.1q,v0.1d,v3.1d'
/tmp/ccZ8ov9y.s:808: Error: selected processor does not support `pmull v5.1q,v1.1d,v3.1d'
/tmp/ccZ8ov9y.s:861: Error: selected processor does not support `pmull v1.1q,v0.1d,v1.1d'
/tmp/ccZ8ov9y.s:888: Error: selected processor does not support `pmull2 v0.1q,v0.2d,v3.2d'
/tmp/ccZ8ov9y.s:985: Error: selected processor does not support `pmull v4.1q,v2.1d,v4.1d'
/tmp/ccZ8ov9y.s:1091: Error: selected processor does not support `pmull v2.1q,v2.1d,v6.1d'
/tmp/ccZ8ov9y.s:1461: Error: selected processor does not support `pmull v2.1q,v0.1d,v17.1d'
/tmp/ccZ8ov9y.s:1523: Error: selected processor does not support `pmull v1.1q,v1.1d,v17.1d'
/tmp/ccZ8ov9y.s:1578: Error: selected processor does not support `pmull v19.1q,v16.1d,v7.1d'
/tmp/ccZ8ov9y.s:1605: Error: selected processor does not support `pmull2 v0.1q,v16.2d,v4.2d'

Apparently this is the only compilation problem. Can anyone help me figure this one out?

noloader commented 3 years ago

Crypto is optional for ARMv8, including Cortex A53's and A57's. Early Mustang boards lacked them. I have not encountered another board that lacked them (yet).

It looks like someone built a compiler without the support crypto, presumably because the SoC or board lacked the crypto extensions.

I think the easiest thing to do in this case is use the CMake DISABLE_ASM option. It avoids the AES, SHA and PMULL code paths. Also see CMake on the Crypto++ wiki.

noloader commented 3 years ago

For what its worth, I think the bug is around CMakefileList.txt : 645. We set compile options for source files like -march=armv8-a+crypto when available, but we don't add -DCRYPTOPP_DISABLE_ARM_XXX when the compile option is not available.

noloader commented 3 years ago

@durdo,

Give Commit 96d1dc744079 and Commit 7edd6a273189 a try. Thos two commits are the tip of Master.

The commits should detect the missing option/supprt for you. If they function properly, you won't have to manually add an option.

durdo commented 3 years ago

First of all, I want to thank you for such a prompt response, I really appreciated it.

I tried the commits you suggested and unfortunately, they did not fix my issue. The DISABLE_ASM on the other hand worked like a charm.

Thank you very much, my problem is definitely solved.

If you want to try to solve this issue without the CMake option I can certainly test the commits and give you feedback, but this is up to you since using the option is more than enough for me.

noloader commented 2 years ago

I think this is fixed now. CMake was not using the options we set in CRYPTOPP_COMPILE_OPTIONS. It was fixed in Commit fae7769fbe00 and Commit 44ba79379ede.

This build system sucks.