报错:
*** stack smashing detected ***: <unknown> terminated
*** stack smashing detected ***: <unknown> terminated
CMake Error at mluop_generated_fault_kernel.mlu.o.cmake:221 (message):Error generating file/mnt/data/ef2301-sdk-0.10.0/board/develop_workspace/inference/samples/cncv/build/mlus/CMakeFiles/mluop.dir//./mluop_generated_fault_kernel.mlu.omlus/CMakeFiles/mluop.dir/build.make:70: recipe for target 'mlus/CMakeFiles/mluop.dir/mluop_generated_fault_kernel.mlu.o' failed
make[2]: *** [mlus/CMakeFiles/mluop.dir/mluop_generated_fault_kernel.mlu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMake Error at mluop_generated_fault_demo.mlu.o.cmake:221 (message):Error generating file/mnt/data/ef2301-sdk-0.10.0/board/develop_workspace/inference/samples/cncv/build/mlus/CMakeFiles/mluop.dir//./mluop_generated_fault_demo.mlu.omlus/CMakeFiles/mluop.dir/build.make:63: recipe for target 'mlus/CMakeFiles/mluop.dir/mluop_generated_fault_demo.mlu.o' failed
排查过程:
1、检查代码,在 官方samples 的代码也会报错。排除代码问题
2、检查cmakelists.txt ,和 build.sh 。可能是这个的问题
在官方samples 里面 按照流程 先执行 env.sh 后,再回到当前自己的工程,运行./build.sh --mlu-arch=SD5223C --cpu-arch=aarch64
,发现没有错误。排除后,发现如果:export NEUWARE_HOME="/usr/local/neuware"
换成export NEUWARE_HOME=/mnt/data/ef2301-sdk-0.10.0/board/develop_workspace/inference/mm/neuware
(就是复制到其他地方),就可正常。
可能是 cmakelists里面的如下代码导致的错误:
message("$ENV{NEUWARE_HOME}/cmake/modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{NEUWARE_HOME}/cmake" "$ENV{NEUWARE_HOME}/cmake/modules")
find_package(BANG)
if(NOT BANG_FOUND)message(FATAL_ERROR "BANG cannot be found.")
elseif(NOT BANG_CNCC_EXECUTABLE)message(FATAL_ERROR "cncc not found, please ensure cncc is in your PATH env or set variable BANG_CNCC_EXECUTABLE from cmake. Otherwise you should check path used by find_program(BANG_CNCC_EXECUTABLE) in FindBANG.cmake")
endif()
set(BANG_CNCC_FLAGS "-Wall -Werror -fPIC -std=c++11 --target=${TARGET_CPU_ARCH} -O3")
set(BANG_CNCC_FLAGS "${BANG_CNCC_FLAGS}""--bang-mlu-arch=tp_520""--bang-wram-align64"
)if(${TARGET_CPU_ARCH} MATCHES "aarch64")# 这两行设置编译标志BANG_CNCC_FLAGS,并添加定义-D_GLIBCXX_USE_CXX11_ABI=1。这允许在编译时启用特定的C++ ABI(Application Binary Interface)。set(BANG_CNCC_FLAGS "${BANG_CNCC_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=1")add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)# 这行代码执行uname -m命令,并将输出存储在_uname_m变量中。-m选项用于获取机器的硬件名称。execute_process(COMMAND uname -mOUTPUT_VARIABLE _uname_mOUTPUT_STRIP_TRAILING_WHITESPACE)# 如果TARGET_CPU_ARCH不包含_uname_m(即硬件名称),并且_uname_m不匹配"aarch64",则执行括号内的代码。if (NOT ("${TARGET_CPU_ARCH}" MATCHES ".*${_uname_m}.*" AND "${_uname_m}" MATCHES "aarch64"))# 这行代码执行CMake定义的CMAKE_CXX_COMPILER变量指向的C++编译器,并传递一些参数来获取编译器版本和一些预定义的宏。execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-v" "-c" "-x" "c++" "/dev/null" "-M"ERROR_VARIABLE _cxx_verbose)# 这行代码处理之前获取的编译器版本信息。它使用sed命令来提取编译器搜索的包含路径,并使用tr命令将新行替换为分号,然后将结果存储在_cxx_includes变量中。execute_process(COMMAND "echo" "${_cxx_verbose}"COMMAND "sed" "-n" "/include.*search starts here/,/End of search list/{s/^ //p}"COMMAND "tr" "'\n'" ";"OUTPUT_VARIABLE _cxx_includes)# 从_cxx_includes列表中移除"/usr/include"路径。list(REMOVE_ITEM _cxx_includes "/usr/include")# 遍历_cxx_includes列表,并将每个路径添加到编译标志BANG_CNCC_FLAGS中,以便在编译时将包含路径添加到其中。这里使用了-idirafter标志,这意味着在搜索包含文件时,编译器将首先搜索当前目录,然后搜索指定的路径。foreach(_include ${_cxx_includes})message(STATUS "add include path: ${_include}")set(BANG_CNCC_FLAGS "${BANG_CNCC_FLAGS} -idirafter ${_include}")endforeach()endif()
endif()
但还不确定,先记录该事项。