diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index 0fdbf79e9ec7f2..0dcf3a6761656c 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -331,7 +331,6 @@ else() if(APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-dead_strip") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip") elseif(LINUX) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL") diff --git a/ngraph/frontend/onnx/onnx_common/CMakeLists.txt b/ngraph/frontend/onnx/onnx_common/CMakeLists.txt index 3eaf88f0c13f20..ec31841e12cccc 100644 --- a/ngraph/frontend/onnx/onnx_common/CMakeLists.txt +++ b/ngraph/frontend/onnx/onnx_common/CMakeLists.txt @@ -2,8 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 # -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) - set(TARGET_NAME "onnx_common") file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) diff --git a/ngraph/frontend/onnx/onnx_import/CMakeLists.txt b/ngraph/frontend/onnx/onnx_import/CMakeLists.txt index b8eab155d9784c..61df1f6443d9ff 100644 --- a/ngraph/frontend/onnx/onnx_import/CMakeLists.txt +++ b/ngraph/frontend/onnx/onnx_import/CMakeLists.txt @@ -2,7 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 # -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) set(ONNX_OPSET_VERSION 13 CACHE INTERNAL "Supported version of ONNX operator set") file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index a526f19e54ff5b..9cbf15c9fe5225 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -642,6 +642,11 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src) target_link_libraries(unit-test PRIVATE onnx_importer) + if (LINUX) + target_link_options(unit-test PRIVATE -Wl,--exclude-libs,ALL) + elseif(APPLE) + target_link_options(unit-test PRIVATE -Wl,-dead_strip) + endif() endif() install(TARGETS unit-test diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 24e10be9f079c5..fa89cefc5c74c3 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -134,11 +134,10 @@ if(NGRAPH_PDPD_FRONTEND_ENABLE OR NGRAPH_ONNX_IMPORT_ENABLE) endif() find_package(Protobuf 3.9.0 REQUIRED) set(Protobuf_LITE_LIBRARIES protobuf::libprotobuf-lite) - set(Protobuf_LIBRARIES protobuf::libprotobuf) set(SYSTEM_PROTOC protobuf::protoc) set(PROTOC_EXECUTABLE ${SYSTEM_PROTOC}) - foreach(target ${SYSTEM_PROTOC} ${Protobuf_LIBRARIES} ${Protobuf_LITE_LIBRARIES}) + foreach(target ${SYSTEM_PROTOC} ${Protobuf_LITE_LIBRARIES}) set_property(TARGET ${target} PROPERTY IMPORTED_GLOBAL TRUE) endforeach() else() @@ -148,12 +147,11 @@ if(NGRAPH_PDPD_FRONTEND_ENABLE OR NGRAPH_ONNX_IMPORT_ENABLE) # forward variables used in the other places set(SYSTEM_PROTOC ${SYSTEM_PROTOC} PARENT_SCOPE) set(PROTOC_EXECUTABLE ${PROTOC_EXECUTABLE} PARENT_SCOPE) - set(Protobuf_LIBRARIES ${Protobuf_LIBRARIES} PARENT_SCOPE) set(Protobuf_LITE_LIBRARIES ${Protobuf_LITE_LIBRARIES} PARENT_SCOPE) set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE) # set public / interface compile options - foreach(target IN LISTS Protobuf_LITE_LIBRARIES Protobuf_LIBRARIES) + foreach(target IN LISTS Protobuf_LITE_LIBRARIES) set(link_type PUBLIC) if(NGRAPH_USE_SYSTEM_PROTOBUF) set(link_type INTERFACE) diff --git a/thirdparty/onnx/CMakeLists.txt b/thirdparty/onnx/CMakeLists.txt index 1196ab8dac0ddd..7915f5c4c71eae 100644 --- a/thirdparty/onnx/CMakeLists.txt +++ b/thirdparty/onnx/CMakeLists.txt @@ -2,12 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 # -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) - #------------------------------------------------------------------------------ # Configure and install libonnx ... #------------------------------------------------------------------------------ +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) set(NGRAPH_ONNX_NAMESPACE ngraph_onnx) set(BUILD_SHARED_LIBS OFF) diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt index 7cab74c6831330..821c6764666ea2 100644 --- a/thirdparty/protobuf/CMakeLists.txt +++ b/thirdparty/protobuf/CMakeLists.txt @@ -6,7 +6,6 @@ # Configure Google Protobuf ... #------------------------------------------------------------------------------ -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) set(BUILD_SHARED_LIBS OFF) if(SUGGEST_OVERRIDE_SUPPORTED) @@ -58,32 +57,22 @@ target_include_directories(libprotobuf-lite SYSTEM PRIVATE "${Protobuf_INCLUDE_D if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel") if(protobuf_BUILD_PROTOC_BINARIES) - set_target_properties(protoc libprotoc PROPERTIES + list(APPEND _protoc_libs protoc libprotoc libprotobuf) + set_target_properties(${_protoc_libs} PROPERTIES CXX_VISIBILITY_PRESET default C_VISIBILITY_PRESET default - VISIBILITY_INLINES_HIDDEN OFF) - list(APPEND _protobuf_libs protoc libprotoc) + VISIBILITY_INLINES_HIDDEN OFF + INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) endif() - ov_disable_all_warnings(${_protobuf_libs} libprotobuf libprotobuf-lite) -endif() - -if(NGRAPH_USE_PROTOBUF_LITE) - # if only libprotobuf-lite is used, both libprotobuf and libprotobuf-lite are built - # libprotoc target needs symbols from libprotobuf, even in libprotobuf-lite configuration - set_target_properties(libprotobuf PROPERTIES - CXX_VISIBILITY_PRESET default - C_VISIBILITY_PRESET default - VISIBILITY_INLINES_HIDDEN OFF) + ov_disable_all_warnings(${_protoc_libs} libprotobuf-lite) + set_target_properties(libprotobuf-lite PROPERTIES + INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) endif() if(protobuf_VERSION VERSION_LESS "3.9" AND NGRAPH_USE_PROTOBUF_LITE) message(FATAL_ERROR "Minimum supported version of protobuf-lite library is 3.9.0 (provided ${protobuf_VERSION})") endif() -if(ENABLE_LTO AND protobuf_VERSION VERSION_GREATER_EQUAL "3.8") - message(WARNING "Protobuf in version 3.8.0+ can throw runtime exceptions if LTO is enabled.") -endif() - if(CMAKE_CROSSCOMPILING AND NOT PROTOC_VERSION VERSION_EQUAL protobuf_VERSION) message(WARNING "system protobuf version does not match with the compiled one, please update system protobuf or submodule") endif() @@ -98,5 +87,4 @@ endif() set(protobuf_VERSION ${protobuf_VERSION} PARENT_SCOPE) set(Protobuf_LITE_LIBRARIES libprotobuf-lite PARENT_SCOPE) -set(Protobuf_LIBRARIES libprotobuf-lite PARENT_SCOPE) set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE)