Build with arm toolchain 32bit

I have both aarch64 and arm android standalone toolchains and any build (cpu/gpu) with aarch64 is successful however, when changing TVM_NDK_CC="/android-toolchain-arm/bin/arm-linux-androideabi-gcc" or "arm-linux-androideabi-clang" (for 32bits), with target="opencl", target_host="llvm -target=arm-linux-androideabi" or target_host="llvm -target=armv7a-linux-android"respectively, but fails with

RuntimeError: Compilation error:
/android-toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /tmp/tmpc964gln3/lib.o uses VFP register arguments, output does not
collect2: error: ld returned 1 exit status

Any idea how to make it work?
Thanks

likely the target triple did not match what you have in the compiler, try to invoke the compiler with --verbose to get the triple

Thanks! here’s the output:

Using built-in specs.
COLLECT_GCC=./arm-linux-androideabi-gcc
COLLECT_LTO_WRAPPER=/android-toolchain-arm/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper
Target: arm-linux-androideabi
Configured with: /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure --prefix=/tmp/7b21daf2c1357ae66bd1633d4faf8a6d --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install --with-mpfr=/buildbot/tmp/build/toolchain/temp-install --with-mpc=/buildbot/tmp/build/toolchain/temp-install --with-cloog=/buildbot/tmp/build/toolchain/temp-install --with-isl=/buildbot/tmp/build/toolchain/temp-install --with-ppl=/buildbot/tmp/build/toolchain/temp-install --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array --disable-nls --prefix=/tmp/7b21daf2c1357ae66bd1633d4faf8a6d --with-sysroot=/tmp/7b21daf2c1357ae66bd1633d4faf8a6d/sysroot --with-binutils-version=2.27 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none --with-gxx-include-dir=/tmp/7b21daf2c1357ae66bd1633d4faf8a6d/include/c++/4.9.x --with-bugurl=http://source.android.com/source/report-bugs.html --enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default
Thread model: posix
gcc version 4.9.x 20150123 (prerelease) (GCC)

and

 ./arm-linux-androideabi-clang --verbose
Android clang version 5.0.300080  (based on LLVM 5.0.300080)
Target: **armv7a-none-linux-android** :roll_eyes:
Thread model: posix
InstalledDir: /android-toolchain-arm/bin/.
Found candidate GCC installation: /android-toolchain-arm/bin/./../lib/gcc/arm-linux-androideabi/4.9.x
Selected GCC installation: /android-toolchain-arm/bin/./../lib/gcc/arm-linux-androideabi/4.9.x
Candidate multilib: thumb;@thumb
Candidate multilib: armv7-a;@armv7
Candidate multilib: armv7-a/thumb;@armv7@thumb
Candidate multilib: .;
Selected multilib: armv7-a;@armv7

Also tried add the recommended flags or this to ndk.create_shared options with no success!

I have no idea what’s wrong? :confused:

You might want to set target to be “llvm -target=arm-linux-androideabi”, as reported by your compiler

Thanks! already tried with many different things, such as adding more options with not success! I can create and issue for it though?

This does not seem to be a problem of TVM itself, which the developer cannot act on to fix the code to resolve this. So let us keep the discussions in the forum.

My guess is that the problem still has things to do with target triple mismatch in the target triple passed into target_host in your tvm.build. Setting that to be the exact same triple of TARGET reported by your cross-compiler might help

Sure! I checked them and updated my first post. Basically the triple with gcc is arm-linux-androideabi and with clang is armv7a-linux-android which non of then works!

Googling also pointed me to some flags with I added to ndk options like -mfloat-abi=hard which seems to solve VFP issue as OpenCL uses hard vfp but was not helpful.

I only needed to add “-mfloat-abi=soft” after the “-target=armv7a-linux-android” and the build was successful for both cpu and gpu with the correct 32bit toolchain.

thanks for your tips

hi @ehsanmok, I met the same problem as you when exporting the 32bit model lib. but when I used your suggestion of adding “-mfloat-abi=soft” the export succeeded, but the model generate color artifacts, my model is an image enhancement model. Do you meet similar problem?

No sure, actually! My guess is if you’re seeing new color artifacts that were not visible before, that could be related to numerical precision mismatch between your initial model and a complied one with TVM. I haven’t noticed a result changing behaviour though, as most of DL models are not very sensitive to numerical precision errors.

Hi, I met the same error, and the newest version of tvm can not use -mfloat-abi=soft(deprecated), do you have any idea to solve this problem.