On 09/07/2017 05:38 AM, Gao, Liming wrote:
Laszlo:
   I add -Wno-unused-const-variable option in GCC5 RELEASE option, and build 
OvmfPkg with GCC5.3. I don't meet any warning or error. Do you meet any issue? 
So, you think we can't add this option in GCC5 tool chain.


Yes, he is right, looking at:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options

When an unrecognized warning option is requested (e.g.,
-Wunknown-warning), GCC emits a diagnostic stating that the option is
not recognized. However, if the -Wno- form is used, the behavior is
slightly different: no diagnostic is 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 warns that an unrecognized option is present.

Also the older ones support it:
https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Warning-Options.html#Warning-Options
https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Warning-Options.html#Warning-Options

I verified this behavior on gcc 5.4 and on gcc version 4.4.5 (Debian 4.4.5-8)
(spun up an squeeze container, fun times)

This seems like an easy solution, hopefully also a valid one in the edk2 
context.
The gcc rationale seems good, if there is such a warning suppress it, if not we
wouldn't output any warning anyhow, so there is nothing to suppress.

The only drawback seems that if something goes wrong the user could wonder if
those "unrecognized command line options" have something to do with his problem.

It looks like this (gcc 4.4.5):

tom@olddeb:~# gcc -Wall -Wno-foo-bar test.c
test.c: In function 'main':
test.c:4: warning: unused variable 'test'
At top level:
cc1: warning: unrecognized command line option "-Wno-foo-bar"

And very similar on gcc 6:

tom@plain-stretch:~# gcc -Wall -Wno-foo-bar test.c
test.c: In function ‘main’:
test.c:7:9: warning: unused variable ‘test’ [-Wunused-variable]
     int test;
         ^~~~
test.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-foo-bar’

cheers,
Thomas


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to