nestlabs / nlbuild-autotools

The Nest Labs Build - GNU Autotools (nlbuild-autotools) provides a customized, turnkey build system framework, based on GNU autotools, for standalone Nest Labs (or other) software packages that need to support not only building on and targeting against standalone build host systems but also embedded target systems using GCC-based or -compatible toolchains.
Apache License 2.0
4 stars 12 forks source link

Fix autotools detection of -Wno-* compiler flags #28

Closed dismirlian closed 4 years ago

dismirlian commented 4 years ago

From gcc version 4.4, the manual states: "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 means that nlbuild-autotools won't detect invalid -Wno- warning flags. As a consequence, gcc will be passed some invalid -Wno- options.

This commit adds code that passes the positive version of the warning flag during compiler checks. For example, -Wno-some-warning will be passed as -Wsome-warning to the compiler during ./configure, so the -Wno-some-warning flag doesn't get added incorrectly to CFLAGS.

The code is almost exactly the same as the one used by gnulib.

gerickson commented 4 years ago

@dismirlian, thank you for surfacing this issue. This seems like an important item to fix; however, the newly-added code is very GCC-/clang-specific. Ideally, the client would test the non-"no-"-decorated option and then push the "no-"-decorated option to the list of flags on a successful test when the compiler is known to be GCC- or GCC-compatible (such as, clang).