Атрибут Crypto ++ и neon_vector_type не поддерживается для этой цели при использовании Android NDK? - PullRequest
1 голос
/ 11 июля 2019

Я хочу построить cryptopp для Android Armeabi.Руководство здесь: https://github.com/noloader/cryptopp-android

git clone http://github.com/weidai11/cryptopp.git
cd cryptopp
git submodule add http://github.com/noloader/cryptopp-android.git android
git submodule update --remote

cp "$PWD/android/Android.mk" "$PWD"
cp "$PWD/android/Application.mk" "$PWD"

Откройте файл Application.mk и измените некоторые переменные

APP_ABI := all → APP_ABI := armeabi

APP_STL := c++_shared → APP_STL := gnustl_shared

Затем установите переменные среды:

export ANDROID_SDK_ROOT=/Users/user/Library/Android/sdk/
export ANDROID_NDK_ROOT=/Users/user/Downloads/android-ndk-r16b/

Команда построения: android-ndk-r16b/ndk-build V=1 NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk" NDK_HOST_32BIT=1

Ниже приведена ошибка:

>     android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/5.0.300080/include/arm_neon.h:28:2:
 error: "NEON support not enabled"
     #error "NEON support not enabled"  ^ android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/5.0.300080/include/arm_neon.h:48:24:
 error: 'neon_vector_type' attribute is not
           supported for this target typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t;

РЕДАКТИРОВАТЬ

Я рекомендую все флаги CRYPTOPP в файле config_asm.h,Сообщение об ошибке здесь

$android-ndk-r16b/ndk-build NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk"

/home/android-ndk-r16b/build/core/setup-app.mk:81: Android NDK: Application targets deprecated ABI(s): armeabi    
/home/android-ndk-r16b/build/core/setup-app.mk:82: Android NDK: Support for these ABIs will be removed in a future NDK release.    
[armeabi] Compile++ thumb: cryptopp_shared <= cryptlib.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= cpu.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= integer.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= 3way.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= adler32.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= algebra.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= algparam.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= arc4.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= aria.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= aria_simd.cpp
In file included from /home/crypto++/cryptopp/aria_simd.cpp:19:0:
/home/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include/arm_neon.h:31:2: error: #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
 #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
  ^
/home/crypto++/cryptopp/aria_simd.cpp:65:34: error: 'uint32x4_t' does not name a type
 inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
                                  ^
/home/crypto++/cryptopp/aria_simd.cpp:65:54: error: 'uint32x4_t' does not name a type
 inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
                                                      ^
/home/crypto++/cryptopp/aria_simd.cpp: In function 'void CryptoPP::ARIA_UncheckedSetKey_Schedule_NEON(CryptoPP::byte*, CryptoPP::word32*, unsigned int)':
/home/crypto++/cryptopp/aria_simd.cpp:80:8: error: 'uint32x4_t' does not name a type
  const uint32x4_t w0 = vld1q_u32(ws+ 0);
        ^
/home/crypto++/cryptopp/aria_simd.cpp:81:8: error: 'uint32x4_t' does not name a type
  const uint32x4_t w1 = vld1q_u32(ws+ 8);
        ^
/home/crypto++/cryptopp/aria_simd.cpp:82:8: error: 'uint32x4_t' does not name a type
  const uint32x4_t w2 = vld1q_u32(ws+12);
        ^
/home/crypto++/cryptopp/aria_simd.cpp:83:8: error: 'uint32x4_t' does not name a type
  const uint32x4_t w3 = vld1q_u32(ws+16);
        ^
/home/crypto++/cryptopp/aria_simd.cpp:85:21: error: 'w0' was not declared in this scope
  ARIA_GSRK_NEON<19>(w0, w1, rk +   0);
                     ^
/home/crypto++/cryptopp/aria_simd.cpp:85:25: error: 'w1' was not declared in this scope
  ARIA_GSRK_NEON<19>(w0, w1, rk +   0);
                         ^
/home/crypto++/cryptopp/aria_simd.cpp:86:25: error: 'w2' was not declared in this scope
  ARIA_GSRK_NEON<19>(w1, w2, rk +  16);
                         ^
/home/crypto++/cryptopp/aria_simd.cpp:87:25: error: 'w3' was not declared in this scope
  ARIA_GSRK_NEON<19>(w2, w3, rk +  32);
                         ^
/home/crypto++/cryptopp/aria_simd.cpp: In function 'void CryptoPP::ARIA_ProcessAndXorBlock_NEON(const byte*, CryptoPP::byte*, const byte*, CryptoPP::word32*)':
/home/crypto++/cryptopp/aria_simd.cpp:136:22: error: 'vld1q_u8' was not declared in this scope
     vld1q_u8(xorBlock),
                      ^
/home/crypto++/cryptopp/aria_simd.cpp:139:31: error: 'vrev32q_u8' was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                               ^
/home/crypto++/cryptopp/aria_simd.cpp:139:32: error: 'veorq_u8' was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                                ^
/home/crypto++/cryptopp/aria_simd.cpp:139:33: error: 'veorq_u8' was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                                 ^
/home/crypto++/cryptopp/aria_simd.cpp:139:33: error: redeclaration of '<typeprefixerror>veorq_u8'
/home/crypto++/cryptopp/aria_simd.cpp:139:32: note: previous declaration '<typeprefixerror>veorq_u8'
      vrev32q_u8(vld1q_u8((rk))))));
                                ^
/home/crypto++/cryptopp/aria_simd.cpp:139:34: error: 'vst1q_u8' was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                                  ^
/home/crypto++/cryptopp/aria_simd.cpp:145:22: error: 'vld1q_u8' was not declared in this scope
     vld1q_u8(outBlock),
                      ^
/home/crypto++/cryptopp/aria_simd.cpp:146:28: error: 'vrev32q_u8' was not declared in this scope
     vrev32q_u8(vld1q_u8(rk))));
                            ^
/home/crypto++/cryptopp/aria_simd.cpp:146:29: error: 'veorq_u8' was not declared in this scope
     vrev32q_u8(vld1q_u8(rk))));
                             ^
/home/crypto++/cryptopp/aria_simd.cpp:146:30: error: 'vst1q_u8' was not declared in this scope
     vrev32q_u8(vld1q_u8(rk))));
                              ^
make: *** [/home/crypto++/cryptopp/obj/local/armeabi/objs/cryptopp_shared/aria_simd.o] Error 1

1 Ответ

0 голосов
/ 13 июля 2019
$android-ndk-r16b/ndk-build NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk"

/home/android-ndk-r16b/build/core/setup-app.mk:81: Android NDK: Application targets deprecated ABI(s): armeabi    
/home/android-ndk-r16b/build/core/setup-app.mk:82: Android NDK: Support for these ABIs will be removed in a future NDK release.    
[armeabi] Compile++ thumb: cryptopp_shared <= cryptlib.cpp
...
[armeabi] Compile++ thumb: cryptopp_shared <= aria_simd.cpp
In file included from /home/crypto++/cryptopp/aria_simd.cpp:19:0:
/home/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include/arm_neon.h:31:2:
error: #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h

Обычно я этого не делаю, но ... основываясь на ndk-r16b, я думаю, вам следует обновить NDK. У меня нет ndk-r16b:

cryptopp$ ls /opt/
android-ndk  android-ndk-r19c  android-sdk

У меня есть ndk-19c, и я не могу продублировать проблему, работая с Мастером. Во-первых, armeabi отсутствует:

cryptopp$ ndk-build APP_ABI=armeabi NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk" V=1
Android NDK: The armeabi ABI is no longer supported. Use armeabi-v7a.    
Android NDK: NDK Application 'local' targets unknown ABI(s): armeabi    
Android NDK: Please fix the APP_ABI definition in /home/jwalton/cryptopp/Application.mk    
/opt/android-ndk-r19c/build/core/setup-app.mk:79: *** Android NDK: Aborting    .  Stop.

Второй, armeabi-v7a строит ОК:

cryptopp$ ndk-build APP_ABI=armeabi-v7a NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk" V=1
rm -f /home/jwalton/cryptopp/libs/armeabi-v7a/
rm -f /home/jwalton/cryptopp/libs/armeabi-v7a/gdbserver
rm -f /home/jwalton/cryptopp/libs/armeabi-v7a/gdb.setup
...

/opt/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -MMD -MP
 -MF /home/jwalton/cryptopp/obj/local/armeabi-v7a/objs/cryptopp_static/aria.o.d
-target armv7-none-linux-androideabi21 -fdata-sections -ffunction-sections -fsta
ck-protector-strong -funwind-tables -no-canonical-prefixes  --sysroot /opt/andro
id-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -Wno-invalid-comman
d-line-argument -Wno-unused-command-line-argument  -fno-addrsig -fno-exceptions
-fno-rtti -fpic -mfpu=vfpv3-d16  -march=armv7-a -mthumb -Oz -DNDEBUG  -I/opt/and
roid-ndk-r19c/sources/android/cpufeatures -I/opt/android-ndk-r19c/sources/cxx-st
l/llvm-libc++/include -I/opt/android-ndk-r19c/sources/cxx-stl/llvm-libc++/../llv
m-libc++abi/include -I/home/jwalton/cryptopp -std=c++11    -DANDROID  -nostdinc+
+ -Wa,--noexecstack -Wformat -Werror=format-security -Wall -frtti -fexceptions
-c  /home/jwalton/cryptopp/aria.cpp -o /home/jwalton/cryptopp/obj/local/armeabi-
v7a/objs/cryptopp_static/aria.o
[armeabi-v7a] Compile++ thumb: cryptopp_static <= aria_simd.cpp
rm -f /home/jwalton/cryptopp/obj/local/armeabi-v7a/objs/cryptopp_static/aria_simd.o

Я также не могу продублировать его, используя Clang на плате разработчика ARM, используя march=armv5te.

...