Re: Turn on compiler warnings by default for AC_PROG_CC, AC_PROG_CXX & AC_PROG_FC

Eric Blake <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Organization Red Hat, Inc.
Message-ID <[email protected]>
On 02/10/2014 03:28 PM, David A. Wheeler wrote:

>  checking if -Wno-such-option can be added to CFLAGS... yes
> ...
> 
> That looks perfect, it's certainly clear what's going on.

> 
> I'm a little annoyed by the second warning, though, the one that says:
>   cc1: warning: unrecognized command line option "-Wno-such-option" [enabled by default]
> I presume this happens because there's no error return
> given an unrecognized command line option.  That's not a *killer*, but
> that would be annoying since it'd repeat in every compile.

Ah, but it IS a killer to anyone compiling with -Werror.

But gnulib's warnings module has already solved that issue - it is
possible to force gcc into not accepting a -Wno-such-option command line
argument.

You really want to borrow some of the ideas from here:
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=m4/warnings.m4

gl_COMPILER_OPTION_IF sounds like your proposed AC_APPEND_FLAG_IFVALID,
with the added benefit of converting -Wno- into -W when probing (gcc
rejects the positive form, and is only silent about the -Wno- form when
no other warnings occur, so you must force gcc into confessing unknown
warnings by using the positive form).

Furthermore, that file also has gl_UNKNOWN_WARNINGS_ARE_ERRORS, which
has various ways of making clang confess which warnings it understands
(clang and gcc have different opinions on what to do with unknown
warnings, and when probing for what warnings you can safely add to
CFLAGS, you REALLY want the probe to reject unknown warnings).

Overall, I think migrating the core functionality of gnulib's warnings
module into autoconf does sound useful, so I'm pleased that you are
pursuing this, and I will answer your off-list query about copyright
assignment.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc (application/pgp-signature, 604 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJS+Vn7AAoJEKeha0olJ0Nq0OcH/RF1lC8I97YC3xMCJbDO/KoO
60Rt7uUYY2U4fdQ+k4VT6A4/U4FP4GPbEDIoaMa0p8qlwVNv2FpvqOhL+TE5esZq
1awf6P/uYfOFUl0RM0iAtve12xhYhlvN8cg9nSnBYV+lVoWjmFkEB54grSfSnOkC
6oNXFDDOkyAWSikBMYSZTjVRrBuQdy1mmjd2ABoVrx5sa66gk/fh2GmSy7wFwGSt
mPIlkL5mWXSNkyWdLdPqwVJZg95J+d3ZX6+OoE8bxPOHPH9AkXNVQp/DAFg1JCDY
EK9OwT+js0U52dBPLNxc/gcY8bho21xF9Fqxl3FrKouIEYo86pU4eIT39LgYDj8=
=YOmq
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.