未验证 提交 e727820d 编写于 作者: W wuhuanzhou 提交者: GitHub

strip after compilation (#32145)

上级 73d0b0e9
...@@ -198,6 +198,7 @@ option(WITH_SW "Compile PaddlePaddle with sw support" OFF) ...@@ -198,6 +198,7 @@ option(WITH_SW "Compile PaddlePaddle with sw support" OFF)
option(WITH_MIPS "Compile PaddlePaddle with mips support" OFF) option(WITH_MIPS "Compile PaddlePaddle with mips support" OFF)
option(WITH_MUSL "Compile with musl libc instead of gblic" OFF) option(WITH_MUSL "Compile with musl libc instead of gblic" OFF)
option(WITH_UNITY_BUILD "Compile with UnityBuild mode" OFF) option(WITH_UNITY_BUILD "Compile with UnityBuild mode" OFF)
option(WITH_STRIP "Strip so files of Whl packages" OFF)
# PY_VERSION # PY_VERSION
if(NOT PY_VERSION) if(NOT PY_VERSION)
...@@ -362,6 +363,13 @@ else() ...@@ -362,6 +363,13 @@ else()
message(WARNING "On inference mode, will take place some specific optimization. Turn on the ON_INFER flag when building inference_lib only.") message(WARNING "On inference mode, will take place some specific optimization. Turn on the ON_INFER flag when building inference_lib only.")
endif() endif()
if(WITH_STRIP)
find_program(STRIP_PATH strip)
if(NOT STRIP_PATH OR NOT LINUX)
set(WITH_STRIP OFF CACHE STRING "Command strip is only used on Linux when it exists." FORCE)
endif()
endif()
add_subdirectory(paddle) add_subdirectory(paddle)
if(WITH_PYTHON) if(WITH_PYTHON)
add_subdirectory(python) add_subdirectory(python)
......
...@@ -119,3 +119,8 @@ if(NOT APPLE AND NOT WIN32) ...@@ -119,3 +119,8 @@ if(NOT APPLE AND NOT WIN32)
DEPENDS paddle_inference_shared) DEPENDS paddle_inference_shared)
add_custom_target(check_symbol ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/.check_symbol") add_custom_target(check_symbol ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/.check_symbol")
endif() endif()
if(LINUX AND WITH_STRIP)
add_custom_command(TARGET paddle_inference_shared POST_BUILD
COMMAND ${STRIP_PATH} $<TARGET_FILE:paddle_inference_shared>)
endif()
...@@ -516,6 +516,12 @@ else: ...@@ -516,6 +516,12 @@ else:
with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r")as f: with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r")as f:
long_description = unicode(f.read(), 'UTF-8') long_description = unicode(f.read(), 'UTF-8')
# strip *.so to reduce package size
if '${WITH_STRIP}' == 'ON':
command = 'find ${PADDLE_BINARY_DIR}/python/paddle -name "*.so" | xargs -i strip {}'
if os.system(command) != 0:
raise Exception("strip *.so failed, command: %s" % command)
with redirect_stdout(): with redirect_stdout():
setup(name='${PACKAGE_NAME}', setup(name='${PACKAGE_NAME}',
version='${PADDLE_VERSION}', version='${PADDLE_VERSION}',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册