public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Alexander Miller <alex.miller@gmx.de>, elfutils-devel@sourceware.org
Subject: Re: [PATCH] Improve building with LTO
Date: Wed, 17 Feb 2021 21:22:15 +0100	[thread overview]
Message-ID: <f595fe47b122f545178ef79a7227f48e2e6f3400.camel@klomp.org> (raw)
In-Reply-To: <20210214235718.7654b5f1.alex.miller@gmx.de>

Hi Alexander,

First my apologies, your last commit had "Alexander Miller via
Elfutils-devel <elfutils-devel@sourceware.org>" as author. That is the
stupid mailinglist doing From mangling, bad mailinglist. But also bad
me for not catching that. We probably need a git hook to reject pushes
with such bogus authors. Could you add a From: Alexander Miller <
alex.miller@gmx.de> in the body (I believe git send-email --from=...
will do that for you). That way git am does the right thing.

On Sun, 2021-02-14 at 23:57 +0100, Alexander Miller via Elfutils-devel wrote:
> Here's my attempt to use gcc-10's new symver attribute to avoid global
> asm statements that cause trouble with LTO. That requires converting
> from triple @ syntax to double @ syntax. To satisfy those picky linkers,
> the unversioned name of the affected symbols has to be changed.
> The NEW_VERSION macros have to be moved before the function definitions.

This is really exciting! I had more or less given up on this. I
couldn't make it work because of the triple @ syntax not being
supported. But it looks we don't need that after all.

> Also tried to improve the situation for older gcc versions. Although
> gcc-5 added a no_reorder attribute that's supposed to help here, it
> doesn't work reliably (but improves the situation substantially).

So you rewrite the asm statements to not use @@@ just @ and @@, that
way they match the symver attribute usage. Smart, that way they are as
similar as possible.

> I've tested the patch with different compilers (gcc-10, gcc-9, gcc-6,
> clang-11), linkers (bfd, gold, lld), 32/64 bit (x86), with/without LTO.
> Of course you need to cheat a bit to build elfutils with clang, and
> lld can't be used with every combination. The workaround for older gcc
> was enough for gcc-9 and 32bit gcc-6, but 64bit gcc-6 builds needed
> -flto-partition=none, so this seems to depend on the version and options
> used.

Wow, you really went above and beyond. IMHO it would have been fine to
simply say that you need GCC10 and a recent binutils ld to get LTO
working. Supporting LTO with gcc-6 is really nice, but people stuck on
such an old compiler should probably first look at upgrading that than
trying to play with LTO. We should probably look at making an LTO build
part of the buildbot.

> Symbol versioning worked as expected in all cases, at least the list
> of dynamic symbols of the libs looked good to me.
> 
> The test suite seems brittle, though. It fails on 32bit builds, with
> gold or lld, and with lto builds using clang (unknown object format)
> or gcc-6 (debug info not found). But that's not related to this patch.
> For 64bit builds with gcc-{9,10} and bfd, the test suite succeeds even
> with lto enabled.

Do the 32bit builds with gcc10/binutils ld have a clean test suite?

> Additional notes:
> * The asm names for the compat versions seem unnecessary, but I've
>   kept them.
> * Commenting out old versions in the .map file may not be needed.
>   It's mostly a leftover from an earlier attempt, but I didn't want to
>   re-run all test and I actually prefer it like this, so I left it in.

I would like to make sure it isn't needed. Having to comment out old
versions is a bit of a pain. In my own attempts I actually tried it the
other way around. Keep the earliest version in the version script and
don't add (remove) new versions (those would come from the symver).
That is slightly easier for maintenance, so you don't need to remove
older versions, just add the new (.symver) version in the source.

> * See commit message below.
> 
> ------------------------ 8< ------------------------
> Use symver attribute for symbol versioning instead of .symver
> assembler directive when available. Convert to use double @ syntax
> for default version in all cases (required when using the attribute).
> 
> Add the attributes externally_visible, no_reorder if available when
> using assembler directives to improve the situation for < gcc-10.
> This is not 100% reliable, though; -flto-partition=none may still be
> needed in some cases.

How does the __COUNTER__ magic work?

> Note that -Wno-error=stack-usage= is still needed to build with LTO.

Yeah that is a pity. The issue is in just a few files, but with LTO
those get combined with all the others causing issues. I believe the
warnings are only in the tools now. It would be really good if we could
get rid of the stack-usage warnings in: readelf.c, nm.c, size.c,
strip.c, elflint.c, findtextrel.c, elfcmp.c, objdump.c, ranlib.c, ar.c,
unstrip.c. But that is for another day.

I have to stare at the marcos a bit to make sure I really understand
what is going on. But this looks really good.

Thanks,

Mark

  reply	other threads:[~2021-02-17 20:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-14 22:57 Alexander Miller
2021-02-17 20:22 ` Mark Wielaard [this message]
2021-02-18 14:27   ` Alexander Miller
2021-02-18  2:38 ` [PATCH v2] " Alexander Miller
2021-08-28  9:31   ` Dmitry V. Levin
2021-11-04 11:23     ` Dmitry V. Levin
2021-11-04 12:12       ` Mark Wielaard
2021-11-08 10:02         ` Dmitry V. Levin
2021-11-08 23:18           ` Mark Wielaard
2021-11-09  8:58             ` Dmitry V. Levin
2021-11-09  9:04               ` Martin Liška
2021-11-09  9:09                 ` Dmitry V. Levin
2021-11-09  9:11                   ` Martin Liška
2021-11-09 11:45                 ` Mark Wielaard
2021-11-09 13:31                   ` Martin Liška
2021-11-09 13:33                     ` Martin Liška
2021-11-09 17:49                     ` Mark Wielaard

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=f595fe47b122f545178ef79a7227f48e2e6f3400.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=alex.miller@gmx.de \
    --cc=elfutils-devel@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).