mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Andre McCurdy <armccurdy@gmail.com>
To: musl@lists.openwall.com
Cc: Andre McCurdy <armccurdy@gmail.com>
Subject: building musl libc.so with gcc -flto
Date: Wed, 22 Apr 2015 15:48:52 -0700	[thread overview]
Message-ID: <1429742932-6026-1-git-send-email-armccurdy@gmail.com> (raw)

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
--


             reply	other threads:[~2015-04-22 22:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 22:48 Andre McCurdy [this message]
2015-04-23  2:23 ` Rich Felker
2015-04-23  5:34   ` Andre McCurdy
2015-04-23  9:45     ` Rich Felker
2015-04-28  0:16       ` Andre McCurdy
2015-04-28  0:24         ` Rich Felker
2015-04-28  6:23           ` Andre McCurdy
2015-04-28 13:44             ` Rich Felker
2015-04-29  1:42               ` Andre McCurdy
2015-04-29  3:27                 ` Rich Felker
2015-05-01  5:48                   ` Andre McCurdy
2015-05-01 10:10                     ` Szabolcs Nagy
2015-05-01 15:49                       ` Rich Felker
2015-04-30 20:46   ` Andy Lutomirski
2015-04-30 23:44     ` Rich Felker
2015-05-01  6:57       ` Alexander Monakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429742932-6026-1-git-send-email-armccurdy@gmail.com \
    --to=armccurdy@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).