From owner-freebsd-current@FreeBSD.ORG Wed Sep 18 06:22:47 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BDDEC45B; Wed, 18 Sep 2013 06:22:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4209A2FD5; Wed, 18 Sep 2013 06:22:47 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.7/8.14.7) with ESMTP id r8I6Mf4p019771; Wed, 18 Sep 2013 09:22:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua r8I6Mf4p019771 Received: (from kostik@localhost) by tom.home (8.14.7/8.14.7/Submit) id r8I6MfMV019770; Wed, 18 Sep 2013 09:22:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 18 Sep 2013 09:22:41 +0300 From: Konstantin Belousov To: Ed Schouten Subject: Re: -ffunction-sections, -fdata-sections and -Wl,--gc-sections Message-ID: <20130918062241.GW41229@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="U23J1OQliU0BUf8i" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: Matthew Fleming , FreeBSD Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Sep 2013 06:22:47 -0000 --U23J1OQliU0BUf8i Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 17, 2013 at 11:45:19PM +0200, Ed Schouten wrote: > Hi Matthew, >=20 > 2013/9/16 Matthew Fleming : > > Would it be possible to enable this only for devd, init, and clang bina= ries? > > Or is it a matter of enabling it for library builds that are linked > > statically with the mentioned binaries? >=20 > For it to have effect, it has to be enabled for both the libraries and > the binaries. The libraries need to be built with > -f{data,function}-sections. The binaries can also be built with those > flags, but it is actually more important to link with --gc-sections. >=20 > > Could init/devd be made smaller by > > finding out which functions they do/don't use and separating those into > > separate .c files? >=20 > Also trying to answer Tim and Adrian's questions at the same time. > I've just taken a look at init and devd to see why the difference in > size is so big: >=20 > init seems to pull in the following things: >=20 > - Sun RPC, > - XDR, > - YP, > - res_*, > - All of the jemalloc profiling/stats code, > - Some widechar functions, > - malloc-related utility functions that are not used (posix_memalign, > aligned_alloc), > - Some stdio bloat, > - All sorts of termios tc* functions. >=20 > devd seems to pull in these: >=20 > - A very big pile of C++ symbols, as libc++ places many functions in a > single file. > - jemalloc profiling/stats again, > - A big pile of pthread, > - Maybe *_l() functions, which are of course rarely used. >=20 > Honestly, I think we can assume we'll never reach the point where all > the components listed above will properly have all functions > partitioned over separate compilation units. >=20 > I suspect that it would make a lot of sense to at least enable these > build flags for our core libraries (libc, libc++, libpthread, > libcompiler_rt, libcxxrt, etc). We could also enable it on > INTERNALLIBs (libraries that are not installed into /usr/lib), as for > these libraries, it would of course not come at any cost. >=20 > Would that sound okay? I think this is a wrong direction. First, the split should be done at the source level, as it was usually done forever. One of the offender there was you, AFAIR. Second, I would rather see init and devd, and in fact all other statically linked binaries from our base system, to become dynamically linked. At least I added a knob for building toolchain dynamic, but avoided the fight of making this default. --U23J1OQliU0BUf8i Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (FreeBSD) iQIcBAEBAgAGBQJSOUawAAoJEJDCuSvBvK1BR8kP/2dMn8XmWawgDqJ5/8O6PlV9 PFswbjrKV6RJMl2bSWdnB5sxkliCbAVoe8/h2cAtALTDEwuNGSSA5MKitcIGt7ov tmbuR5P/svHOK1yqfSb21MnRDLOCdmcxX1IOot1hsGrmD5pdrkiskc3chj/nBja1 Z4L5688AwsBN7zDypL3ebn+sxngxZZQCyyKfu/ewPUSBcp+8crQQU8Q1HauL9PjL yuu5wkniS6uH9K4YL1Am13JvTQMrJi+1tSFVLeqvjwhoAJ83zaOcwcNM8zOEAJpt 3QNj3oxWJz3rShvuxGOmWC70jmPqGD1Skxe6HU5AgMpicXfBgyfo/cd8RR3rwcXB RBKkZNGm3GADXyNrcUWVeX7RAMKzHNmm0YcAzz+Z76f4xKoD1s8juI8l7nOcJcO8 lur8+BNyysfLpYXBpIeTZ++isZ/CdwSos9+gqv9Y9K7cmkpx+b4TdLtppgAsa2Bi R1mrMatKzlhDKMM1lK9DxLqMsmwpbBIy1ZQBBQXgtFLF/XGf3yAHb/ncO4GfIUlj QLMzSf5XViYT7f8LHFetnRLAvFBHoeIO/BMRdCA7hW0euPnKLDBEbvxipFT9nG73 ZqlV2P+vQGzqYGSM0lnywJvYcf1/2mWRNfSq0rwsPcLZZ+HqjzJjwa81QnOjMZOM 23ySmYvV9qAyEyONhr6k =ZnpO -----END PGP SIGNATURE----- --U23J1OQliU0BUf8i--