public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: niXman <i.nixman@autistici.org>
Cc: Gcc Help <gcc-help@gcc.gnu.org>
Subject: Re: Extra import symbol in debug build
Date: Thu, 16 Feb 2023 20:08:59 +0000	[thread overview]
Message-ID: <CAH6eHdSrfaQjCZ2RoenFDcNjZO8HME5fUmWUTULY1avNU0eNtw@mail.gmail.com> (raw)
In-Reply-To: <82d48ece08fbe9d59cca0cebd8d04f58@autistici.org>

[-- Attachment #1: Type: text/plain, Size: 2268 bytes --]

On Thu, 16 Feb 2023, 18:39 , <i.nixman@autistici.org> wrote:

> On 2023-02-16 15:29, Jonathan Wakely wrote:
> > On Thu, 16 Feb 2023 at 15:25, i.nixman--- via Gcc-help
> > <gcc-help@gcc.gnu.org> wrote:
> >>
> >> hello,
> >>
> >>
> >> I can successfully build the same C++ code using GCC-8.3.1 for Debug
> >> (-g
> >> -O0) and Release (-g -O2) build.
> >> I can successfully debug the Release-executable on a remote host, but
> >> I
> >> can't debug the Debug-executable on a remote host, because the
> >> Debug-executable imports an extra symbol
> >> _ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv from libstdc++ which
> >> doesn't
> >> exist.
> >
> > It should exist, it has been there since GCC
>
> hmm...
>
> I just checked the two binaries using this cmd:
>
> > readelf -sW executable | grep
> > _ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv
>
> it shows nothing for release build, and shows this for debug build:
>
> >     54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND
> > _ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv
> > 199898: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND
> > _ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv
>


This only shows that the function is inlined in the optimized build, and
not in the debug build, so the debug one has an unresolved reference to a
symbol defined in the libstdc++ dynamic library. This is completely normal.


>
> what should I do next to understand the reason?
>

Check which libstdc++.so.6 is being used by the executable when you're
debugging it and make sure it's the one from the GCC build you're compiling
with.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html#manual.intro.using.linkage.dynamic

Since the problem happens when debugging on a remote host, you need to make
sure you have the right libstdc++.so.6 when doing that debugging.


moreover, im unsure I understand the reason correctly...
>
>
>
> best!
>
>
> >
> >>
> >> but I don't want to debug libstdc++, so I think I shouldn't install
> >> additional debug version of libstdc++.
> >>
> >> it looks like a bug, or am I wrong?
> >>
> >> another my question is, what should I do to get rid of that extra
> >> symbol
> >> in Debug build?
> >>
> >>
> >>
> >>
> >> best!
> >>
> >> ps
> >> I can't update GCC nor libstdc++.
>

  reply	other threads:[~2023-02-16 20:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 15:23 i.nixman
2023-02-16 15:29 ` Jonathan Wakely
2023-02-16 18:39   ` i.nixman
2023-02-16 20:08     ` Jonathan Wakely [this message]
2023-02-17  8:51       ` i.nixman
2023-02-17 10:23         ` Xi Ruoyao
2023-02-17 11:31           ` i.nixman
2023-02-17 11:26         ` Jonathan Wakely
2023-02-17 11:32           ` i.nixman
2023-02-17 12:06             ` Jonathan Wakely
2023-02-17 14:59               ` i.nixman
2023-02-17 15:18                 ` i.nixman
2023-02-17 15:30                 ` Jonathan Wakely
2023-02-17 15:35                   ` i.nixman

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=CAH6eHdSrfaQjCZ2RoenFDcNjZO8HME5fUmWUTULY1avNU0eNtw@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=i.nixman@autistici.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).