Build app/hexagon_api error

I want to using hexagon dsp for model inference, and the device is Hexagon V66 with Linux aarch64 not android. When I build hexagon_api for test, I found two problem. First, when I using aarch64 cross-compile for compiling android_tvm_runtime_rpc and it failed with

“/usr/lib/gcc-cross/aarch64-linux-gnu/7/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible /workspace/HexagonDSP/4.1.0.4/tools/HEXAGON_Tools/8.4.05/Tools/lib/iss/libwrapper.so when searching for -lwrapper”

I want to know if i miss the wrapper.so in aarch64, while the android ndk will contain this library.

Second, When I build hexagon_tvm_runtime_rpc, the error is

/workspace/HexagonDSP/tvm/src/runtime/hexagon/hexagon_user_dma_instructions.h:41:16: error: invalid instruction asm volatile(" %0 = dmpoll" : “=r”(dm0)); ^ :1:3: note: instantiated into assembly here r2 = dmpoll /workspace/HexagonDSP/tvm/src/runtime/hexagon/ops/conv2d_fp16_hvx.cc:140:22: error: use of undeclared identifier ‘Q6_Vqf16_vmpy_VhfVhf’ HVX_Vector v_res = Q6_Vqf16_vmpy_VhfVhf(act_vec, wgt_vec); // result is in qf16

The cmake set as following:

cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-28 -DUSE_ANDROID_TOOLCHAIN=/opt/qcom/cmake/aarch64_cross_compile.cmake -DUSE_HEXAGON_ARCH=v66 -DUSE_HEXAGON_SDK=/workspace/HexagonDSP/4.5.0.3 -DUSE_HEXAGON_TOOLCHAIN=/workspace/HexagonDSP/4.5.0.3/tools/HEXAGON_Tools/8.5.08/Tools/ -DUSE_OUTPUT_BINARY_DIR=hexagon_api …

This Error had fixed, it happens because of the version of Hexagon V66, and Q6_Vqf16_vmpy_VhfVhf Func is support after V68.

The Compiler Error for AARCH64 is solved, it is caused by the BUILD_FOR_ANDROID Check Error, I Set BUILD_FOR_ANDROID into True Maunally for Solving this problem

This Problem Still can not be solved, and I see same bug in github:https://github.com/apache/tvm/issues/14407

UserDMA instructions are only available in v68 and later. There used to be some code in there that guarded against older targets, but it seems to be gone now. Check commit 02fff50cbb7cdeb333563be70fd5601d49fb08ab for example.

1 Like

I am also building hexagon_api for a aarch64 linux platform and I faced with the linking issue related to -lwrapper, but manually setting the BUILD_FOR_ANDROID fixed the problem. However, now I’m getting another linking error:

[100%] Linking CXX executable ../../tvm_rpc
/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/bin/ld: cannot find -llog
collect2: error: ld returned 1 exit status

@dingyongchao @kparzysz Have you faced with this issue? Any guess how to solve it?

IIRC, some versions of the Android NDK don’t have a separate liblog. Try removing that option.

Thanks for your swift response. I’m not using Android NDK, as the target platform is aarch64 ubuntu linux. Thus, I edited the hexagon_api/CMakeFiles.txt and removed the following lines:

"-DCMAKE_TOOLCHAIN_FILE=${USE_ANDROID_TOOLCHAIN}"
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}"
"-DANDROID_ABI=${ANDROID_ABI}"

I’m building hexagon_api using the following command:

export HEXAGON_SDK_ROOT=$HOME/Hexagon/5.3.0.0; export DEFAULT_HEXAGON_TOOLS_ROOT=$HEXAGON_SDK_ROOT/tools/HEXAGON_Tools/8.6.06; cmake .. -DUSE_HEXAGON_SDK=$HEXAGON_SDK_ROOT -DUSE_HEXAGON_TOOLCHAIN=$HEXAGON_SDK_ROOT/tools/HEXAGON_Tools/8.6.06/Tools -DUSE_HEXAGON_ARCH=v69 -DCMAKE_SYSTEM_VERSION=1

Any pointer on where to remove liblog option?

In apps/cpp_rpc/CMakeLists.txt:

  list(APPEND TVM_RPC_LINKER_LIBS cdsprpc log)

Thanks a lot. That fixed the issue with liblog. But surprisingly, the linking issue with -lwrapper came back again. Do we need to have Android_NDK installed even if the target platform is not Android? This doesn’t make sense to me.

libwrapper is the Hexagon simulator and it’s shipped with the Hexagon toolchain. It only runs on x86. If you want the host to be AArch64, then you need to remove the target hexagon_rpc_sim from Hexagon.cmake.

Hmm. Surprisingly, BUILD_FOR_ANDROID turns off when I run make for the second time. I need to rebuild from scratch to fix make sure the build is working for android.

Anyway, now after removing log, following error pops up:

/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/bin/ld: warning: liblog.so, needed by //home/osboxes/Hexagon/5.3.0.0/ipc/fastrpc/remote/ship/android_aarch64/libcdsprpc.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/bin/ld: warning: libc.so, needed by //home/osboxes/Hexagon/5.3.0.0/ipc/fastrpc/remote/ship/android_aarch64/libcdsprpc.so, not found (try using -rpath or -rpath-link)
//home/osboxes/Hexagon/5.3.0.0/ipc/fastrpc/remote/ship/android_aarch64/libcdsprpc.so: undefined reference to `__android_log_print'

I think liblog cannot be removed.

I managed to compile the code using Android NDK. Would be nice to have a non-android target as well in the future.