From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8793 Path: news.gmane.org!not-for-mail From: Denys Vlasenko Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] configure: add gcc flags for better link-time optimization Date: Tue, 27 Oct 2015 20:09:28 +0100 Message-ID: References: <1445603426-4827-1-git-send-email-vda.linux@googlemail.com> <20151023131202.GI10551@port70.net> <20151027012131.GR8645@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1445973011 20161 80.91.229.3 (27 Oct 2015 19:10:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Oct 2015 19:10:11 +0000 (UTC) Cc: musl To: Rich Felker Original-X-From: musl-return-8806-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 27 20:10:05 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 1Zr9dD-00036i-ST for gllmg-musl@m.gmane.org; Tue, 27 Oct 2015 20:10:03 +0100 Original-Received: (qmail 5392 invoked by uid 550); 27 Oct 2015 19:10:00 -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 5363 invoked from network); 27 Oct 2015 19:09:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=UCc9lyiiTcRc+heqt2M9uNJA3f15TqvO8uKjO5tHG98=; b=mkPHJG0im98OzqLd0Bfd3/qRMv3KEOrG0iJ6M+I5wz2Pjf7tE2DQKY9vufQXh08u2C cYYOWduGpSO2fPoCmzgutkqKIDBP720CAInoF/CtqMlOIAZy2dVmIdbJqit+hVWa7co4 nBqFqTZBxJvpiCvQCSsU5/a92OBGDGgpzxvzaS0Fx6zzs2fpH7aV1rVLUPUXA0i98fkq dZwOg1iRgcsvm6Zeg8wJ/jQH/0WLoqjFGdjmADRjpYBeuuvoUNGF91P3QkBpwne5UfjN DJzj9x7Z09kh81XecZShyzBPLS2LL5BosVE9FGVcEmIxG+Qreq5msUBV8QaS/WrRPKZ0 53xA== X-Received: by 10.140.28.66 with SMTP id 60mr51419512qgy.79.1445972987793; Tue, 27 Oct 2015 12:09:47 -0700 (PDT) In-Reply-To: <20151027012131.GR8645@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:8793 Archived-At: On Tue, Oct 27, 2015 at 2:21 AM, Rich Felker wrote: > 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. No, it does not look that way. These options don't give linker any extra freedom to eliminate anything. "nm --size-sort -D libc.so" shows no differences after --sort-section=alignment --sort-common were added to ld command line. After -ffunction-sections -fdata-sections are added to gcc command line, "nm" output does change, the entire difference is as follows: --- libc.so.nm.OLD 2015-10-27 19:57:52.971964518 +0100 +++ libc.so.nm 2015-10-27 19:58:28.544115009 +0100 @@ -18,7 +18,6 @@ 0000000000000001 T setutxent 0000000000000001 W updwtmp 0000000000000001 T updwtmpx -0000000000000002 T dlclose 0000000000000002 T __stack_chk_fail 0000000000000003 T catclose 0000000000000003 T dirfd @@ -84,6 +83,7 @@ 0000000000000005 T catopen 0000000000000005 T creall 0000000000000005 T dladdr +0000000000000005 T dlclose 0000000000000005 T dlinfo 0000000000000005 T __fbufsize 0000000000000005 T __freadptrinc @@ -328,7 +328,6 @@ 000000000000000b T recv 000000000000000b T send 000000000000000b T setprotoent -000000000000000b T tfind 000000000000000b T __xstat 000000000000000b W __xstat64 000000000000000c T __acquire_ptc @@ -417,6 +416,7 @@ 000000000000000e T tcflow 000000000000000e T tcflush 000000000000000e T tcsendbreak +000000000000000e T tfind 000000000000000f T dcgettext 000000000000000f T execv 000000000000000f T execvp @@ -986,8 +986,6 @@ 0000000000000032 T pthread_rwlock_init 0000000000000032 T putchar_unlocked 0000000000000032 T sem_init -0000000000000032 T __stdio_exit -0000000000000032 W __stdio_exit_needed 0000000000000032 T wcschr 0000000000000033 T pthread_rwlock_tryrdlock 0000000000000033 T pthread_setcanceltype @@ -1011,6 +1009,8 @@ 0000000000000035 T pthread_sigmask 0000000000000035 T pwritev 0000000000000035 W pwritev64 +0000000000000035 T __stdio_exit +0000000000000035 W __stdio_exit_needed 0000000000000035 W thrd_detach 0000000000000035 T __tre_mem_destroy 0000000000000035 T tsearch As you see, not a single label was eliminated. The visible small differences in size for a few functions are caused by the need to always use "near" jumps (not "short" ones) for tail call optimizations now, since they now jump across sections: Before: 00000000000274a6 : 274a6: eb c8 jmp 27470 <__reset_tls+0x1f0> After: 000000000002795f : 2795f: e9 c5 ff ff ff jmpq 27929 <__reset_tls+0x1f0>