mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Леонид Юрьев (Leonid Yuriev)" <leo@yuriev.ru>
To: musl@lists.openwall.com
Cc: Jiahao XU <Jiahao_XU@outlook.com>
Subject: Re: [musl] Can’t build musl with lto=thin
Date: Sat, 30 Jan 2021 23:59:14 +0300	[thread overview]
Message-ID: <CAO2+NUAO607B6vRhWdOt9+p9Ccx-aWr=Td9=kyE1rgFME=dwMw@mail.gmail.com> (raw)
In-Reply-To: <20210130201227.GP23432@brightrain.aerifal.cx>

I have some experience in solving problems with LTO, including for
embedded projects.
Therefore, perhaps my thoughts and advice will be useful.

In general, LTO almost always requires a little refinement of source
code but problems arise only with really dirty code or due to
ill-conceived modularity.
For instance, the ODR must not be violated.

On Sat, Jan 30, 2021 at 11:12 PM Rich Felker <dalias@libc.org> wrote:
> The -fmerge-all-constants option gives non-conforming language
> semantics and should not be used, but that's a separate issue.

There are no problems with constants, unless it's addresses are used
to distinguish ones (and even more so to change).
But this is easily workarounded by placing such constants inside an
instance of a single static structure, etc.

> Otherwise, it's a known issue that LTO misses references from asm
> (both top-level and in functions). I think dlstart.lo and a few other
> files should just be built with LTO disabled; any LTO-type
> optimization in code that runs at this stage is inherently invalid,
> anyway. So something like (in config.mak):

This is easily workarounded by adding __attribute__((__used__)) or
__attribute__((__externally_visible__)) to the function/variable
definition, but requires binutils version >= 2.36.

Regards,
Leonid.

  reply	other threads:[~2021-01-30 21:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-29 12:19 Jiahao XU
2021-01-29 20:04 ` Szabolcs Nagy
2021-01-29 20:53   ` Fangrui Song
2021-01-30 20:12 ` Rich Felker
2021-01-30 20:59   ` Леонид Юрьев (Leonid Yuriev) [this message]
     [not found]   ` <SYBP282MB020277E08EB49C9AC9BF90888AB89@SYBP282MB0202.AUSP282.PROD.OUTLOOK.COM>
2021-01-30 23:30     ` Rich Felker
     [not found]       ` <SYBP282MB0202BF16DD08A2F1537FD5428AB89@SYBP282MB0202.AUSP282.PROD.OUTLOOK.COM>
2021-01-31  5:01         ` Rich Felker
2021-01-31  5:32           ` Jiahao XU
2021-01-31 21:01             ` Rich Felker
2021-01-31 22:29               ` Jiahao XU
2021-02-01  0:22               ` Jiahao XU
2021-02-01  0:31                 ` Jiahao XU
2021-02-01  0:44                   ` Jiahao XU
2021-02-01  0:50                     ` Jiahao XU
2021-02-01 13:20                       ` Jiahao XU
2021-02-01 16:55                         ` Nick Bray
2021-02-01 17:53                   ` Rich Felker
2021-02-01 18:06                     ` Fangrui Song
2021-02-01 21:20                       ` Jiahao XU
2021-02-13 17:54                         ` Tim Tassonis
2021-02-14  5:59                           ` Markus Wichmann

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='CAO2+NUAO607B6vRhWdOt9+p9Ccx-aWr=Td9=kyE1rgFME=dwMw@mail.gmail.com' \
    --to=leo@yuriev.ru \
    --cc=Jiahao_XU@outlook.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).