[groonga-dev, 00644] [PATCH]: Fix configure checking of -Wno-* CFLAGS and CXXFLAGS for GCC

Back to archive index

Arnaud Fontaine arnau****@nexed*****
2011年 12月 6日 (火) 14:51:07 JST


Hello,

Compiling groonga with an old version of GCC fails when checking whether
`-lm' is supported because of unsupported `-Wno-unused-but-set-variable'
(only available  from gcc 4.6.0 apparently),  which on gcc 4.3  at least
displays  a warning  for  log()  prototype and  then  aborts because  of
`-Wno-unused-but-set-variable'.


Groonga configure.ac checks whether `-Wno-*' CFLAGS are supported by gcc
(through using its own M4  macro (CHECK_CFLAG)), however it seems wrong,
and    thus    it    incorrectly   detects    whether    `-Wno-*'    are
supported. According to GCC manual[0]:

  When   an   unrecognized   warning    option   is   requested   (e.g.,
  -Wunknown-warning), GCC will emit a diagnostic stating that the option
  is not recognized.   However, if the -Wno- form is  used, the behavior
  is   slightly  different:   No   diagnostic  will   be  produced   for
  -Wno-unknown-warning unless other diagnostics are being produced. This
  allows  the use  of  new  -Wno- options  with  old  compilers, but  if
  something  goes wrong,  the compiler  will warn  that an  unrecognized
  option was used.

This  means that  if there  is  no other  warning, gcc  will not  report
`-Wno-*' warning as an unrecognized  command line option. For example if
you  try  to  compile `int  main(void)  {  return  0;  }' with  `gcc  -o
/tmp/conftest -g -O2 -Wall  -Wextra -Wno-INVALID-OPTION conftest.c', gcc
will display nothing and exit successfully.

Moreover, gcc  4.3 aborts  when there  is an  unknown command  line even
without `-Werror' (with gcc 4.6.2, only a warning is displayed).


I have  attached to  this email  a patch  for configure.ac  which checks
`-WWARNING-FLAG' (which according to GCC  manual always raises a warning
message) when  checking `-Wno-WARNING-FLAG'. I  have tested it  with GCC
4.3  and it  seems  to work  well  as `-Wno-unused-but-set-variable'  is
properly detected as  not available. Could you  please consider applying
this patch if you think it's fine?

Many thanks.

Regards,
-- 
Arnaud Fontaine

[0] http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html




groonga-dev メーリングリストの案内
Back to archive index