mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: Some questions
Date: Tue, 1 May 2018 12:32:47 +1000	[thread overview]
Message-ID: <CAEg67GmJ6JjAQ8Pv9CObumard+WEgLDP=2tpAVFFS9Ez1KmB-A@mail.gmail.com> (raw)
In-Reply-To: <20180430152951.GK1392@brightrain.aerifal.cx>

On Tue, May 1, 2018 at 1:29 AM, Rich Felker <dalias@libc.org> wrote:
> On Mon, Apr 30, 2018 at 03:17:11PM +1000, Patrick Oppenlander wrote:
>> Last time I tried to LTO a C library I ran into this:
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63215#c1
>
> I don't quite understand the issue as reported there. The example is
> defining abs in a way that could be self-referential in the absence of
> -fno-builtin or -ffreestanding (which implies -fno-builtin). But the
> use of -ffreestanding is always necessary to build a libc. This is in
> no way specific to LTO.

There were other related bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60395
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58203

It all boiled down to the case where gcc was emitting a runtime symbol
and couldn't resolve the reference at static link time.

I've just run through the various test cases and they appear to be
resolved in the gcc on this arch box (7.3.1).

> Anyway I don't think this issue affects musl but I'm not sure.

You're probably right.

> The issue I'm aware of is that the reference to _start_c from the
> top-level asm _start function is not seen by LTO. This should be
> possible to work around just by teaching configure to check if
> -fno-lto is supported, and if so having the Makefile pass it for crt
> files. But I'm skeptical that you'd get much benefit applying LTO to
> musl itself. It's known that you don't for producing a shared library
> (ppl have tested this), but static may fare better. In theory a really
> smart LTO could optimize out the whole floating point support from
> printf when all formst strings are literals and none contain %f's, but
> in practice none are anywhere near that smart.

Marking _start_c with __attribute__((used)) should also work.

In a static link LTO will also inline many trivial functions from the
C library which can reduce binary size and help with instruction cache
footprint & locality. I've had good results especially on targets with
small instruction caches executing in place.

Another benefit is constant propagation across the library boundary
which can also eliminate reasonable amounts of code.

Patrick


  reply	other threads:[~2018-05-01  2:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  2:52 Patrick Oppenlander
2018-04-30  3:16 ` Rich Felker
2018-04-30  3:55   ` Patrick Oppenlander
2018-04-30 15:35     ` Rich Felker
2018-05-01  2:35       ` Patrick Oppenlander
2018-05-01 21:03         ` Rich Felker
2018-05-01 22:14           ` Patrick Oppenlander
2018-04-30  5:17   ` Patrick Oppenlander
2018-04-30 15:29     ` Rich Felker
2018-05-01  2:32       ` Patrick Oppenlander [this message]
2018-04-30  5:29   ` Patrick Oppenlander
2018-04-30 15:31     ` Rich Felker
2018-05-01  2:34       ` Patrick Oppenlander
2018-05-01 15:52         ` Rich Felker
2018-05-01 17:35           ` Rich Felker
2018-05-01 21:49             ` Andre McCurdy
2018-05-01 22:14               ` Szabolcs Nagy
2018-05-02 13:42                 ` Rich Felker
2018-05-01  0:10   ` Patrick Oppenlander
2018-05-01 14:19     ` Szabolcs Nagy
2018-05-01 21:05     ` Rich Felker

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='CAEg67GmJ6JjAQ8Pv9CObumard+WEgLDP=2tpAVFFS9Ez1KmB-A@mail.gmail.com' \
    --to=patrick.oppenlander@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).