public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info
@ 2023-08-14  9:27 vries at gcc dot gnu.org
  2023-08-14  9:28 ` [Bug build/30751] " vries at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-14  9:27 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

            Bug ID: 30751
           Summary: [gdb/build] ODR violation for struct
                    btrace_target_info
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: build
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

When building gdb with -O2 -flto -Wall we run into:
...
/data/vries/gdb/src/gdb/nat/linux-btrace.h:84:8: warning: type 'struct
btrace_target_info' violates the C++ One Definition Rule [-Wodr]
 struct btrace_target_info
        ^
/data/vries/gdb/src/gdb/remote.c:14140:0: note: a different type is defined in
another translation unit
 struct btrace_target_info

/data/vries/gdb/src/gdb/nat/linux-btrace.h:101:5: note: the first difference of
corresponding definitions is field 'variant'
   } variant;
     ^
/data/vries/gdb/src/gdb/remote.c:14140:0: note: a type with different number of
fields is defined in another translation unit
 struct btrace_target_info
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
@ 2023-08-14  9:28 ` vries at gcc dot gnu.org
  2023-08-14  9:35 ` sam at gentoo dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-14  9:28 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |markus.t.metzger at intel dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
  2023-08-14  9:28 ` [Bug build/30751] " vries at gcc dot gnu.org
@ 2023-08-14  9:35 ` sam at gentoo dot org
  2023-08-14 12:36 ` tromey at sourceware dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: sam at gentoo dot org @ 2023-08-14  9:35 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sam at gentoo dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
  2023-08-14  9:28 ` [Bug build/30751] " vries at gcc dot gnu.org
  2023-08-14  9:35 ` sam at gentoo dot org
@ 2023-08-14 12:36 ` tromey at sourceware dot org
  2023-08-14 12:56 ` vries at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tromey at sourceware dot org @ 2023-08-14 12:36 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org
             Blocks|                            |22395


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=22395
[Bug 22395] ODR violations
-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-08-14 12:36 ` tromey at sourceware dot org
@ 2023-08-14 12:56 ` vries at gcc dot gnu.org
  2023-08-14 13:20 ` markus.t.metzger at intel dot com
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-14 12:56 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
I tried renaming "struct btrace_target_info" to "struct
remote_btrace_target_info" in remote.c, but that didn't work.  The two types
are related somehow but not the same.

I'm not sure how to fix this.

Markus, do you have any idea how this should be fixed?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-08-14 12:56 ` vries at gcc dot gnu.org
@ 2023-08-14 13:20 ` markus.t.metzger at intel dot com
  2023-08-14 18:03 ` tromey at sourceware dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: markus.t.metzger at intel dot com @ 2023-08-14 13:20 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #2 from Markus Metzger <markus.t.metzger at intel dot com> ---
(In reply to Tom de Vries from comment #1)
> I tried renaming "struct btrace_target_info" to "struct
> remote_btrace_target_info" in remote.c, but that didn't work.  The two types
> are related somehow but not the same.
> 
> I'm not sure how to fix this.
> 
> Markus, do you have any idea how this should be fixed?

The idea was that targets can attach target-specific information.  You'd get
the handle when enabling btrace on a target, then you'd pass it to other btrace
functions on that target.

One obvious fix would be to turn it into a void * and have targets cast it.  I
declared this opaque struct to avoid exactly that.

This is similar to the private data targets attach to inferiors or threads so
the same solution should work here, as well.

I can work on a patch but not right now.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-08-14 13:20 ` markus.t.metzger at intel dot com
@ 2023-08-14 18:03 ` tromey at sourceware dot org
  2023-08-18 10:07 ` markus.t.metzger at intel dot com
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tromey at sourceware dot org @ 2023-08-14 18:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Another option is to use a base class and derive the per-target classes
from it.  'inferior' does this for private data.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-08-14 18:03 ` tromey at sourceware dot org
@ 2023-08-18 10:07 ` markus.t.metzger at intel dot com
  2023-08-18 14:12 ` tromey at sourceware dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: markus.t.metzger at intel dot com @ 2023-08-18 10:07 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #4 from Markus Metzger <markus.t.metzger at intel dot com> ---
(In reply to Tom Tromey from comment #3)
> Another option is to use a base class and derive the per-target classes
> from it.  'inferior' does this for private data.

I have a patch to c++ify the btrace_target_info similar to inferior and thread
private target data, but I cannot reproduce the original issue with GCC 11.4.0
on Ubuntu 22.04.

After configuring, I build GDB with:

    $ make -sj$(nproc) CFLAGS='-O2 -flto -Wall' CXXFLAGS='-O2 -flto -Wall'

and I get several fails, e.g.

.../sim/m32r/traps.c:115:43: error: type of 'm32r2f_h_psw_get' does not match
original declaration [-Werror=lto-type-mismatch]
  115 |           m32r2f_h_bpsw_set (current_cpu, m32r2f_h_psw_get
(current_cpu));

but no -Wodr warnings nor any other warnings related to btrace.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-08-18 10:07 ` markus.t.metzger at intel dot com
@ 2023-08-18 14:12 ` tromey at sourceware dot org
  2023-08-18 14:29 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tromey at sourceware dot org @ 2023-08-18 14:12 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Markus Metzger from comment #4)

> but no -Wodr warnings nor any other warnings related to btrace.

FWIW I can definitely reproduce on x86-64 Fedora 36 using the system
gcc (12.2.1), e.g.:

../../binutils-gdb/gdb/nat/linux-btrace.h:84: warning: type 'struct
btrace_target_info' violates the C++ One Definition Rule [-Wodr]

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-08-18 14:12 ` tromey at sourceware dot org
@ 2023-08-18 14:29 ` vries at gcc dot gnu.org
  2023-08-18 15:56 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-18 14:29 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Markus Metzger from comment #4)
> but I cannot reproduce the original issue with
> GCC 11.4.0 on Ubuntu 22.04.

I'm currently trying -flto-partition=one to try to flush out more odr warnings.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2023-08-18 14:29 ` vries at gcc dot gnu.org
@ 2023-08-18 15:56 ` vries at gcc dot gnu.org
  2023-08-21  6:55 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-18 15:56 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
FWIW, if you post the patch here or on the ml, I can confirm that the warning
is gone.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2023-08-18 15:56 ` vries at gcc dot gnu.org
@ 2023-08-21  6:55 ` vries at gcc dot gnu.org
  2023-09-06  7:18 ` markus.t.metzger at intel dot com
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: vries at gcc dot gnu.org @ 2023-08-21  6:55 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Markus Metzger from comment #4)
> After configuring, I build GDB with:
> 
>     $ make -sj$(nproc) CFLAGS='-O2 -flto -Wall' CXXFLAGS='-O2 -flto -Wall'
> 
> and I get several fails, e.g.
> 
> .../sim/m32r/traps.c:115:43: error: type of 'm32r2f_h_psw_get' does not
> match original declaration [-Werror=lto-type-mismatch]
>   115 |           m32r2f_h_bpsw_set (current_cpu, m32r2f_h_psw_get
> (current_cpu));
> 
> but no -Wodr warnings nor any other warnings related to btrace.

I think what may be happening is that if you're getting an error while building
sim, gdb is not build at all, because all-gdb requires maybe-all-sim.

In that case, you could try building with --disable-sim.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2023-08-21  6:55 ` vries at gcc dot gnu.org
@ 2023-09-06  7:18 ` markus.t.metzger at intel dot com
  2023-09-11  6:18 ` cvs-commit at gcc dot gnu.org
  2023-09-11  6:55 ` vries at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: markus.t.metzger at intel dot com @ 2023-09-06  7:18 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #9 from Markus Metzger <markus.t.metzger at intel dot com> ---
(In reply to Tom de Vries from comment #8)
> (In reply to Markus Metzger from comment #4)
> > After configuring, I build GDB with:
> > 
> >     $ make -sj$(nproc) CFLAGS='-O2 -flto -Wall' CXXFLAGS='-O2 -flto -Wall'
> > 
> > and I get several fails, e.g.
> > 
> > .../sim/m32r/traps.c:115:43: error: type of 'm32r2f_h_psw_get' does not
> > match original declaration [-Werror=lto-type-mismatch]
> >   115 |           m32r2f_h_bpsw_set (current_cpu, m32r2f_h_psw_get
> > (current_cpu));
> > 
> > but no -Wodr warnings nor any other warnings related to btrace.
> 
> I think what may be happening is that if you're getting an error while
> building sim, gdb is not build at all, because all-gdb requires
> maybe-all-sim.
> 
> In that case, you could try building with --disable-sim.

After disabling sim, I get

bfd/elf32-xtensa.c:5725:41: error: 'MEM[(struct removal_by_action_entry
*)ientry_91 + -24B].offset' may be used uninitialized
[-Werror=maybe-uninitialized]
 5725 |   if (ctx->map.n_entries && (ientry - 1)->offset == r->offset)
      |                                    

but when I build with 'make -k' I can now reproduce the error and confirm that
it is fixed with my patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2023-09-06  7:18 ` markus.t.metzger at intel dot com
@ 2023-09-11  6:18 ` cvs-commit at gcc dot gnu.org
  2023-09-11  6:55 ` vries at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-11  6:18 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

--- Comment #10 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Markus Metzger <mmetzger@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cdda72c2fa1e47c566c7b5768f3831a1cc11d263

commit cdda72c2fa1e47c566c7b5768f3831a1cc11d263
Author: Markus Metzger <markus.t.metzger@intel.com>
Date:   Thu Aug 17 10:17:26 2023 +0000

    gdb: c++ify btrace_target_info

    Following the example of private_thread_info and private_inferior, turn
    struct btrace_target_info into a small class hierarchy.

    Also merge btrace_tinfo_bts with btrace_tinfo_pt and inline into
    linux_btrace_target_info.

    Fixes PR gdb/30751.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug build/30751] [gdb/build] ODR violation for struct btrace_target_info
  2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
                   ` (12 preceding siblings ...)
  2023-09-11  6:18 ` cvs-commit at gcc dot gnu.org
@ 2023-09-11  6:55 ` vries at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-11  6:55 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30751

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |14.1

--- Comment #11 from Tom de Vries <vries at gcc dot gnu.org> ---
Markus, thanks for fixing this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-09-11  6:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14  9:27 [Bug build/30751] New: [gdb/build] ODR violation for struct btrace_target_info vries at gcc dot gnu.org
2023-08-14  9:28 ` [Bug build/30751] " vries at gcc dot gnu.org
2023-08-14  9:35 ` sam at gentoo dot org
2023-08-14 12:36 ` tromey at sourceware dot org
2023-08-14 12:56 ` vries at gcc dot gnu.org
2023-08-14 13:20 ` markus.t.metzger at intel dot com
2023-08-14 18:03 ` tromey at sourceware dot org
2023-08-18 10:07 ` markus.t.metzger at intel dot com
2023-08-18 14:12 ` tromey at sourceware dot org
2023-08-18 14:29 ` vries at gcc dot gnu.org
2023-08-18 15:56 ` vries at gcc dot gnu.org
2023-08-21  6:55 ` vries at gcc dot gnu.org
2023-09-06  7:18 ` markus.t.metzger at intel dot com
2023-09-11  6:18 ` cvs-commit at gcc dot gnu.org
2023-09-11  6:55 ` vries at gcc dot gnu.org

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).