Bug 19587 - Some of the less-well used targets won't compile with gcc-6 due to static vars in opcode headers
Summary: Some of the less-well used targets won't compile with gcc-6 due to static var...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-09 14:43 UTC by David Howells
Modified: 2016-02-10 09:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Howells 2016-02-09 14:43:11 UTC
gcc-6 added a new warning -Wunused-const-variable that causes unused constant variables to generate a warning.  Binutils adds -Werror to the build which turns this into an error.

The opcode header files define a bunch of static constant variables, mostly arrays, that now fall foul of this.  Errors like the following are generated:

 ../../binutils-2.26/opcodes/../include/opcode/metag.h:686:30: error: 'metag_scondtab' defined but not used [-Werror=unused-const-variable]

This error can be suppressed by adding -Wno-unused-const-variable to the build. Note that whilst -Wno-error=unused-const-variable could be used with gcc-6, it cannot be used with anything older.


The following are all potential problems:

warthog>git grep "static const.*=" master -- include/opcode/*.h | sed s/master://
include/opcode/dlx.h:static const struct dlx_opcode dlx_opcodes[] =
include/opcode/hppa.h:static const char *const completer_chars = ",CcY<>?!@+&U~FfGHINnOoZMadu|/=0123%e$m}";
include/opcode/hppa.h:static const struct pa_opcode pa_opcodes[] =
include/opcode/i860.h:static const struct i860_opcode i860_opcodes[] =
include/opcode/metag.h:static const metag_reg metag_regtab[] =
include/opcode/metag.h:static const metag_reg metag_dsp_regtab[] =
include/opcode/metag.h:static const metag_reg metag_dsp_tmpl_regtab[2][56] =
include/opcode/metag.h:static const metag_acf metag_acftab[] =
include/opcode/metag.h:static const split_condition metag_scondtab[] =
include/opcode/metag.h:static const split_condition metag_dsp_scondtab[] =
include/opcode/metag.h:static const split_condition metag_fpu_scondtab[] =
include/opcode/metag.h:static const insn_template metag_optab[] =
include/opcode/mips.h:static const unsigned int mips_isa_table[] = {
include/opcode/nds32.h:static const int nds32_r45map[] =
include/opcode/nds32.h:static const int nds32_r54map[] =
include/opcode/ns32k.h:static const struct ns32k_opcode ns32k_opcodes[]=
include/opcode/score-datadep.h:static const struct insn_to_dependency insn_to_dependency_table[] =
include/opcode/score-datadep.h:static const struct data_dependency data_dependency_table[] =
include/opcode/tic30.h:static const reg tic30_regtab[] = {
include/opcode/tic30.h:static const ind_addr_type tic30_indaddr_tab[] = {
include/opcode/tic30.h:static const insn_template tic30_optab[] = {
include/opcode/tic30.h:static const insn_template *const tic30_optab_end =
include/opcode/tic30.h:static const partemplate tic30_paroptab[] = {
include/opcode/tic30.h:static const partemplate *const tic30_paroptab_end =
include/opcode/tic4x.h:static const tic4x_register_t tic3x_registers[] =
include/opcode/tic4x.h:static const tic4x_register_t tic4x_registers[] =
include/opcode/tic4x.h:static const tic4x_cond_t tic4x_conds[] =
include/opcode/tic4x.h:static const tic4x_indirect_t tic4x_indirects[] =
include/opcode/tic4x.h:static const tic4x_inst_t tic4x_insts[] =
include/opcode/visium.h:static const struct reg_entry gen_reg_table[] =
include/opcode/visium.h:static const struct reg_entry fp_reg_table[] =
Comment 1 Nick Clifton 2016-02-09 16:39:16 UTC
Hi David,

  This should now be fixed. :-)

  The liberal use of ATTRIBUTE_UNUSED appears to be the answer.

Cheers
  Nick
Comment 2 Maciej W. Rozycki 2016-02-09 17:57:47 UTC
AFAICT mips_isa_table is always used, so I'd rather keep it without
useless annotation so that if it ever becomes unused indeed an error
is spat in the face right away.
Comment 3 Nick Clifton 2016-02-10 09:42:38 UTC
Hi Maciej,

> AFAICT mips_isa_table is always used, so I'd rather keep it without
> useless annotation so that if it ever becomes unused indeed an error
> is spat in the face right away.

OK - I will not touch it. :-)

Cheers
  Nick