Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>,
	Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org, binutils@sourceware.org
Subject: Re: [PATCH] include, opcodes: prefix REG_* macros in cris.h, nds32.h and microblaze-opcm.h
Date: Wed, 19 Aug 2026 01:03:17 -0400	[thread overview]
Message-ID: <713f31a8-b405-4cb8-9ff8-a5172f2514ad@simark.ca> (raw)
In-Reply-To: <yddik57kv23.fsf@CeBiTec.Uni-Bielefeld.DE>



On 2026-08-18 16:55, Rainer Orth wrote:
> Hi Simon,
> 
>> Bug 34537 reports:
>>
>>     When building gdb with the default configure options of gdb buildbots (which
>>     include --enable-targets=all), gdb fails to build:
>>
>>       CXX    microblaze-tdep.o
>>     In file included from ../../binutils-gdb/gdb/microblaze-tdep.c:37:
>>     ../../binutils-gdb/gdb/../opcodes/microblaze-opcm.h:101:9: error: ‘REG_PC’ redefined [-Werror]
>>       101 | #define REG_PC  32 /* PC.  */
>> 	  |         ^~~~~~
>>     In file included from /usr/include/sys/ucontext.h:14,
>> 		     from /usr/include/sys/signal.h:197,
>> 		     from /usr/include/sys/procset.h:17,
>> 		     from /usr/include/sys/wait.h:22,
>> 		     from ../gnulib/import/sys/wait.h:28,
>> 		     from /usr/include/stdlib.h:16,
>> 		     from /usr/gcc/16/include/c++/16.1.0/cstdlib:83,
>> 		     from ../../binutils-gdb/gdb/../gdbsupport/common-defs.h:107,
>> 		     from ./../../binutils-gdb/gdb/defs.h:26,
>> 		     from <command-line>:
>>     /usr/include/sys/regset.h:158:9: note: this is the location of the previous definition
>>       158 | #define REG_PC  REG_RIP
>> 	  |         ^~~~~~
>>     ../../binutils-gdb/gdb/../opcodes/microblaze-opcm.h:120:9: error: ‘REG_SP’ redefined [-Werror]
>>       120 | #define REG_SP  1 /* stack pointer.  */
>> 	  |         ^~~~~~
>>     /usr/include/sys/regset.h:160:9: note: this is the location of the previous definition
>>       160 | #define REG_SP  REG_RSP
>> 	  |         ^~~~~~
> [...]
>> Attempt to fix it by prefixing the macros with the arch name.
>>
>> I only modified the macros starting with "REG_", but there are other
>> macros with very generic names (e.g. "MAX_REG") that could be renamed
>> too (for consistency, IMO, all the macros in those files should be
>> prefixed the same way).
> 
> Thanks for doing this: I wasn't sure how best to address this.

I think it's just good practice to not use generic macro names in header
files and namespace them a bit.

>> I couldn't build-test this patch on Solaris, but it build with
>> --enable-targets=all on Linux.
> 
> I'll give it a whirl tomorrow.  Just in case, there are Solaris 11.4
> systems in the cfarm for some time now (cfarm216 for sparc and cfarm215
> for x86).

I tried building on cfarm216, just a simple

  $ ../configure --enable-targets=all && gmake

but I hit other problems than what you reported, the first of which:

      CC       igen/igen.o
    In file included from ../../binutils-gdb/sim/igen/igen.c:23:
    /usr/include/stdlib.h:307:12: error: conflicting types for ‘getopt’; have ‘int(int,  char * const*, const char *)’
      307 | extern int getopt(int, char *const *, const char *);
          |            ^~~~~~
    In file included from ../../binutils-gdb/sim/igen/igen.c:22:
    ../../binutils-gdb/sim/../include/getopt.h:115:12: note: previous declaration of ‘getopt’ with type ‘int(void)’
      115 | extern int getopt ();
          |            ^~~~~~
    In file included from ../../binutils-gdb/sim/igen/misc.h:36,
                     from ../../binutils-gdb/sim/igen/igen.c:25:
    /usr/gcc/15/lib/gcc/sparcv9-sun-solaris2.11/15.2.0/include-fixed/stdio.h:373:17: error: conflicting types for ‘getopt’; have ‘int(int,  char * const*, const char *)’
      373 | extern int      getopt(int, char *const *, const char *);
          |                 ^~~~~~
    ../../binutils-gdb/sim/../include/getopt.h:115:12: note: previous declaration of ‘getopt’ with type ‘int(void)’
      115 | extern int getopt ();
          |            ^~~~~~

Simon

  reply	other threads:[~2026-08-19  5:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 20:27 Simon Marchi
2026-08-18 20:55 ` Rainer Orth
2026-08-19  5:03   ` Simon Marchi [this message]
2026-08-19  9:11   ` Rainer Orth
2026-08-19 12:35     ` Simon Marchi
2026-08-21  8:03       ` Alan Modra
2026-08-22  5:19         ` Simon Marchi
2026-08-19 17:32 ` Hans-Peter Nilsson
2026-08-19 17:58   ` Simon Marchi
2026-08-19 19:11   ` Rainer Orth

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=713f31a8-b405-4cb8-9ff8-a5172f2514ad@simark.ca \
    --to=simark@simark.ca \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=ro@CeBiTec.Uni-Bielefeld.DE \
    --cc=simon.marchi@efficios.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