From 8bf118d459d0fdd411904dc53e207e5dc05cd3f2 Mon Sep 17 00:00:00 2001 From: jiweibo Date: Fri, 13 Aug 2021 14:09:11 +0000 Subject: [PATCH 1/2] strip inference.so and make link to mkldnn.so --- cmake/inference_lib.cmake | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 669875d81dfecc..814e6cc82b3f1b 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -94,8 +94,12 @@ function(copy_part_of_thrid_party TARGET DST) DSTS ${dst_dir} ${dst_dir}/lib ${dst_dir}/lib) else() copy(${TARGET} - SRCS ${MKLDNN_INC_DIR} ${MKLDNN_SHARED_LIB} ${MKLDNN_SHARED_LIB_1} ${MKLDNN_SHARED_LIB_2} - DSTS ${dst_dir} ${dst_dir}/lib ${dst_dir}/lib ${dst_dir}/lib) + SRCS ${MKLDNN_INC_DIR} ${MKLDNN_SHARED_LIB} + DSTS ${dst_dir} ${dst_dir}/lib) + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink ${dst_dir}/lib/libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.1 + COMMAND ${CMAKE_COMMAND} -E create_symlink ${dst_dir}/lib/libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.2 + COMMENT "Make a symbol link of libmkldnn.so.0") endif() endif() @@ -225,6 +229,13 @@ copy(inference_lib_dist SRCS ${src_dir}/inference/capi_exp/pd_*.h ${paddle_inference_c_lib} DSTS ${PADDLE_INFERENCE_C_INSTALL_DIR}/paddle/include ${PADDLE_INFERENCE_C_INSTALL_DIR}/paddle/lib) +if(WITH_STRIP AND NOT WIN32) + add_custom_command(TARGET inference_lib_dist POST_BUILD + COMMAND strip -s ${PADDLE_INFERENCE_C_INSTALL_DIR}/paddle/lib/libpaddle_inference_c.so + COMMAND strip -s ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.so + COMMENT "striping libpaddle_inference_c.so\nstriping libpaddle_inference.so") +endif() + # fluid library for both train and inference set(fluid_lib_deps inference_lib_dist) add_custom_target(fluid_lib_dist ALL DEPENDS ${fluid_lib_deps}) From 99e3d1df72951a207a77a2f99659b5582cff1b6e Mon Sep 17 00:00:00 2001 From: jiweibo Date: Tue, 24 Aug 2021 12:13:32 +0000 Subject: [PATCH 2/2] update --- cmake/inference_lib.cmake | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 814e6cc82b3f1b..cb2ed614d3d7ca 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -72,6 +72,12 @@ function(copy_part_of_thrid_party TARGET DST) copy(${TARGET} SRCS ${MKLML_LIB} ${MKLML_IOMP_LIB} ${MKLML_INC_DIR} DSTS ${dst_dir}/lib ${dst_dir}/lib ${dst_dir}) + if(WITH_STRIP) + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND strip -s ${dst_dir}/lib/libiomp5.so + COMMAND strip -s ${dst_dir}/lib/libmklml_intel.so + COMMENT "striping libiomp5.so\nstriping libmklml_intel.so") + endif() endif() elseif(${CBLAS_PROVIDER} STREQUAL EXTERN_OPENBLAS) set(dst_dir "${DST}/third_party/install/openblas") @@ -96,9 +102,14 @@ function(copy_part_of_thrid_party TARGET DST) copy(${TARGET} SRCS ${MKLDNN_INC_DIR} ${MKLDNN_SHARED_LIB} DSTS ${dst_dir} ${dst_dir}/lib) + if(WITH_STRIP) + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND strip -s ${dst_dir}/lib/libmkldnn.so.0 + COMMENT "striping libmkldnn.so.0") + endif() add_custom_command(TARGET ${TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink ${dst_dir}/lib/libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.1 - COMMAND ${CMAKE_COMMAND} -E create_symlink ${dst_dir}/lib/libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.2 + COMMAND ${CMAKE_COMMAND} -E create_symlink libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.1 + COMMAND ${CMAKE_COMMAND} -E create_symlink libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.2 COMMENT "Make a symbol link of libmkldnn.so.0") endif() endif()