Re: [RFA 12/13] Add ATTRIBUTE_UNUSED to regdat.sh output

Pedro Alves
2018-07-16T17:54:57Z

On 07/16/2018 05:40 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> On 07/12/2018 09:52 PM, Tom Tromey wrote:
>>> This changes regdat.sh to emit ATTRIBUTE_UNUSED for the
>>> xmltarget_${name} variable. This seemed simpler than trying to figure
>>> out under exactly which circumstances each one was in fact used.
>
> Pedro> Can you give an example configuration where you got a warning?
>
> I only found this one via the buildbot:
>
> https://gdb-build.sergiodj.net/builders/Fedora-s390x-m64/builds/9085
>
>
> It fails like so:
>
> s390-linux32-generated.c: In function ‘void init_registers_s390_linux32()’:
> s390-linux32-generated.c:141:20: error: unused variable ‘xmltarget_s390_linux32’ [-Werror=unused-variable]
> static const char *xmltarget_s390_linux32 = "s390-linux32.xml";
> ^~~~~~~~~~~~~~~~~~~~~~
> s390-linux32v1-generated.c: In function ‘void init_registers_s390_linux32v1()’:
> s390-linux32v1-generated.c:143:20: error: unused variable ‘xmltarget_s390_linux32v1’ [-Werror=unused-variable]
> static const char *xmltarget_s390_linux32v1 = "s390-linux32v1.xml";
> ^~~~~~~~~~~~~~~~~~~~~~~~
> s390-linux32-generated.c: At global scope:
> s390-linux32-generated.c:141:20: error: ‘xmltarget_s390_linux32’ defined but not used [-Werror=unused-variable]
> s390-linux32v1-generated.c: At global scope:
> s390-linux32v1-generated.c:143:20: error: ‘xmltarget_s390_linux32v1’ defined but not used [-Werror=unused-variable]

This is building an ipa object:

s390-linux32-generated.c: In function ‘void init_registers_s390_linux32()’:
s390-linux32-generated.c:141:20: error: unused variable ‘xmltarget_s390_linux32’ [-Werror=unused-variable]
static const char *xmltarget_s390_linux32 = "s390-linux32.xml";
^~~~~~~~~~~~~~~~~~~~~~
s390-linux32v1-generated.c: In function ‘void init_registers_s390_linux32v1()’:
s390-linux32v1-generated.c:143:20: error: unused variable ‘xmltarget_s390_linux32v1’ [-Werror=unused-variable]
static const char *xmltarget_s390_linux32v1 = "s390-linux32v1.xml";
^~~~~~~~~~~~~~~~~~~~~~~~
s390-linux32-generated.c: At global scope:
s390-linux32-generated.c:141:20: error: ‘xmltarget_s390_linux32’ defined but not used [-Werror=unused-variable]
s390-linux32v1-generated.c: At global scope:
s390-linux32v1-generated.c:143:20: error: ‘xmltarget_s390_linux32v1’ defined but not used [-Werror=unused-variable]
cc1plus: all warnings being treated as errors
make[4]: *** [Makefile:576: s390-linux32-ipa.o] Error 1

The generated files look something like this (here for x86-64):

static const char *expedite_regs_amd64_linux[] = { "rbp", "rsp", "rip", 0 };
static const char *xmltarget_amd64_linux = 0;

#ifndef IN_PROCESS_AGENT
result->xmltarget = xmltarget_amd64_linux;
#endif

So the xmltarget_foo variable is defined unconditionally, but
used only when #ifndef IN_PROCESS_AGENT. So if we wrap the variable
definition in !IN_PROCESS_AGENT too, the warning should go away.

I guess that getting warning or not is most likely dependent on
GCC version.

Thanks,
Pedro Alves