Gentoo Archives: gentoo-user

From: walt <w41ter@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: bloated by gcc
Date: Sun, 28 Sep 2014 23:09:42
Message-Id: m0a06e$4ff$1@ger.gmane.org
In Reply to: [gentoo-user] bloated by gcc by Jorge Almeida
1 On 09/28/2014 01:44 AM, Jorge Almeida wrote:
2 > I'm having a somewhat disgusting issue on my Gentoo: binaries are
3 > unaccountably large.
4 >
5 > I'm talking about C programs of my own, so no version related issues
6 > whatsoever. The computer is a core i3 with a 32 bit system.
7 >
8 > Example, for the same program:
9 >
10 > 10275 B on an atom running Slackware 14.1 (gcc 4.8.2)
11 > 5896 B (same, stripped with strip --strip-unneeded)
12 >
13 > 11675 B on i3, Gentoo, gcc 4.8.3 (with default gcc it was worse)
14 > 9704 B stripped
15 >
16 > 8207 B on *the same i3 box* running LFS (gcc 4.9.1)
17 > 5768 B stripped
18 >
19 > When compiling against dietlibc, the difference is even more shocking
20 > (almost double size in Gentoo after stripping).
21 >
22 > Compiled with:
23 > gcc -Os -march=i686 -fomit-frame-pointer -pipe -Wall -pedantic
24 > -fdata-sections -ffunction-sections -Wl,--gc-sections
25 > -fno-asynchronous-unwind-tables -std=c99
26 >
27 > Gentoo:
28 > $ gcc -v
29 > Using built-in specs.
30 > COLLECT_GCC=/usr/i686-pc-linux-gnu/gcc-bin/4.8.3/gcc
31 > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/lto-wrapper
32 > Target: i686-pc-linux-gnu
33 > Configured with:
34 > /var/tmp/portage/sys-devel/gcc-4.8.3/work/gcc-4.8.3/configure
35 > --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --prefix=/usr
36 > --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.8.3
37 > --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/include
38 > --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.8.3
39 > --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.8.3/man
40 > --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.8.3/info
41 > --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/include/g++-v4
42 > --with-python-dir=/share/gcc-data/i686-pc-linux-gnu/4.8.3/python
43 > --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
44 > --disable-werror --with-system-zlib --disable-nls
45 > --enable-checking=release --with-bugurl=https://bugs.gentoo.org/
46 > --with-pkgversion='Gentoo 4.8.3' --enable-libstdcxx-time
47 > --enable-shared --enable-threads=posix --enable-__cxa_atexit
48 > --enable-clocale=gnu --disable-multilib --disable-altivec
49 > --disable-fixed-point --with-arch=i686 --enable-targets=all
50 > --disable-libgcj --enable-libgomp --disable-libmudflap
51 > --disable-libssp --enable-lto --without-cloog
52 > Thread model: posix
53 > gcc version 4.8.3 (Gentoo 4.8.3)
54 >
55 > LFS:
56 > ## gcc -v
57 > Using built-in specs.
58 > COLLECT_GCC=gcc
59 > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.9.1/lto-wrapper
60 > Target: i686-pc-linux-gnu
61 > Configured with: ../gcc-4.9.1/configure --prefix=/usr
62 > --enable-languages=c,c++ --disable-multilib --disable-bootstrap
63 > --with-system-zlib
64 > Thread model: posix
65 > gcc version 4.9.1 (GCC)
66 >
67 > Slackware:
68 > Reading specs from /slash/usr/bin/../lib/gcc/i486-slackware-linux/4.8.2/specs
69 > COLLECT_GCC=gcc
70 > COLLECT_LTO_WRAPPER=/slash/usr/bin/../libexec/gcc/i486-slackware-linux/4.8.2/lto-wrapper
71 > Target: i486-slackware-linux
72 > Configured with: ../gcc-4.8.2/configure --prefix=/usr
73 > --libdir=/usr/lib --mandir=/usr/man --infodir=/usr/info
74 > --enable-shared --enable-bootstrap
75 > --enable-languages=ada,c,c++,fortran,go,java,lto,objc
76 > --enable-threads=p osix --enable-checking=release --enable-objc-gc
77 > --with-system-zlib --with-python-dir=/lib/python2.7/site-packages
78 > --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp
79 > --enable-lto --with-gnu-ld --verbose --enable-java-home
80 > --with-java-home=/usr/lib/jvm/jre --with-jvm-root-dir=/usr/lib/jvm
81 > --with-jvm-jar-dir=/usr/lib/jvm/jvm-exports --with-arch-directory=i386
82 > --with-antlr-jar=/root/slackware-current/source/d/gcc/antlr-runtime-3.4.jar
83 > --enable-java-awt=gtk --disable-gtktest --with-arch=i486
84 > --target=i486-slackware-linux --build=i486-slackware-linux
85 > --host=i486-slackware-linux
86 > Thread model: posix
87 > gcc version 4.8.2 (GCC)
88 >
89 > I'm not elfwise, but I could post something to google drive if needed.
90
91 Are you cross-compiling for different hardware? I'm just curious what results
92 you get with --march=native.
93
94 Also, I looked up data-sections and function-sections (which I'd never heard
95 of before today :) The gcc man page says the resulting executable will be
96 larger and slower, and not to use them "unless there are significant benefits"
97 but then doesn't say what those benefits might be. Hm, cryptic.

Replies

Subject Author
Re: [gentoo-user] Re: bloated by gcc Jorge Almeida <jjalmeida@×××××.com>