public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>,
	Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] [gdb/build] Work around cgen odr violations
Date: Mon, 21 Aug 2023 08:05:51 +0200	[thread overview]
Message-ID: <d1cfdf42-8a5e-aa7d-966b-666de51b4ed3@suse.de> (raw)
In-Reply-To: <877cpsxsiu.fsf@tromey.com>

On 8/18/23 17:46, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> When building gdb with -flto -O2, I run into:
> Tom> ...
> Tom> opcodes/mep-desc.h:250:14: warning: type 'cgen_operand_type' violates the \
> Tom>   C++ One Definition Rule [-Wodr]
> Tom>  typedef enum cgen_operand_type {
> 
> I thought... hey, the best way is probably to change cgen to emit
> different names for these things.  So I tried looking at cgen.  Then I
> found out I don't know how it can even be run at all.  Maybe it requires
> the obsolete-and-no-longer-shipped Guile 1.8 -- it definitely barfs with
> newer versions.
> 

Agreed, that's the best way. I decided though to try to achieve that by 
filing the binutils PR, to see if the binutils maintainers could help out.

> Tom> Fix this by making the conflicting type names unique, adding a target-specific
> Tom> prefix using a define before the include:
> Tom> ...
> Tom>  #define cgen_operand_type <target-name>_cgen_operand_type
> Tom>  #define cgen_hw_type  <target-name>_cgen_hw_type
> Tom>  #include "opcodes/<target-name>-desc.h"
> Tom> ...
> 
> Thanks.
> 
> Approved-By: Tom Tromey <tom@tromey.com>
> 

Thanks for the review.

After trying a bit more, with -flto-partitions=one and and various gcc 
version, I found more occurrences so I went the yy-remap.h way in a v2, 
submitted here ( 
https://sourceware.org/pipermail/gdb-patches/2023-August/201719.html ).

I also considered trying to generate a custom -desc.h using sed, which 
would be guaranteed to be complete, but I realized that would also 
require some complex custom solution to skip '#include' and function 
names, so I decided against that.

> Tom> A PR has been filed to take care of this in the opcodes dir instead (PR30758).
> 
> That was WONTFIX'd unfortunately.

Yep, unfortunate indeed.

FWIW, the rationale given there was about libopcodes being a C library, 
and I also briefly considered encapsulating the use of the *-desc.h 
files in a C file, and exporting a cgen-free interface from there, to be 
used in C++ files, but I found that there's no longer any real support 
for compiling C inside the gdb dir.

Thanks,
- Tom


  reply	other threads:[~2023-08-21  6:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  8:38 Tom de Vries
2023-08-18 15:46 ` Tom Tromey
2023-08-21  6:05   ` Tom de Vries [this message]
2023-08-22 15:54     ` Tom Tromey

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=d1cfdf42-8a5e-aa7d-966b-666de51b4ed3@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).