From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8789 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] configure: add gcc flags for better link-time optimization Date: Mon, 26 Oct 2015 21:21:31 -0400 Message-ID: <20151027012131.GR8645@brightrain.aerifal.cx> References: <1445603426-4827-1-git-send-email-vda.linux@googlemail.com> <20151023131202.GI10551@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1445908918 4013 80.91.229.3 (27 Oct 2015 01:21:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Oct 2015 01:21:58 +0000 (UTC) Cc: Denys Vlasenko To: musl@lists.openwall.com Original-X-From: musl-return-8802-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 27 02:21:49 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZqsxQ-0007Rm-CU for gllmg-musl@m.gmane.org; Tue, 27 Oct 2015 02:21:48 +0100 Original-Received: (qmail 15674 invoked by uid 550); 27 Oct 2015 01:21:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15656 invoked from network); 27 Oct 2015 01:21:44 -0000 Content-Disposition: inline In-Reply-To: <20151023131202.GI10551@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:8789 Archived-At: On Fri, Oct 23, 2015 at 03:12:02PM +0200, Szabolcs Nagy wrote: > * Denys Vlasenko [2015-10-23 14:30:26 +0200]: > > libc.so size reduction: > > > > text data bss dec hex filename > > 564099 1944 11768 577811 8d113 libc.so.before > > 562277 1924 11576 575777 8c921 libc.so > > > > i assume this is x86_64, nice improvement. I suspect all of this difference comes from optimizing out dummy weak functions that are replaced by strong versions in other files. The same savings could be achieved by eliminating them with #ifndef SHARED, but as noted elsewhere I actually want to eliminate all such #ifdefs and build only one set of .o files to use for libc.so and libc.a. So I think this looks like a nice way to get the same benefit without #ifdef. BTW I noticed that __simple_malloc (in lite_malloc.c) is external despite there being no need for it to be external. If we make it static, I think gc-sections will be able to remove it too. (Denys, if you want to try the numbers with it made static before I get around to it, I'd be happy to hear results.) > > +# When linker merges sections, a tiny section (such as one resulting > > +# from "static char flag_var") with no alignment restrictions > > +# can end up logded between two more strongly aligned ones (say, > > +# "static int global_cnt1/2", both of which want 32-bit alignment). > > +# Then this byte-sized "flag_var" gets 3 bytes of padding. > > +# > > +# With section sorting by alignment, one-byte flag variables have > > +# higher chance of being grouped together and not require padding. > > +# (It can be made even better. Linker is too dumb. > > +# ld needs to grow -Wl,--pack-sections-optimally) > > +# > > +# For us, this affects the size of only one file: libc.so > > +# > > +tryldflag LDFLAGS_AUTO -Wl,--sort-section=alignment > > +tryldflag LDFLAGS_AUTO -Wl,--sort-common > > i think this came up before > https://sourceware.org/bugzilla/show_bug.cgi?id=14156 I don't think this bug affects linkin musl itself, since we don't have init or fini sections, so we probably don't have to worry about it. Does this sound correct? If there's a risk of these options making breakage with some binutils versions then we probably have to detect that, but hopefully there's not. Rich