From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7470 Path: news.gmane.org!not-for-mail From: Andre McCurdy Newsgroups: gmane.linux.lib.musl.general Subject: building musl libc.so with gcc -flto Date: Wed, 22 Apr 2015 15:48:52 -0700 Message-ID: <1429742932-6026-1-git-send-email-armccurdy@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1429742989 13334 80.91.229.3 (22 Apr 2015 22:49:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Apr 2015 22:49:49 +0000 (UTC) Cc: Andre McCurdy To: musl@lists.openwall.com Original-X-From: musl-return-7483-gllmg-musl=m.gmane.org@lists.openwall.com Thu Apr 23 00:49:48 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 1Yl3Sl-0008G0-FZ for gllmg-musl@m.gmane.org; Thu, 23 Apr 2015 00:49:47 +0200 Original-Received: (qmail 30410 invoked by uid 550); 22 Apr 2015 22:49: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 30263 invoked from network); 22 Apr 2015 22:49:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=/2clE5pbELVC9qcocoS7UyOWbpxPViHO7+kpTYLz3D8=; b=qCsaTYplR+Al34Qmds4Etd0PLywQulcHAqpGiVDwTabR+4wghsQmpwIOK+lqk8CN8Q J0Cw2cnhUwYsRJjcDkjGyXfRuJ4mbrLNad4qGtyplXB3osCSb74uGwfdsjQ+lYzkBq5W jyCNlA7coHDUOJs4ruXETNWCskPKfyONeA5p8cEvEMc8hX4bst9IAVmKRjWv6++nfum/ sJm2wfozotlz4puKRUsWqPp48k7wSABtlYc1PAu7HQL1CMYIyAkrLX70IkEF3ZzTpuWg w1z7il3yWlSG1j43fA4ldY6oc7irBPQ/5fwD6sqMryy4hyFM94nvdVXkYGp/6PkzQfki vNjg== X-Received: by 10.107.16.32 with SMTP id y32mr39716359ioi.53.1429742940461; Wed, 22 Apr 2015 15:49:00 -0700 (PDT) X-Mailer: git-send-email 1.9.1 Xref: news.gmane.org gmane.linux.lib.musl.general:7470 Archived-At: Hi all, Below are some observations from building musl libc.so with gcc's -flto (link time optimization) option. 1) With today's master (afbcac68), adding -flto to CFLAGS causes the build to fail: | `_dlstart_c' referenced in section `.text' of /tmp/cc8ceNIy.ltrans0.ltrans.o: defined in discarded section `.text' of src/ldso/dlstart.lo (symbol from plugin) | collect2: error: ld returned 1 exit status | make: *** [lib/libc.so] Error 1 Reverting f1faa0e1 (make _dlstart_c function use hidden visibility) seems to be a workaround. 2) With f1faa0e1 reverted, the build succeeds, but with a warning about differing declarations for dummy_tsd and __pthread_tsd_main: | src/thread/pthread_create.c:169:1: warning: type of '__pthread_tsd_main' does not match original declaration | weak_alias(dummy_tsd, __pthread_tsd_main); | ^ | src/thread/pthread_key_create.c:4:7: note: previously declared here | void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 }; | ^ 3) Overall build times are similar, but archieving the best results with -flto relies on manually duplicating any 'make -j' options for the linker. Times below are from a quad core + hyperthreading system running 'make -j8 lib/libc.so': original : real 0m8.501s -flto : real 0m18.034s -flto=4 : real 0m9.885s -flto=8 : real 0m8.876s 4) Changes in code size seem to be minor, except when compiling with -O3, where the code gets noticably larger (presumably due to -flto giving a lot more scope for inlining?). Results below are from building with gcc 4.9.2 for 32bit x86: text data bss dec hex filename 536405 1416 8800 546621 8573d lib/libc.so ( -Os ) 536324 1324 8780 546428 8567c lib/libc.so.lto ( -Os ) 612028 1416 8928 622372 97f24 lib/libc.so ( -O2 ) 611701 1304 9132 622137 97e39 lib/libc.so.lto ( -O2 ) 687708 1416 8992 698116 aa704 lib/libc.so ( -O3 ) 713704 1312 9208 724224 b0d00 lib/libc.so.lto ( -O3 ) Andre --