From db44e8b4144fdc3c282166e0cbc4eae6fc8b198e Mon Sep 17 00:00:00 2001 From: Qi Li Date: Tue, 22 Sep 2020 09:40:36 +0800 Subject: [PATCH] [ASCEND] fix build for Ubuntu18.04 and GCC7.3, test=develop (#4397) * [ASCEND] fix build for Ubuntu18.04 and GCC7.3, test=develop * [ASCEND] address review comments, test=develop --- cmake/device/huawei_ascend_npu.cmake | 5 +++++ cmake/external/protobuf.cmake | 4 ++++ lite/kernels/huawei_ascend_npu/bridges/matmul_op.cc | 2 ++ lite/kernels/huawei_ascend_npu/bridges/scale_op.cc | 2 ++ lite/tools/build.sh | 2 +- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cmake/device/huawei_ascend_npu.cmake b/cmake/device/huawei_ascend_npu.cmake index 0bd9591eee..a2b664abd1 100644 --- a/cmake/device/huawei_ascend_npu.cmake +++ b/cmake/device/huawei_ascend_npu.cmake @@ -16,6 +16,11 @@ if(NOT LITE_WITH_HUAWEI_ASCEND_NPU) return() endif() +# require -D_GLIBCXX_USE_CXX11_ABI=0 if GCC 7.3.0 +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") +endif() + # 1. path to Huawei Ascend Install Path if(NOT DEFINED HUAWEI_ASCEND_NPU_DDK_ROOT) set(HUAWEI_ASCEND_NPU_DDK_ROOT $ENV{HUAWEI_ASCEND_NPU_DDK_ROOT}) diff --git a/cmake/external/protobuf.cmake b/cmake/external/protobuf.cmake index 76cc7b21de..eb6c26e38d 100644 --- a/cmake/external/protobuf.cmake +++ b/cmake/external/protobuf.cmake @@ -217,6 +217,10 @@ FUNCTION(build_protobuf TARGET_NAME BUILD_FOR_HOST) SET(OPTIONAL_ARGS ${OPTIONAL_ARGS} "-DCMAKE_GENERATOR_PLATFORM=x64") ENDIF() + IF(LITE_WITH_HUAWEI_ASCEND_NPU) + SET(OPTIONAL_ARGS ${OPTIONAL_ARGS} "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") + ENDIF() + if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) ExternalProject_Add( ${TARGET_NAME} diff --git a/lite/kernels/huawei_ascend_npu/bridges/matmul_op.cc b/lite/kernels/huawei_ascend_npu/bridges/matmul_op.cc index 1621d10deb..1b43099aef 100644 --- a/lite/kernels/huawei_ascend_npu/bridges/matmul_op.cc +++ b/lite/kernels/huawei_ascend_npu/bridges/matmul_op.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "lite/core/subgraph_bridge_registry.h" #include "lite/kernels/huawei_ascend_npu/bridges/graph.h" #include "lite/kernels/huawei_ascend_npu/bridges/utility.h" diff --git a/lite/kernels/huawei_ascend_npu/bridges/scale_op.cc b/lite/kernels/huawei_ascend_npu/bridges/scale_op.cc index 3baee3af41..12afe76c29 100644 --- a/lite/kernels/huawei_ascend_npu/bridges/scale_op.cc +++ b/lite/kernels/huawei_ascend_npu/bridges/scale_op.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "lite/core/subgraph_bridge_registry.h" #include "lite/kernels/huawei_ascend_npu/bridges/graph.h" #include "lite/kernels/huawei_ascend_npu/bridges/utility.h" diff --git a/lite/tools/build.sh b/lite/tools/build.sh index 1f5389cce3..eb0a7b1c04 100755 --- a/lite/tools/build.sh +++ b/lite/tools/build.sh @@ -372,7 +372,7 @@ function make_x86 { build_directory=$BUILD_DIR/build.lite.x86 if [ ${WITH_HUAWEI_ASCEND_NPU} == "ON" ]; then - export CXX=/usr/bin/g++ # Ascend need g++ in centos + export CXX=g++ # Huawei Ascend NPU need g++ build_directory=$BUILD_DIR/build.lite.huawei_ascend_npu fi -- GitLab