Cla*_*dio 4 linux binary gcc native gnu
所以我使用旧的 CentOS 6.6 发行版,并从源代码编译了 GCC 5.2。当我安装它时,它会在 libexec 下创建 5.2.0 子文件夹,但二进制文件 cc1 和 cc1 plus 非常巨大!
这是我的构建方法
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=/usr2/libexec/gcc/i686-redhat-linux-gnu/5.2.0/lto-wrapper
Target: i686-redhat-linux-gnu
Configured with: ../configure
--prefix=/usr2
--disable-multilib
--enable-languages=c,c++
--enable-gnu-unique-object
--disable-dssi
--enable-libstdcxx-threads
--enable-libstdcxx-time
--enable-shared
--enable-__cxa_atexit
--disable-libunwind-exceptions
--disable-libada
--host=i686-redhat-linux-gnu
--build=i686-redhat-linux-gnu
--target=i686-redhat-linux-gnu
--with-default-libstdcxx-abi=gcc4-compatible
--with-arch=i686
--enable-linker-build-id
--with-system-zlib
--with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.2.0 (GCC)
Run Code Online (Sandbox Code Playgroud)
这是发行版中 4.4.7 的 ls
-rwxr-xr-x 1 root root 8566416 Jul 23 00:19 cc1
-rwxr-xr-x 1 root root 9574772 Jul 23 00:19 cc1plus
-rwxr-xr-x 1 root root 101596 Jul 23 00:19 collect2
-rwxr-xr-x 1 root root 9419280 Jul 23 00:19 f951
Run Code Online (Sandbox Code Playgroud)
这里和新编译的5.2.0是一样的
-rwxr-xr-x 1 root root 102532928 Dec 11 16:48 cc1
-rwxr-xr-x 1 root root 109000772 Dec 11 16:48 cc1plus
-rwxr-xr-x 1 root root 2033844 Dec 11 16:48 collect2
drwxr-xr-x 2 root root 4096 Dec 11 16:48 install-tools
-rwxr-xr-x 1 root root 995 Dec 11 16:48 liblto_plugin.la
lrwxrwxrwx 1 root root 22 Dec 11 16:48 liblto_plugin.so -> liblto_plugin.so.0.0.0
lrwxrwxrwx 1 root root 22 Dec 11 16:48 liblto_plugin.so.0 -> liblto_plugin.so.0.0.0
-rwxr-xr-x 1 root root 235508 Dec 11 16:48 liblto_plugin.so.0.0.0
-rwxr-xr-x 1 root root 98350432 Dec 11 16:48 lto1
-rwxr-xr-x 1 root root 2288396 Dec 11 16:48 lto-wrapper
Run Code Online (Sandbox Code Playgroud)
cc1、cc1plus 和 lto1 各为 100MB。5.2这个正常吗?为什么会出现这种情况?
感谢 @Marc Glisse 评论,我在两个二进制文件上运行了一个文件
5.2.0/cc1: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
4.4.7/cc1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
Run Code Online (Sandbox Code Playgroud)
这是剥离后的结果吗?我缺少什么配置标志?
感谢@MarcGlisse 为我指明了正确的方向。
无论你如何配置GCC,除非你安装
make install-strip
Run Code Online (Sandbox Code Playgroud)
二进制文件将充满符号。安装精简版本后,大小缩小了 70%。
-rwxr-xr-x 1 root root 19749196 Dec 14 13:01 cc1
-rwxr-xr-x 1 root root 21057676 Dec 14 13:01 cc1plus
-rwxr-xr-x 1 root root 507336 Dec 14 13:01 collect2
drwxr-xr-x 2 root root 4096 Dec 14 13:01 install-tools
-rwxr-xr-x 1 root root 995 Dec 14 13:01 liblto_plugin.la
lrwxrwxrwx 1 root root 22 Dec 14 13:01 liblto_plugin.so -> liblto_plugin.so.0.0.0
lrwxrwxrwx 1 root root 22 Dec 14 13:01 liblto_plugin.so.0 -> liblto_plugin.so.0.0.0
-rwxr-xr-x 1 root root 76972 Dec 14 13:01 liblto_plugin.so.0.0.0
-rwxr-xr-x 1 root root 18930924 Dec 14 13:01 lto1
-rwxr-xr-x 1 root root 693024 Dec 14 13:01 lto-wrapper
drwxr-xr-x 2 root root 4096 Dec 14 13:01 plugin
Run Code Online (Sandbox Code Playgroud)