public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "andi-gcc at firstfloor dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/107779] New: Support implicit references from inline assembler to compiler symbols
Date: Mon, 21 Nov 2022 07:05:31 +0000	[thread overview]
Message-ID: <bug-107779-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107779

            Bug ID: 107779
           Summary: Support implicit references from inline assembler to
                    compiler symbols
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andi-gcc at firstfloor dot org
                CC: hubicka at gcc dot gnu.org, marxin at gcc dot gnu.org,
                    mliska at suse dot cz
  Target Milestone: ---

Created attachment 53933
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53933&action=edit
prototype patch

So I looked into the problem the kernel people complained about: a
lot of assembler statements reference C symbols, which need externally_visible
and
    global for gcc LTO, otherwise they can end up in the wrong asm file
    and cause missing symbols.

I came up with the attached (hackish) patch that tries to solve the problem
very
partially: it parses the assembler strings and looks for anything that
could be an identifier, and then tries to mark it externally_visible.

It has the following open issues:

    - The parsing is very approximate and doesn't handle some obscure cases.
    With the approximation it's also impossible to give error messages,
    but hopefully the linker takes care of that.
    It also gives false positives with some assembler syntax,
    but in the worst case would just lose some optimization from unnecessary
    references.

    - It doesn't handle the case (which happens in the kernel) that the C
    declaration is after the asm statement. This could be fixed with some
    more effort.

    - It doesn't work for static which can get mangled (that's a lot of
    the kernel cases)
    static is a difficult problem because there could be conflicting names,
    so we cannot jut put it all in partition zero.

    This would need some special handling in the LTO partitioning code to
    create new partitions just for having unique name spaces, and then
    avoid mangling.  Related problem is also PR50676

    It's likely possible to create situations where it's impossible to
    solve, there could be circular dependencies etc. But I assume in this
    case the non LTO case would fail too.

    Or maybe do something with redefining symbols at the assembler level.

    This one is somewhat difficult and I don't have a simple solution
    currently. Unfortunately to solve the kernel issue would need a
    solution for static.

             reply	other threads:[~2022-11-21  7:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21  7:05 andi-gcc at firstfloor dot org [this message]
2022-11-21  7:12 ` [Bug lto/107779] " pinskia at gcc dot gnu.org
2022-11-21 17:32 ` pinskia at gcc dot gnu.org
2022-11-22  8:36 ` rguenth at gcc dot gnu.org
2023-10-15 22:55 ` andi-gcc at firstfloor dot org

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=bug-107779-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).