Closed dismirlian closed 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).
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.