[PATCH] include, opcodes: prefix REG_* macros in cris.h, nds32.h and microblaze-opcm.h

Simon Marchi simark@simark.ca
Wed Aug 19 17:58:15 GMT 2026


On 8/19/26 1:32 PM, Hans-Peter Nilsson wrote:
> On Tue, 18 Aug 2026, Simon Marchi wrote:
> 
>> 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:
> 
>>       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.  */
>> 	  |         ^~~~~~
> 
>> Attempt to fix it by prefixing the macros with the arch name.
> 
> An alternative, less intrusive method, would be to #undef those 
> macros in a suitable gdb toplevel file, maybe defs.h, after 
> including cstdlib but before including binutils/gdb files.  The 
> error is clearly on the Solaris side, for namespace intrusion 
> and pollution.

I think that would be more obscure and less maintainable.

> Having said and suggested that, if that won't work, the CRIS 
> bits are fine.
>>
>> 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).
>>
>> I couldn't build-test this patch on Solaris, but it build with
>> --enable-targets=all on Linux.
> 
> How would you tell this attempt is complete?
> (Maybe someone's doing evil ungreppable things like REG_ ## SP. ;-)
> Are there not Solaris machines in the gcc build farm?

I rely on Rainer to tell me :).

As mentioned here:

https://inbox.sourceware.org/gdb-patches/alpine.BSF.2.20.16.2608191324250.89035@arjuna.pair.com/T/#mcffe63661ff054a3384964589356e90d21eebdac

I did try to build on Solaris, but I hit some other separate build
errors.

Simon


More information about the Binutils mailing list