pytorch / executorch

On-device AI across mobile, embedded and edge for PyTorch
https://pytorch.org/executorch/
Other
1.45k stars 237 forks source link

clang++: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [CMakeFiles/qnn_executor_runner.dir/build.make:185: qnn_executor_runner] Error 1 make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/qnn_executor_runner.dir/all] Error 2 #4085

Open shubhamnake23 opened 2 weeks ago

shubhamnake23 commented 2 weeks ago

I follow the instruction in https://pytorch.org/executorch/main/build-run-qualcomm-ai-engine-direct-backend.html and finish the following steps: cd $EXECUTORCH_ROOT mkdir build_android cd build_android

build executorch & qnn_executorch_backend

cmake .. \ -DCMAKE_INSTALL_PREFIX=$PWD \ -DEXECUTORCH_BUILD_SDK=ON \ -DEXECUTORCH_BUILD_QNN=ON \ -DQNN_SDK_ROOT=$QNN_SDK_ROOT \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ -DANDROID_ABI='arm64-v8a' \ -DANDROID_NATIVE_API_LEVEL=23 \ -B$PWD

cmake --build $PWD -j16 --target install

cmake ../examples/qualcomm \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ -DANDROID_ABI='arm64-v8a' \ -DANDROID_NATIVE_API_LEVEL=23 \ -DCMAKE_PREFIX_PATH="$PWD/lib/cmake/ExecuTorch;$PWD/third-party/gflags;" \ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \ -Bexamples/qualcomm

But when I run the: cmake --build examples/qualcomm -j16

I met the problem as followed: ld: error: undefined symbol: __ubsan_handle_type_mismatch_v1

referenced by builder.c:131 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:131) builder.c.o:(flatcc_builder_default_alloc) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:131 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:131) builder.c.o:(flatcc_builder_default_alloc) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:132 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:132) builder.c.o:(flatcc_builder_default_alloc) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 1980 more times

ld: error: undefined symbol: __ubsan_handle_divrem_overflow

referenced by builder.c:164 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:164) builder.c.o:(flatcc_builder_default_alloc) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:591 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:591) builder.c.o:(enter_frame) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:362 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:362) builder.c.o:(alloc_ht) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 3 more times

ld: error: undefined symbol: __ubsan_handle_pointer_overflow

referenced by builder.c:173 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:173) builder.c.o:(flatcc_builder_default_alloc) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:385 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:385) builder.c.o:(flatcc_builder_flush_vtable_cache) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:433 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:433) builder.c.o:(flatcc_builder_custom_reset) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 262 more times

ld: error: undefined symbol: __ubsan_handle_out_of_bounds

referenced by builder.c:385 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:385) builder.c.o:(flatcc_builder_flush_vtable_cache) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:433 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:433) builder.c.o:(flatcc_builder_custom_reset) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:460 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:460) builder.c.o:(flatcc_builder_custom_reset) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 69 more times

ld: error: undefined symbol: __ubsan_handle_builtin_unreachable

referenced by builder.c:442 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:442) builder.c.o:(flatcc_builder_custom_reset) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:316 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:316) builder.c.o:(reserve_buffer) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:556 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:556) builder.c.o:(flatcc_builder_exit_user_frame) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 66 more times

ld: error: undefined symbol: __ubsan_handle_add_overflow

referenced by builder.c:432 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:432) builder.c.o:(flatcc_builder_custom_reset) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:488 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:488) builder.c.o:(flatcc_builder_clear) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:740 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:740) builder.c.o:(flatcc_builder_embed_buffer) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 30 more times

ld: error: undefined symbol: __ubsan_handle_sub_overflow

referenced by builder.c:632 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:632) builder.c.o:(front_pad) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:659 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:659) builder.c.o:(emit_front) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:588 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:588) builder.c.o:(enter_frame) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 17 more times

ld: error: undefined symbol: __ubsan_handle_shift_out_of_bounds

referenced by builder.c:380 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:380) builder.c.o:(lookup_ht) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by builder.c:363 (/home/usr1/executorch/third-party/flatcc/src/runtime/builder.c:363) builder.c.o:(alloc_ht) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by refmap.c:56 (/home/usr1/executorch/third-party/flatcc/src/runtime/refmap.c:56) refmap.c.o:(_flatcc_refmap_hash) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced 2 more times

ld: error: undefined symbol: __ubsan_handle_negate_overflow

referenced by emitter.c:164 (/home/usr1/executorch/third-party/flatcc/src/runtime/emitter.c:164) emitter.c.o:(flatcc_emitter_reset) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by emitter.c:39 (/home/usr1/executorch/third-party/flatcc/src/runtime/emitter.c:39) emitter.c.o:(advance_front) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a referenced by emitter.c:80 (/home/usr1/executorch/third-party/flatcc/src/runtime/emitter.c:80) emitter.c.o:(advance_back) in archive /home/usr1/executorch/build_android/lib/libflatccrt_d.a clang++: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [CMakeFiles/qnn_executor_runner.dir/build.make:185: qnn_executor_runner] Error 1 make[1]: [CMakeFiles/Makefile2:111: CMakeFiles/qnn_executor_runner.dir/all] Error 2

Jack-Khuu commented 2 weeks ago

@cccclai for QNN

cccclai commented 2 weeks ago

Have you tried running this script instead?

sh backends/qualcomm/scripts/build.sh
allzero-kwon commented 2 weeks ago

@cccclai I got same errors and the script didn't work.

Have you tried running this script instead?

sh backends/qualcomm/scripts/build.sh
cccclai commented 2 weeks ago

It looks like the sdk build part is failing. Can you try -DEXECUTORCH_BUILD_SDK=OFF? Or change it in the CmakeCache.txt directly

haowhsu-quic commented 1 week ago

Hi @allzero-kwon , please add target_link_options(qnn_executor_runner PUBLIC -fsanitize=undefined) to the end of examples/qualcomm/CMakeLists.txt

cbilgin commented 1 week ago

@allzero-kwon does the previous suggestion solve your issue?