public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/109253] libbpf: failed to find BTF info for global/extern symbol '__divdi3'
Date: Tue, 28 Nov 2023 15:23:01 +0000	[thread overview]
Message-ID: <bug-109253-4-ARiSoKCLDI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109253-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jose E. Marchesi <jemarch@gcc.gnu.org>:

https://gcc.gnu.org/g:f31a019d1161ec78846473da743aedf49cca8c27

commit r14-5930-gf31a019d1161ec78846473da743aedf49cca8c27
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date:   Fri Nov 24 06:30:28 2023 +0100

    Emit funcall external declarations only if actually used.

    There are many places in GCC where alternative local sequences are
    tried in order to determine what is the cheapest or best alternative
    to use in the current target.  When any of these sequences involve a
    libcall, the current implementation of emit_library_call_value_1
    introduce a side-effect consisting on emitting an external declaration
    for the funcall (such as __divdi3) which is thus emitted even if the
    sequence that does the libcall is not retained.

    This is problematic in targets such as BPF, because the kernel loader
    chokes on the spurious symbol __divdi3 and makes the resulting BPF
    object unloadable.  Note that BPF objects are not linked before being
    loaded.

    This patch changes asssemble_external_libcall to defer emitting
    declarations of external libcall symbols, by saving the call tree
    nodes in a temporary list pending_libcall_symbols and letting
    process_pending_assembly_externals to emit them only if they have been
    referenced.  Solution suggested and sketched by Richard Sandiford.

    Regtested in x86_64-linux-gnu.
    Tested with host x86_64-linux-gnu with target bpf-unknown-none.

    gcc/ChangeLog

            PR target/109253
            * varasm.cc (pending_libcall_symbols): New variable.
            (process_pending_assemble_externals): Process
            pending_libcall_symbols.
            (assemble_external_libcall): Defer emitting external libcall
            symbols to process_pending_assemble_externals.

    gcc/testsuite/ChangeLog

            PR target/109253
            * gcc.target/bpf/divmod-libcall-1.c: New test.
            * gcc.target/bpf/divmod-libcall-2.c: Likewise.
            * gcc.c-torture/compile/libcall-2.c: Likewise.

  parent reply	other threads:[~2023-11-28 15:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  2:27 [Bug debug/109253] New: " james.hilliard1 at gmail dot com
2023-03-23 16:08 ` [Bug target/109253] " david.faust at oracle dot com
2023-08-18 13:57 ` jemarch at gcc dot gnu.org
2023-11-28 15:23 ` cvs-commit at gcc dot gnu.org [this message]
2023-11-28 15:48 ` jemarch at gcc dot gnu.org
2023-11-29 11:41 ` shung-hsi.yu at suse dot com
2023-11-29 12:45 ` jemarch at gcc dot gnu.org
2023-11-30  1:38 ` shung-hsi.yu at suse dot com
2024-01-20 17:23 ` pinskia at gcc dot gnu.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-109253-4-ARiSoKCLDI@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).