What float-abi and fpu should be used for Raspberry Pi ARMv7l model so file?

I’m trying to export model so file at the end of the compilation process
What float-abi and fpu should be used for Raspberry Pi ARMv7l?
I tried ["-mfloat-abi=hard","-mfpu=vfp"] - “so” file generation fails.

#target = "llvm -device=arm_cpu -model=bcm2837 -target=armv7l-linux-gnueabihf -mattr=+neon"
target = tvm.target.arm_cpu('rasp3b')
lib.export_library(path_lib, tvm.contrib.cc.create_shared, cc="/usr/bin/arm-linux-gnueabi-g++", options=["-mfloat-abi=hard","-mfpu=vfp"])

Error:

$ ./compile.py 
('model:', 'resnet50_v2', ', target:', llvm -device=arm_cpu -model=bcm2837 -target=armv7l-linux-gnueabihf -mattr=+neon, ', target_host:', None, ', opt_level:', 3, ', data_shape:', (1, 3, 224, 224))
Compiling...
No handlers could be found for logger "autotvm"
Compilation done
Saving files
('cmd: ', ['/usr/bin/arm-linux-gnueabi-g++', '-shared', '-fPIC', '-o', 'model.so', '/tmp/tmp988SCf/lib.o', '-mfloat-abi=hard', '-mfpu=vfp'])
Traceback (most recent call last):
  File "./compile.py", line 49, in <module>
    lib.export_library(path_lib, tvm.contrib.cc.create_shared, cc="/usr/bin/arm-linux-gnueabi-g++", options=["-mfloat-abi=hard","-mfpu=vfp"])
  File "/root/tvm/python/tvm/module.py", line 121, in export_library
    fcompile(file_name, files, **kwargs)
  File "/root/tvm/python/tvm/contrib/cc.py", line 33, in create_shared
    _linux_shared(output, objects, options, cc)
  File "/root/tvm/python/tvm/contrib/cc.py", line 59, in _linux_shared
    raise RuntimeError(msg)
RuntimeError: Compilation error:
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: error: /tmp/tmp988SCf/lib.o uses VFP register arguments, model.so does not
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file /tmp/tmp988SCf/lib.o
collect2: error: ld returned 1 exit status

Found the solution!!!
use “hf” HardFloat version g++ - arm-linux-gnueabihf-g++

compile and export model library for ARMv7 (Raspberry Pi 3B+) on x86 box

target = tvm.target.arm_cpu('rasp3b')
...
# Use hf HardFloat version of g++!!!
lib.export_library(“model.so”, cc="/usr/bin/arm-linux-gnueabihf-g++")
2 Likes

Now that I think about it again, you can likely find the target triple by type the following command on your board

gcc -verbose 

true

gcc --verbose
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 4.9.2-10+deb8u1' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.9.2 (Raspbian 4.9.2-10+deb8u1) 
1 Like

I was getting the similar error as @apivovarov on imx6 DL and when I changed gnueabi to gnuebihf then I am getting a new error as:

/opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabihf-g++ -c -std=c++11 -O2 -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfloat-abi=hard -mfpu=neon -fPIC -I/home/tvm/include -I/home/tvm/3rdparty/dmlc-core/include -I/home/tvm/3rdparty/dlpack/include -o lib/libtvm_runtime_pack.o tvm_runtime_pack.cc
make: /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabihf-g++: Command not found
Makefile:21: recipe for target ‘lib/libtvm_runtime_pack.o’ failed
make: *** [lib/libtvm_runtime_pack.o] Error 127

I checked the arm-poky-linux-gnueabi folder and there is no file named arm-poky-linux-gnueabihf. @tqchen