• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 84e02cee10d5f1b56ea5b919a93ea3bbcfcc6570 Mon Sep 17 00:00:00 2001
2From: Zhu Guodong <zhuguodong0001@163.com>
3Date: Mon, 5 Jun 2023 15:54:54 +0800
4Subject: [PATCH] auto-apply 0020-support-cross-compile-with-ohos-ndk.patch
5
6---
7 cmake/external_libs/flatbuffers.cmake         |  4 +-
8 cmake/external_libs/pybind11.cmake            | 14 +++++-
9 .../device/cpu/kernel/nnacl/CMakeLists.txt    |  3 ++
10 mindspore/lite/BUILD.gn                       |  2 -
11 mindspore/lite/CMakeLists.txt                 | 10 ++++
12 mindspore/lite/build_lite.sh                  | 14 +++++-
13 mindspore/lite/src/CMakeLists.txt             |  8 +++-
14 mindspore/lite/src/common/log.cc              | 33 +++++++++++--
15 mindspore/lite/src/common/log.h               | 47 ++-----------------
16 mindspore/lite/src/common/utils.cc            |  6 +--
17 mindspore/lite/tools/benchmark/CMakeLists.txt | 11 ++++-
18 third_party/securec/CMakeLists.txt            |  4 ++
19 12 files changed, 95 insertions(+), 61 deletions(-)
20
21diff --git a/cmake/external_libs/flatbuffers.cmake b/cmake/external_libs/flatbuffers.cmake
22index d1e3d880..2101711f 100644
23--- a/cmake/external_libs/flatbuffers.cmake
24+++ b/cmake/external_libs/flatbuffers.cmake
25@@ -3,8 +3,8 @@ if(MSVC)
26     set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
27     set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
28 else()
29-    set(flatbuffers_CXXFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
30-    set(flatbuffers_CFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
31+    set(flatbuffers_CXXFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong -Wno-error=unused-but-set-variable")
32+    set(flatbuffers_CFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong -Wno-error=unused-but-set-variable")
33 endif()
34
35 if(WIN32)
36diff --git a/cmake/external_libs/pybind11.cmake b/cmake/external_libs/pybind11.cmake
37index 1d634f29..7d82ec6c 100644
38--- a/cmake/external_libs/pybind11.cmake
39+++ b/cmake/external_libs/pybind11.cmake
40@@ -15,7 +15,10 @@ if(ENABLE_GITEE)
41         return()
42     endif()
43 else()
44-    if(PYTHON_VERSION MATCHES "3.9")
45+    if(PYTHON_VERSION MATCHES "3.10")
46+        set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
47+        set(MD5 "32a7811f3db423df4ebfc731a28e5901")
48+    elseif(PYTHON_VERSION MATCHES "3.9")
49         set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
50         set(MD5 "32a7811f3db423df4ebfc731a28e5901")
51     elseif(PYTHON_VERSION MATCHES "3.8")
52@@ -32,7 +35,14 @@ endif()
53 set(pybind11_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
54 set(pybind11_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
55
56-if(PYTHON_VERSION MATCHES "3.9")
57+if(PYTHON_VERSION MATCHES "3.10")
58+    mindspore_add_pkg(pybind11
59+            VER 2.6.1
60+            URL ${REQ_URL}
61+            MD5 ${MD5}
62+            CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
63+            )
64+elseif(PYTHON_VERSION MATCHES "3.9")
65     mindspore_add_pkg(pybind11
66         VER 2.6.1
67         URL ${REQ_URL}
68diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt
69index 3d54a010..71f06de9 100644
70--- a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt
71+++ b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt
72@@ -64,6 +64,9 @@ if(APPLE OR PLATFORM_ARM32 OR PLATFORM_ARM64 OR PLATFORM_MCU)
73         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  -fomit-frame-pointer -fstrict-aliasing \
74         -ffunction-sections -fdata-sections -ffast-math")
75     endif()
76+    if(TARGET_OHOS)
77+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-inline-asm")
78+    endif()
79 endif()
80
81 if(NOT MSVC)
82diff --git a/mindspore/lite/BUILD.gn b/mindspore/lite/BUILD.gn
83index 7032b028..50b1fe7c 100644
84--- a/mindspore/lite/BUILD.gn
85+++ b/mindspore/lite/BUILD.gn
86@@ -581,7 +581,6 @@ ohos_shared_library("mindspore_lib") {
87   sources = all_sources
88
89   include_dirs = [
90-    "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
91     "//third_party/flatbuffers/include",
92     "./",
93     "../",
94@@ -820,7 +819,6 @@ ohos_shared_library("mindspore_train_lib") {
95   sources = all_train_sources
96
97   include_dirs = [
98-    "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
99     "//third_party/flatbuffers/include",
100     "./",
101     "../",
102diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt
103index 79fb55ba..0838dbe1 100644
104--- a/mindspore/lite/CMakeLists.txt
105+++ b/mindspore/lite/CMakeLists.txt
106@@ -237,6 +237,12 @@ elseif(TOOLCHAIN_NAME STREQUAL "mix210")
107 elseif(TOOLCHAIN_NAME STREQUAL "ohos-lite")
108     set(TARGET_OHOS_LITE on)
109     SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
110+elseif(TOOLCHAIN_NAME STREQUAL "ohos")
111+    set(TARGET_OHOS on)
112+    add_compile_definitions(MS_COMPILE_OHOS)
113+    add_compile_definitions(MS_COMPILE_WITH_OHOS_NDK)
114+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-command-line-argument -Wno-c++17-extensions")
115+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument -Wno-c++17-extensions")
116 endif()
117
118 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3.0
119@@ -531,6 +537,8 @@ endif()
120 if(PLATFORM_ARM64)
121     if(TARGET_HIMIX100 OR TARGET_MIX210 OR MACHINE_LINUX_ARM64)
122         set(RUNTIME_COMPONENT_NAME "linux-aarch64")
123+    elseif(TARGET_OHOS)
124+        set(RUNTIME_COMPONENT_NAME "ohos-aarch64")
125     else()
126         set(RUNTIME_COMPONENT_NAME "android-aarch64")
127     endif()
128@@ -540,6 +548,8 @@ elseif(PLATFORM_ARM32)
129         set(RUNTIME_COMPONENT_NAME "linux-aarch32")
130     elseif(TARGET_OHOS_LITE)
131         set(RUNTIME_COMPONENT_NAME "ohos-aarch32")
132+    elseif(TARGET_OHOS)
133+        set(RUNTIME_COMPONENT_NAME "ohos-aarch32")
134     endif()
135 elseif(WIN32)
136     if(CMAKE_SIZEOF_VOID_P EQUAL 4)
137diff --git a/mindspore/lite/build_lite.sh b/mindspore/lite/build_lite.sh
138index d2ce8bb6..8df9706d 100644
139--- a/mindspore/lite/build_lite.sh
140+++ b/mindspore/lite/build_lite.sh
141@@ -294,6 +294,12 @@ build_lite() {
142         LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DTOOLCHAIN_NAME=himix200"
143         LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_MINDDATA_IMPLEMENT=off"
144         LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_ENABLE_FP16=off -DMSLITE_ENABLE_TRAIN=off -DMSLITE_GPU_BACKEND=off"
145+      elif [[ "${TOOLCHAIN_NAME}" == "ohos" ]]; then
146+        pkg_name=mindspore-lite-${VERSION_STR}-ohos-arm32
147+        CMAKE_TOOLCHAIN_FILE=${OHOS_NDK}/build/cmake/ohos.toolchain.cmake
148+        LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DCMAKE_OHOS_NDK=${OHOS_NDK} -DOHOS_ARCH=armeabi-v7a -DOHOS_STL=c++_static -DTOOLCHAIN_NAME=${TOOLCHAIN_NAME}"
149+        LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_MINDDATA_IMPLEMENT=off"
150+        LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_ENABLE_FP16=off -DMSLITE_ENABLE_TRAIN=off -DMSLITE_GPU_BACKEND=off"
151       else
152         # CPU : Android-aarch32
153         checkndk
154@@ -323,6 +329,12 @@ build_lite() {
155         LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DTOOLCHAIN_NAME=mix210"
156         LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_MINDDATA_IMPLEMENT=off"
157         LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_ENABLE_FP16=on -DMSLITE_ENABLE_TRAIN=off -DMSLITE_GPU_BACKEND=off"
158+      elif [[ "${TOOLCHAIN_NAME}" == "ohos" ]]; then
159+        pkg_name=mindspore-lite-${VERSION_STR}-ohos-aarch64
160+        CMAKE_TOOLCHAIN_FILE=${OHOS_NDK}/build/cmake/ohos.toolchain.cmake
161+        LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DCMAKE_OHOS_NDK=${OHOS_NDK} -DOHOS_ARCH=arm64-v8a -DOHOS_STL=c++_static -DTOOLCHAIN_NAME=${TOOLCHAIN_NAME}"
162+        LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_MINDDATA_IMPLEMENT=off"
163+        LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_ENABLE_FP16=on -DMSLITE_ENABLE_TRAIN=off -DMSLITE_GPU_BACKEND=off"
164       else
165         if [[ "${machine}" == "aarch64" ]]; then
166           # CPU : Linux-aarch64
167@@ -374,7 +386,7 @@ build_lite() {
168     if [[ "X$MSLITE_COMPILE_TWICE" != "X" ]]; then
169       LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_COMPILE_TWICE=${MSLITE_COMPILE_TWICE}"
170     fi
171-    if [[ "${local_lite_platform}" == "arm64" || "${local_lite_platform}" == "arm32" ]]; then
172+    if [[ ("${local_lite_platform}" == "arm64" || "${local_lite_platform}" == "arm32") && "${TOOLCHAIN_NAME}" != "ohos" ]]; then
173       echo "default link libc++_static.a, export MSLITE_ANDROID_STL=c++_shared to link libc++_shared.so"
174     fi
175
176diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt
177index a80656f2..31941fb1 100644
178--- a/mindspore/lite/src/CMakeLists.txt
179+++ b/mindspore/lite/src/CMakeLists.txt
180@@ -537,10 +537,16 @@ if(SUPPORT_NPU)
181     target_link_libraries(mindspore-lite_static npu_kernel_mid)
182 endif()
183 if(PLATFORM_ARM32 OR PLATFORM_ARM64 AND NOT TARGET_HIMIX
184-        AND NOT TARGET_MIX210 AND NOT TARGET_OHOS_LITE AND NOT MACHINE_LINUX_ARM64)
185+        AND NOT TARGET_MIX210 AND NOT TARGET_OHOS_LITE AND NOT MACHINE_LINUX_ARM64 AND NOT TARGET_OHOS)
186     target_link_libraries(mindspore-lite log)
187     target_link_libraries(mindspore-lite_static log)
188 endif()
189+
190+if(TARGET_OHOS)
191+    target_link_libraries(mindspore-lite hilog_ndk.z.so)
192+    target_link_libraries(mindspore-lite_static hilog_ndk.z.so)
193+endif()
194+
195 if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "lite")
196     target_link_libraries(mindspore-lite minddata_eager_mid minddata-lite)
197     target_link_libraries(mindspore-lite_static minddata_eager_mid)
198diff --git a/mindspore/lite/src/common/log.cc b/mindspore/lite/src/common/log.cc
199index 66c0d76b..f8ba18af 100644
200--- a/mindspore/lite/src/common/log.cc
201+++ b/mindspore/lite/src/common/log.cc
202@@ -21,6 +21,13 @@
203 #include <android/log.h>
204 #endif
205
206+#ifdef MS_COMPILE_OHOS
207+#define LOG_DOMAIN 0x2102
208+#define LOG_TAG "MS_LITE"
209+#define FORMAT "[%{public}s:%{public}d] %{public}s# %{public}s"
210+#include "hilog/log.h"
211+#endif
212+
213 // namespace to support utils module definition namespace mindspore constexpr const char *ANDROID_LOG_TAG = "MS_LITE";
214 namespace mindspore {
215 #if defined(__ANDROID__)
216@@ -73,17 +80,33 @@ static int GetAndroidLogLevel(LiteLogLevel level) {
217
218 #ifdef MS_COMPILE_OHOS
219 void PrintHiLog(LiteLogLevel level, const char *file, int line, const char *func, const char *msg) {
220+#ifdef MS_COMPILE_WITH_OHOS_NDK
221+  // When build with OHOS NDK, use public api of hilog module.
222   if (level == LiteLogLevel::DEBUG) {
223-    OHOS::HiviewDFX::HiLog::Debug(MSLite_LABEL, FORMAT, file, line, func, msg);
224+    OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
225   } else if (level == LiteLogLevel::INFO) {
226-    OHOS::HiviewDFX::HiLog::Info(MSLite_LABEL, FORMAT, file, line, func, msg);
227+    OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
228   } else if (level == LiteLogLevel::WARNING) {
229-    OHOS::HiviewDFX::HiLog::Warn(MSLite_LABEL, FORMAT, file, line, func, msg);
230+    OH_LOG_Print(LOG_APP, LOG_WARN, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
231   } else if (level == LiteLogLevel::ERROR) {
232-    OHOS::HiviewDFX::HiLog::Error(MSLite_LABEL, FORMAT, file, line, func, msg);
233+    OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
234   } else {
235-    OHOS::HiviewDFX::HiLog::Error(MSLite_LABEL, FORMAT, file, line, func, msg);
236+    OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
237   }
238+#else
239+  // When build in OHOS repo, use inner api of hilog module.
240+  if (level == LiteLogLevel::DEBUG) {
241+    (void)HiLogPrint(LOG_APP, LOG_DEBUG, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
242+  } else if (level == LiteLogLevel::INFO) {
243+    (void)HiLogPrint(LOG_APP, LOG_INFO, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
244+  } else if (level == LiteLogLevel::WARNING) {
245+    (void)HiLogPrint(LOG_APP, LOG_WARN, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
246+  } else if (level == LiteLogLevel::ERROR) {
247+    (void)HiLogPrint(LOG_APP, LOG_ERROR, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
248+  } else {
249+    (void)HiLogPrint(LOG_APP, LOG_ERROR, LOG_DOMAIN, LOG_TAG, FORMAT, file, line, func, msg);
250+  }
251+#endif
252 }
253 #endif
254
255diff --git a/mindspore/lite/src/common/log.h b/mindspore/lite/src/common/log.h
256index 1890863e..bea21f01 100644
257--- a/mindspore/lite/src/common/log.h
258+++ b/mindspore/lite/src/common/log.h
259@@ -22,9 +22,6 @@
260 #include <map>
261 #include <unordered_map>
262 #include "utils/overload.h"
263-#ifdef MS_COMPILE_OHOS
264-#include "hilog/log.h"
265-#endif
266
267 // NOTICE: when relative path of 'log.h' changed, macro 'LITE_LOG_HEAR_FILE_REL_PATH' must be changed
268 #ifndef LITE_LOG_HEAR_FILE_REL_PATH
269@@ -137,6 +134,9 @@ class LiteLogWriter {
270   LiteLogLevel log_level_;
271 };
272
273+#define MSLOG_IF(level)                                                                                  \
274+  mindspore::LiteLogWriter(mindspore::LiteLocationInfo(LITE_FILE_NAME, __LINE__, __FUNCTION__), level) < \
275+    mindspore::LiteLogStream()
276
277 #define MS_LOG(level) MS_LOG_##level
278
279@@ -145,47 +145,6 @@ class LiteLogWriter {
280 #define MS_LOG_WARNING MSLOG_IF(mindspore::LiteLogLevel::WARNING)
281 #define MS_LOG_ERROR MSLOG_IF(mindspore::LiteLogLevel::ERROR)
282
283-
284-#ifdef MS_COMPILE_OHOS
285-namespace {
286-constexpr unsigned int MSLITE_DOMAIN_ID_START = 0xD0029A0;
287-constexpr unsigned int MSLITE_DOMAIN_ID_END = MSLITE_DOMAIN_ID_START + 32;
288-constexpr unsigned int TEST_DOMAIN_ID = 0xD000F00;
289-}  // namespace
290-
291-#define FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
292-#define FORMAT "[%{public}s:%{public}d] %{public}s# %{public}s"
293-
294-#define MSLOG_IF(level)                                                                                  \
295-  mindspore::LiteLogWriter(mindspore::LiteLocationInfo(LITE_FILE_NAME, __LINE__, __FUNCTION__), level) < \
296-    mindspore::LiteLogStream()
297-
298-enum MSLiteManagerLogLabel {
299-  // Component labels, you can add if needed
300-  COMP_FWK = 0,
301-  // Test label
302-  LABEL_TEST,
303-  // The end of labels, max to the domain id range length 32
304-  LABEL_END,
305-};
306-
307-enum MSLiteManagerLogDomain {
308-  DOMAIN_FRAMEWORK = MSLITE_DOMAIN_ID_START + COMP_FWK,  // 0xD0029A0
309-  DOMAIN_TEST = TEST_DOMAIN_ID,                          // 0xD000F00
310-  DOMAIN_END = MSLITE_DOMAIN_ID_END,  // Max to 0xD002940, keep the sequence and length same as MSLiteManagerLogLabel
311-};
312-
313-// Keep the sequence and length same as MSLiteManagerLogDomain
314-static constexpr OHOS::HiviewDFX::HiLogLabel MSLite_LABEL = {LOG_CORE, DOMAIN_FRAMEWORK, "MSLiteFwk"};
315-
316-#else
317-
318-#define MSLOG_IF(level)                                                                                  \
319-  mindspore::LiteLogWriter(mindspore::LiteLocationInfo(LITE_FILE_NAME, __LINE__, __FUNCTION__), level) < \
320-    mindspore::LiteLogStream()
321-
322-#endif
323-
324 }  // namespace mindspore
325
326 #ifdef Debug
327diff --git a/mindspore/lite/src/common/utils.cc b/mindspore/lite/src/common/utils.cc
328index ba60bea2..17b71bd5 100644
329--- a/mindspore/lite/src/common/utils.cc
330+++ b/mindspore/lite/src/common/utils.cc
331@@ -14,7 +14,7 @@
332  * limitations under the License.
333  */
334
335-#ifdef __ANDROID__
336+#if defined(__ANDROID__) || defined(MS_COMPILE_OHOS)
337 #include <sys/auxv.h>
338 #include <asm/hwcap.h>
339 #endif
340@@ -141,7 +141,7 @@ std::vector<std::string> Tokenize(const std::string &src, const std::string &del
341   return tokens;
342 }
343
344-#if defined(__ANDROID__)
345+#if defined(__ANDROID__) || defined(MS_COMPILE_OHOS)
346 uint32_t getHwCap(int hwcap_type) {
347   uint32_t ret = getauxval(hwcap_type);
348   return ret;
349@@ -151,7 +151,7 @@ uint32_t getHwCap(int hwcap_type) {
350 bool IsSupportSDot() {
351   bool status = false;
352 #ifdef ENABLE_ARM64
353-#if defined(__ANDROID__)
354+#if defined(__ANDROID__) || defined(MS_COMPILE_OHOS)
355   int hwcap_type = 16;
356   uint32_t hwcap = getHwCap(hwcap_type);
357   if (hwcap & HWCAP_ASIMDDP) {
358diff --git a/mindspore/lite/tools/benchmark/CMakeLists.txt b/mindspore/lite/tools/benchmark/CMakeLists.txt
359index eff7adde..1f52a4ef 100644
360--- a/mindspore/lite/tools/benchmark/CMakeLists.txt
361+++ b/mindspore/lite/tools/benchmark/CMakeLists.txt
362@@ -1,7 +1,11 @@
363 cmake_minimum_required(VERSION 3.12)
364 project(Lite_benchmark)
365
366-set(BENCHMARK_LINK_LIB mindspore-lite)
367+if(TARGET_OHOS)
368+    set(BENCHMARK_LINK_LIB libmindspore-lite.so)
369+else()
370+    set(BENCHMARK_LINK_LIB mindspore-lite)
371+endif()
372 set(PROVIDERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../providers)
373 if(TARGET_HIMIX)
374     add_subdirectory(${PROVIDERS_DIR}/nnie nnie)
375@@ -72,6 +76,11 @@ add_executable(benchmark
376         ${CMAKE_CURRENT_SOURCE_DIR}/benchmark_c_api.cc
377         ${COMMON_SRC})
378
379+if(TARGET_OHOS)
380+    target_link_directories(benchmark PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../../src)
381+    add_dependencies(benchmark mindspore-lite)
382+endif()
383+
384 add_dependencies(benchmark fbs_src)
385
386 target_link_libraries(benchmark ${BENCHMARK_LINK_LIB})
387diff --git a/third_party/securec/CMakeLists.txt b/third_party/securec/CMakeLists.txt
388index 91fb33b7..dd6e001a 100644
389--- a/third_party/securec/CMakeLists.txt
390+++ b/third_party/securec/CMakeLists.txt
391@@ -12,5 +12,9 @@ if(NOT MSVC)
392     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror")
393 endif()
394
395+if(TARGET_OHOS)
396+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-command-line-argument")
397+endif()
398+
399 include_directories(./include)
400 add_subdirectory(src)
401--
4022.34.1
403
404