ascon / ascon-c

Ascon - Lightweight Authenticated Encryption & Hashing
https://ascon.iaik.tugraz.at/
Creative Commons Zero v1.0 Universal
189 stars 30 forks source link

Error while compiling ref on a M1 chip #3

Closed MrUndead13 closed 2 years ago

MrUndead13 commented 2 years ago

Good afternoon, I'm trying to build and run the ref version on a MacBook Air M1 by using:

mkdir build && cd build cmake .. -DVERSION_LIST="v12" -DALG_LIST="ascon128;asconhash" -DIMPL_LIST="ref" -DTEST_LIST="genkat;getcycles" cmake --build . ctest -R genkat

But after entering Cmake --build . I get :

clang: error: the clang compiler does not support '-march=native'

To which I go into the CMakeCache.txt and change -march=native to -mcpu=apple-m1

However, I'm now getting :

/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/hresetintrin.h:42:27: error: invalid input constraint 'a' in asm asm ("hreset $0" :: "a"(__eax));

and then a lot of:

/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:50:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size

and finally:

fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. make[2]: [CMakeFiles/getcycles_crypto_aead_ascon128v12_ref.dir/tests/getcycles.c.o] Error 1 make[1]: [CMakeFiles/getcycles_crypto_aead_ascon128v12_ref.dir/all] Error 2 make: *** [all] Error 2

If I understood well hresetintrin and mmintrin are made for x86 (but I may be mistaken). Is there a fix for Apple M1 ?

Thanks in advance

cdobraunig commented 2 years ago

Hi,

Since the errors seem to come from the cycle computation, I think that

cmake .. -DVERSION_LIST="v12" -DALG_LIST="ascon128;asconhash" -DIMPL_LIST="ref" -DTEST_LIST="genkat"

should compile.

Best regards, Christoph

Am Do., 6. Jan. 2022 um 16:11 Uhr schrieb MrUndead13 < @.***>:

Good afternoon, I'm trying to build and run the ref version on a MacBook Air M1 by using:

mkdir build && cd build cmake .. -DVERSION_LIST="v12" -DALG_LIST="ascon128;asconhash" -DIMPL_LIST="ref" -DTEST_LIST="genkat;getcycles" cmake --build . ctest -R genkat

But after entering Cmake --build . I get :

clang: error: the clang compiler does not support '-march=native'

To which I go into the CMakeCache.txt and change -march=native to -mcpu=apple-m1

However, I'm now getting :

/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/hresetintrin.h:42:27: error: invalid input constraint 'a' in asm asm ("hreset $0" :: "a"(__eax));

and then a lot of:

/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:50:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size

and finally:

fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. make[2]: [CMakeFiles/getcycles_crypto_aead_ascon128v12_ref.dir/tests/getcycles.c.o] Error 1 make[1]: [CMakeFiles/getcycles_crypto_aead_ascon128v12_ref.dir/all] Error 2 make: *** [all] Error 2

If I understood well hresetintrin and mmintrin are made for x86 (but I may be mistaken). Is there a fix for Apple M1 ?

Thanks in advance

— Reply to this email directly, view it on GitHub https://github.com/ascon/ascon-c/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZUYBNWV2WBTEJ33ANWNXDUUWWL3ANCNFSM5LMRKPMQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

MrUndead13 commented 2 years ago

Thank you so much ! It works ! One strange thing is that I get :

zsh: command not found: -DIMPL_LIST=ref

then:

CMake Warning: Manually-specified variables were not used by the project:

IVERSION_LIST

But when I do Cmake --build after that and even ctest -R genkat I pass all tests

mschlaeffer commented 2 years ago

I'm closing this issue since it seems to be resolved. The last error comes from the line break (zsh tries to interpret -DIMPL_LIST=ref). The readme has been updated to better show available cmake options.