使用Android NDK的此目标不支持Crypto ++和neon_vector_type属性吗?

时间:2019-07-11 12:16:17

标签: android android-ndk crypto++

我想为Android armeabi构建cryptopp。指南在这里: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;

编辑

我推荐config_asm.h文件中的所有CRYPTOPP标志。错误消息在这里

$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 :(得分:0)

$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

我也无法使用march=armv5te在ARM开发板上使用Clang复制它。