From a7461c21567b0eb4f7ded8b7294882100aeb54d7 Mon Sep 17 00:00:00 2001 From: gongdaguo Date: Thu, 18 Nov 2021 16:28:42 +0800 Subject: [PATCH] fix glog --- cmake/external_libs/glog.cmake | 2 +- mindspore/lite/CMakeLists.txt | 1 + .../lite/cmake/check_requirements_lite.cmake | 13 ++++++ third_party/patch/glog/glog_lite.patch001 | 43 +++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 mindspore/lite/cmake/check_requirements_lite.cmake create mode 100644 third_party/patch/glog/glog_lite.patch001 diff --git a/cmake/external_libs/glog.cmake b/cmake/external_libs/glog.cmake index 0723fac3e11..115fef9dfff 100644 --- a/cmake/external_libs/glog.cmake +++ b/cmake/external_libs/glog.cmake @@ -8,7 +8,7 @@ if(BUILD_LITE) set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_C_FLAGS}") set(glog_LDFLAGS "${SECURE_SHARED_LINKER_FLAGS}") endif() - set(glog_patch "") + set(glog_patch ${CMAKE_SOURCE_DIR}/../../third_party/patch/glog/glog_lite.patch001) set(glog_lib glog) else() set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private") diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index 8ef13ee09c2..8c1c6a868e3 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -3,6 +3,7 @@ project(Lite) set(BUILD_LITE "on") +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_requirements_lite.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/secure_option.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/compile_link_option.cmake) diff --git a/mindspore/lite/cmake/check_requirements_lite.cmake b/mindspore/lite/cmake/check_requirements_lite.cmake new file mode 100644 index 00000000000..f98762254c7 --- /dev/null +++ b/mindspore/lite/cmake/check_requirements_lite.cmake @@ -0,0 +1,13 @@ +## packages used both on windows and linux +if(DEFINED ENV{MS_PATCH_PATH}) + find_program(Patch_EXECUTABLE patch PATHS $ENV{MS_PATCH_PATH}) + set(Patch_FOUND ${Patch_EXECUTABLE}) +else() + find_package(Patch) +endif() +if(NOT Patch_FOUND) + message(FATAL_ERROR "Patch not found, " + "please set environment variable MS_PATCH_PATH to path where Patch is located, " + "usually found in GIT_PATH/usr/bin on Windows") +endif() +message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE}) diff --git a/third_party/patch/glog/glog_lite.patch001 b/third_party/patch/glog/glog_lite.patch001 new file mode 100644 index 00000000000..bf260641e80 --- /dev/null +++ b/third_party/patch/glog/glog_lite.patch001 @@ -0,0 +1,43 @@ +diff -Npur glog/CMakeLists.txt glog-patch/CMakeLists.txt +--- glog/CMakeLists.txt 2019-03-22 10:51:46.000000000 +0800 ++++ glog-patch/CMakeLists.txt 2021-04-01 10:32:25.753140500 +0800 +@@ -64,7 +64,6 @@ check_include_file (dlfcn.h HAVE_DLFCN_H + check_include_file (execinfo.h HAVE_EXECINFO_H) + check_include_file (glob.h HAVE_GLOB_H) + check_include_file (inttypes.h HAVE_INTTYPES_H) +-check_include_file (libunwind.h HAVE_LIBUNWIND_H) + check_include_file (memory.h HAVE_MEMORY_H) + check_include_file (pwd.h HAVE_PWD_H) + check_include_file (stdint.h HAVE_STDINT_H) +@@ -80,7 +79,6 @@ check_include_file (syscall.h HAVE_SYSCA + check_include_file (syslog.h HAVE_SYSLOG_H) + check_include_file (ucontext.h HAVE_UCONTEXT_H) + check_include_file (unistd.h HAVE_UNISTD_H) +-check_include_file (unwind.h HAVE_UNWIND_H) + check_include_file (pwd.h HAVE_PWD_H) + + check_include_file_cxx ("ext/hash_map" HAVE_EXT_HASH_MAP) +@@ -116,12 +114,8 @@ check_cxx_compiler_flag (-Wunnamed-type- + # snprintf as an inline function + check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF) + +-check_library_exists (unwind get_static_proc_name "" HAVE_LIB_UNWIND) + check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP) + +-find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library") +-mark_as_advanced (UNWIND_LIBRARY) +- + check_c_source_compiles (" + #include + static void foo(void) __attribute__ ((unused)); +@@ -470,10 +464,6 @@ add_library (glog + add_library(glog::glog ALIAS glog) + + set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON) +- +-if (UNWIND_LIBRARY) +- target_link_libraries (glog PUBLIC ${UNWIND_LIBRARY}) +-endif (UNWIND_LIBRARY) + + if (HAVE_DBGHELP) + target_link_libraries (glog PUBLIC dbghelp)