OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[MLIR] Added linker options to reduce the GPU plugin binary size (#39265)
Andrey Pavlenkof65506e8af2e
diff --git a/cmake/developer_package/compile_flags/sdl.cmake b/cmake/developer_package/compile_flags/sdl.cmakeindex 8935e8d4664..c23390fae5e 100644--- a/cmake/developer_package/compile_flags/sdl.cmake+++ b/cmake/developer_package/compile_flags/sdl.cmake@@ -38,6 +38,10 @@ if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR (UNIX AND OV_COMPILER_IS_# https://stackoverflow.com/questions/58854858/undefined-symbol-stack-chk-guard-in-libopenh264-so-when-building-ffmpeg-witelse()set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -fstack-protector-all")+ if(NOT ENABLE_SANITIZER AND NOT APPLE AND NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")+ # Remove all symbol table and relocation information from the executable+ set(OV_LINKER_FLAGS "${OV_LINKER_FLAGS} -s")+ endif()endif()elseif(OV_COMPILER_IS_INTEL_LLVM)set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -fstack-protector-strong")diff --git a/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmake b/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmakeindex 77a7cd43a34..e878204507c 100644--- a/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmake+++ b/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmake@@ -3,6 +3,7 @@#include_guard()+include(CheckLinkerFlag)include("${CMAKE_CURRENT_LIST_DIR}/llvm.cmake")find_package(GraphCompiler QUIET CONFIG)@@ -28,3 +29,19 @@ if (NOT GraphCompiler_FOUND)FetchContent_MakeAvailable(GraphCompiler)set(BUILD_SHARED_LIBS ${_ov_build_shared_libs})endif()++check_linker_flag(CXX "LINKER:--icf=safe" OV_GPU_LINKER_HAS_ICF)+if(OV_GPU_LINKER_HAS_ICF)+ target_link_options(GraphCompiler INTERFACE $<$<CONFIG:Release>:LINKER:--icf=safe >)+endif()++check_linker_flag(CXX "LINKER:-z,pack-relative-relocs" OV_GPU_LINKER_HAS_PACK_RELATIVE_RELOCS)+if(OV_GPU_LINKER_HAS_PACK_RELATIVE_RELOCS)+ include(CheckCXXSourceCompiles)+ check_cxx_source_compiles("#include <features.h>+static_assert(__GLIBC_PREREQ(2, 36), \"\");+int main() {}" OV_GPU_GLIBC_HAS_DT_RELR)+ if(OV_GPU_GLIBC_HAS_DT_RELR)+ target_link_options(GraphCompiler INTERFACE $<$<CONFIG:Release>:LINKER:-z,pack-relative-relocs>)+ endif()+endif()