所以我使用旧的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)
这是发行版中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
以下是新编译的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
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
剥离是否有所作为? 我错过了什么配置标志?
答案 0 :(得分:2)
感谢@MarcGlisse指出我正确的方向。
无论您如何配置GCC,除非您使用
进行安装make install-strip
二进制文件将充满符号。 安装剥离版本使尺寸缩小了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