[SOLVED] Which compiler for module cross-compilation for android

Hello,

I have problems with compiling module for android device. When I use clangs from ndk folder I’m getting error information that my compiler doesn’t support hard float(ld: error: /tmp/tmpew1cmum0/lib0.o uses VFP register arguments, output does not). When I use arm-linux-gnueabihf-g+±8 from ubuntu system, I cannot change sysroot, so the module requires libm.so.6, which is not present on android device (mod.so dlopen failed: library "libm.so.6" not found). How to live?

–edit–

It looks like NDK from Android SDK should be prohibited with using TVM. And it should be mentioned in official documentation. Standalone ndk from NDK Downloads  |  Android NDK  |  Android Developers works better. At least produces similar errors to arm-linux-gnueabihf-g++8

Finally I have upgraded ndk from 21 to 23, and I have created standalone toolchain(to get proper sysroot):

my command which works:

TVM_LIBRARY_PATH=<tvm>/build-sys-llvm12 python3 \
    -m tvm.driver.tvmc compile \
    --target "llvm -device=arm_cpu -mtriple=armv7a-linux-androideabi -mattr=+neon" \
    --cross-compiler <ndk23>/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi28-clang \
    --cross-compiler-options="--target=armv7a-none-linux-androideabi28 -lm --sysroot=<standalone-toolchain-for-android-28-arm>/sysroot" \
    --input-shapes "input_tensor:[1,288,512,3]" \
    --desired-layout NHWC \
   <pb-model>

–edit–

and for clang++

TVM_LIBRARY_PATH=<tvm>/build-sys-llvm12 python3 \
    -m tvm.driver.tvmc compile \
    --target "llvm -device=arm_cpu -mtriple=armv7a-linux-androideabi -mattr=+neon" \
    --cross-compiler <ndk23>/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi28-clang++ \
    --cross-compiler-options="--target=armv7a-none-linux-androideabi28 -static-libstdc++ -lm --sysroot=<standalone-toolchain-for-android-28-arm>/sysroot" \
    --input-shapes "input_tensor:[1,288,512,3]" \
    --desired-layout NHWC \
    <pb-model>
1 Like