Skip to content

利用 linux strip 命令给编译后的文件瘦身 #115

Description

@lanlin

情景

希望制作出更小的 docker image, 或者说给编译后的程序瘦身。
这个时候可以尝试采用 strip 命令,或许会有意想不到的惊喜。

指令

strip /path/to/your/compiled/file

例如:strip /usr/local/php/extensions/*.so

注意,该指令是对编译之后的文件使用,而不是对源码文件使用。

安装

如果系统中没有 strip 可通过安装 binutils 包来安装。

效果展示:

  1. 瘦身前的 php grpc 扩展(>140M)
    image

  2. 瘦身后的 php grpc 扩展 (< 7M)
    image

同时可以看到,其他扩展也有大小不等的瘦身效果

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions