bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Re: coreutils and GCC -fanalyzer
       [not found]         ` <3a074086-47f7-638f-50a8-cd7ceb46a11a@draigBrady.com>
@ 2020-05-23 16:08           ` Paul Eggert
  2020-05-23 16:22             ` Tim Rühsen
  2020-07-02  0:26             ` Paul Eggert
  0 siblings, 2 replies; 7+ messages in thread
From: Paul Eggert @ 2020-05-23 16:08 UTC (permalink / raw)
  To: Pádraig Brady; +Cc: Gnulib bugs, coreutils

On 5/23/20 8:56 AM, Pádraig Brady wrote:
> Note -Wanalyzer... flags are ineffective without -fanalyzer.
> Also -Wanalyzer-too-complex (now auto enabled by gnulib) is currently quite
> problematic with -fanalyzer.

Hmm, that's odd, since I recall getting more warnings with those flags enabled.
Perhaps not all of them are disabled when you don't use -fanalyzer? Or maybe my
memory is faulty.

Anyway, cleary the Gnulib manywarnings module needs to be fixed to do a better
job here, and this reminds me of another problem that has been bothering me for
quite some time: ./configure spends way too much time testing for individual
warnings when the manywarnings module is in use. So I am thinking of killing two
stones by doing the following.

1. Test for -fanalyzer, -Wall, -Wextra.

2. Test for flags not automatically enabled by -fanalyzer, -Wall, -Wextra but
flags that we want anyway.

3. Test for flags automatically enabled by -fanalyzer, -Wall, -Wextra that are
also flags that we don't want.

This should make 'configure' much faster. It'll also fix the issue you
mentioned. And we can make sure that -Wanalyzer-too-complex is not mentioned in
step (2) so that Gnulib won't generate it.

Ccing to bug-gnulib since this is really more of a bug-gnulib issue.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: coreutils and GCC -fanalyzer
  2020-05-23 16:08           ` coreutils and GCC -fanalyzer Paul Eggert
@ 2020-05-23 16:22             ` Tim Rühsen
  2020-07-02  0:26             ` Paul Eggert
  1 sibling, 0 replies; 7+ messages in thread
From: Tim Rühsen @ 2020-05-23 16:22 UTC (permalink / raw)
  To: Paul Eggert, Pádraig Brady; +Cc: Gnulib bugs, coreutils


[-- Attachment #1.1: Type: text/plain, Size: 1675 bytes --]

On 23.05.20 18:08, Paul Eggert wrote:
> On 5/23/20 8:56 AM, Pádraig Brady wrote:
>> Note -Wanalyzer... flags are ineffective without -fanalyzer.
>> Also -Wanalyzer-too-complex (now auto enabled by gnulib) is currently quite
>> problematic with -fanalyzer.
> 
> Hmm, that's odd, since I recall getting more warnings with those flags enabled.
> Perhaps not all of them are disabled when you don't use -fanalyzer? Or maybe my
> memory is faulty.
> 
> Anyway, cleary the Gnulib manywarnings module needs to be fixed to do a better
> job here, and this reminds me of another problem that has been bothering me for
> quite some time: ./configure spends way too much time testing for individual
> warnings when the manywarnings module is in use. So I am thinking of killing two
> stones by doing the following.
> 
> 1. Test for -fanalyzer, -Wall, -Wextra.
> 
> 2. Test for flags not automatically enabled by -fanalyzer, -Wall, -Wextra but
> flags that we want anyway.
> 
> 3. Test for flags automatically enabled by -fanalyzer, -Wall, -Wextra that are
> also flags that we don't want.
> 
> This should make 'configure' much faster. It'll also fix the issue you
> mentioned. And we can make sure that -Wanalyzer-too-complex is not mentioned in
> step (2) so that Gnulib won't generate it.

This has been done for Wget2
https://gitlab.com/gnuwget/wget2/-/blob/master/m4/wget_manywarnings.m4

Example usage at L123+:
https://gitlab.com/gnuwget/wget2/-/blob/master/configure.ac

To make it usable for other projects, it needs some merging with the
manywarnings.m4 from gnulib, IMO. I would support any volunteer as good
as i can.

Regards, Tim


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: coreutils and GCC -fanalyzer
  2020-05-23 16:08           ` coreutils and GCC -fanalyzer Paul Eggert
  2020-05-23 16:22             ` Tim Rühsen
@ 2020-07-02  0:26             ` Paul Eggert
  2020-07-10 21:21               ` Pádraig Brady
  1 sibling, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2020-07-02  0:26 UTC (permalink / raw)
  To: Pádraig Brady; +Cc: Tim Rühsen, Gnulib bugs, coreutils

[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]

On 5/23/20 9:08 AM, Paul Eggert wrote:

> So I am thinking of killing two
> stones by doing the following.
> 
> 1. Test for -fanalyzer, -Wall, -Wextra.
> 
> 2. Test for flags not automatically enabled by -fanalyzer, -Wall, -Wextra but
> flags that we want anyway.
> 
> 3. Test for flags automatically enabled by -fanalyzer, -Wall, -Wextra that are
> also flags that we don't want.

I did that in Gnulib by installing the attached patch. This could greatly
increase compile times due to the -fanalyzer option, so let's keep an eye out
for that.

On 5/23/20 9:22 AM, Tim Rühsen wrote:

> This has been done for Wget2
> https://gitlab.com/gnuwget/wget2/-/blob/master/m4/wget_manywarnings.m4
>
> Example usage at L123+:
> https://gitlab.com/gnuwget/wget2/-/blob/master/configure.ac
>
> To make it usable for other projects, it needs some merging with the
> manywarnings.m4 from gnulib, IMO. I would support any volunteer as good
> as i can.

Thanks. I think this different approach should be a win. I wanted to get the old
approach working with GCC 10.1 first though (and did that via the attached
patch) before trying out this new method, so that we can verify that switching
from old to new methods improves 'configure' performance without changing the
set of flags given to GCC. Perhaps we can wait for a bit for a shakeout period
for -fanalyzer etc., and then look into switching methods.

[-- Attachment #2: 0001-manywarnings-improve-port-to-GCC-10.1.patch --]
[-- Type: text/x-patch, Size: 24668 bytes --]

From 3831e2e9f355c557b0c0ed9712548b62feaf694f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 1 Jul 2020 17:00:51 -0700
Subject: [PATCH] manywarnings: improve port to GCC 10.1

* build-aux/gcc-warning.spec: Also list warnings that are default
or are enabled by already-given flags.  This lets us speed up
checking for attributes, and makes the generated compilation
commands shorter.  Add -Wanalyzer-too-complex (too much noise).
* m4/manywarnings.m4 (gl_MANYWARN_COMPLEMENT)
(gl_MANYWARN_ALL_GCC): Use gl_AS_VAR_APPEND to append
to shell variables that may have long values.
(gl_MANYWARN_ALL_GCC): Omit flags that are default or are
consequences of other flags, to speed up checking and
shorten commands.
---
 ChangeLog                  |  12 +++
 build-aux/gcc-warning.spec | 144 ++++++++++++++++++++++++--
 m4/manywarnings.m4         | 206 ++++++-------------------------------
 3 files changed, 181 insertions(+), 181 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index edb63b348..6115ab946 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2020-07-01  Paul Eggert  <eggert@cs.ucla.edu>
 
+	manywarnings: improve port to GCC 10.1
+	* build-aux/gcc-warning.spec: Also list warnings that are default
+	or are enabled by already-given flags.  This lets us speed up
+	checking for attributes, and makes the generated compilation
+	commands shorter.  Add -Wanalyzer-too-complex (too much noise).
+	* m4/manywarnings.m4 (gl_MANYWARN_COMPLEMENT)
+	(gl_MANYWARN_ALL_GCC): Use gl_AS_VAR_APPEND to append
+	to shell variables that may have long values.
+	(gl_MANYWARN_ALL_GCC): Omit flags that are default or are
+	consequences of other flags, to speed up checking and
+	shorten commands.
+
 	tests: pacify gcc -fanalyzer on zerosize_ptr
 	* tests/test-memcasecmp.c (main):
 	* tests/test-memchr.c (main):
diff --git a/build-aux/gcc-warning.spec b/build-aux/gcc-warning.spec
index 89a0bc734..6c0602be4 100644
--- a/build-aux/gcc-warning.spec
+++ b/build-aux/gcc-warning.spec
@@ -1,24 +1,51 @@
 # options to filter out, and why
 --all-warnings				alias for -Wall
 --extra-warnings			alias for -Wextra
+-W					alias for -Wextra
 -Wabi					this is now a no-op
 -Wabi-tag				c++
 -Wabi=					c++
+-Wabsolute-value			enabled by -Wextra
+-Waddress				enabled by -Wall
+-Waddress-of-packed-member		default
 -Waggregate-return			obsolescent
+-Waggressive-loop-optimizations		default
 -Waliasing				fortran
 -Walign-commons				fortran
 -Waligned-new=[none|global|all]		c++
--Walloc-size-larger-than=<bytes>	handled specially by gl_MANYWARN_ALL_GCC
+-Walloc-size-larger-than=<bytes>	defaults to PTRDIFF_MAX
 -Walloc-zero				Gnulib fixes this problem
 -Walloca				we like alloca in small doses
 -Walloca-larger-than=<number>		FIXME: choose something sane?
 -Wampersand				fortran
+-Wanalyzer-double-fclose		enabled by -fanalyzer
+-Wanalyzer-double-free			enabled by -fanalyzer
+-Wanalyzer-exposure-through-output-file	enabled by -fanalyzer
+-Wanalyzer-file-leak			enabled by -fanalyzer
+-Wanalyzer-free-of-non-heap		enabled by -fanalyzer
+-Wanalyzer-malloc-leak			enabled by -fanalyzer
+-Wanalyzer-null-argument		enabled by -fanalyzer
+-Wanalyzer-null-dereference		enabled by -fanalyzer
+-Wanalyzer-possible-null-argument	enabled by -fanalyzer
+-Wanalyzer-possible-null-dereference	enabled by -fanalyzer
+-Wanalyzer-stale-setjmp-buffer		implied by -fanalyzer
+-Wanalyzer-tainted-array-index		FIXME maybe? too much noise
+-Wanalyzer-too-complex			enabled by -fanalyzer
+-Wanalyzer-unsafe-call-within-signal-handler	enabled by -fanalyzer
+-Wanalyzer-use-after-free		enabled by -fanalyzer
+-Wanalyzer-use-of-pointer-in-stale-stack-frame	enabled by -fanalyzer
 -Warray-bounds				covered by -Warray-bounds=
 -Warray-bounds=<0,2>			handled specially by gl_MANYWARN_ALL_GCC
 -Warray-temporaries			fortran
 -Wassign-intercept			objc/objc++
 -Wattribute-alias			covered by -Wattribute-alias=2
 -Wattribute-alias=<0,2>			handled specially by gl_MANYWARN_ALL_GCC
+-Wattribute-warning			default
+-Wattributes				default
+-Wbool-compare				enabled by -Wall
+-Wbool-operation			enabled by -Wall
+-Wbuiltin-declaration-mismatch		default
+-Wbuiltin-macro-redefined		default
 -Wc++-compat				only useful for code meant to be compiled by a C++ compiler
 -Wc++0x-compat				c++
 -Wc++11-compat				c++
@@ -31,63 +58,120 @@
 -Wc11-c2x-compat			c compatibility
 -Wc90-c99-compat			c compatibility
 -Wc99-c11-compat			c compatibility
+-Wcannot-profile			default
+-Wcast-align				enabled by -Wcast-align=strict
+-Wcast-function-type			enabled by -Wextra
 -Wcast-qual				FIXME maybe? too much noise; encourages bad changes
 -Wcast-result				D
 -Wcatch-value				c++
 -Wcatch-value=<0,3>			c++
+-Wchar-subscripts			enabled by -Wall
 -Wcharacter-truncation			fortran
 -Wchkp					deprecated
 -Wclass-conversion			c++ and objc++
 -Wclass-memaccess			c++
+-Wclobbered				enabled by -Wextra
 -Wcomma-subscript			c++ and objc++
+-Wcomment				enabled by -Wall
+-Wcomments				alias for -Wcomment
 -Wcompare-reals				fortran
 -Wconditionally-supported		c++ and objc++
 -Wconversion				FIXME maybe? too much noise; encourages bad changes
 -Wconversion-extra			fortran
 -Wconversion-null			c++ and objc++
+-Wcoverage-mismatch			default
+-Wcpp					default
 -Wctor-dtor-privacy			c++
+-Wdangling-else				enabled by -Wparentheses
 -Wdeclaration-after-statement		FIXME: do not want.  others may
 -Wdelete-incomplete			c++ and objc++
 -Wdelete-non-virtual-dtor		c++
+-Wdeprecated				default
 -Wdeprecated-copy			c++ and objc++
 -Wdeprecated-copy-dtor			c++ and objc++
+-Wdeprecated-declarations		default
+-Wdesignated-init			default
+-Wdiscarded-array-qualifiers		default
+-Wdiscarded-qualifiers			default
 -Wdo-subscript				fortran
+-Wdiv-by-zero				default
+-Wduplicate-decl-specifier		enabled by -Wall
 -Weffc++				c++
+-Wempty-body				enabled by -Wextra
+-Wenum-compare				enabled by -Wall
+-Wenum-conversion			enabled by -Wextra
+-Wendif-labels				default
 -Werror-implicit-function-declaration	deprecated
+-Wexpansion-to-defined			enabled by -Wextra
 -Wextra-semi				c++
 -Wfloat-conversion			FIXME maybe? borderline.  some will want this
 -Wfloat-equal				FIXME maybe? borderline.  some will want this
 -Wformat				covered by -Wformat=2
+-Wformat-contains-nul			default
+-Wformat-diag				enabled by -Wformat=2
+-Wformat-extra-args			enabled by -Wformat=2
+-Wformat-nonliteral			enabled by -Wformat=2
 -Wformat-overflow<0,2>			gcc --help=warnings artifact
 -Wformat-overflow=<0,2>			handled specially by gl_MANYWARN_ALL_GCC
+-Wformat-security			enabled by -Wformat=2
 -Wformat-truncation			covered by -Wformat-truncation=2
 -Wformat-truncation=<0,2>		handled specially by gl_MANYWARN_ALL_GCC
+-Wformat-y2k				enabled by -Wformat=2
+-Wformat-zero-length			enabled by -Wformat=2
 -Wformat=<0,2>				gcc --help=warnings artifact
+-Wframe-address				enabled by -Wall
 -Wframe-larger-than=<byte-size>		FIXME: choose something sane?
+-Wfree-nonheap-object			default
 -Wfunction-elimination			fortran
+-Whsa					default
+-Wif-not-aligned			default
+-Wignored-attributes			default
+-Wignored-qualifiers			enabled by -Wextra
+-Wimplicit				enabled by -Wall
 -Wimplicit-fallthrough			covered by -Wimplicit-fallthrough=2
 -Wimplicit-fallthrough=<0,5>		handled specially by gl_MANYWARN_ALL_GCC
+-Wimplicit-function-declaration		enabled by -Wimplicit
+-Wimplicit-int				enabled by -Wimplicit
 -Wimplicit-interface			fortran
 -Wimplicit-procedure			fortran
 -Winaccessible-base			c++ and objc++
+-Wincompatible-pointer-types		default
 -Winherited-variadic-ctor		c++
 -Winit-list-lifetime			c++ and objc++
+-Wint-conversion			default
+-Wint-in-bool-context			enabled by -Wall
+-Wint-to-pointer-cast			default
 -Winteger-division			fortran
 -Wintrinsic-shadow			fortran
 -Wintrinsics-std			fortran
+-Winvalid-memory-model			default
 -Winvalid-offsetof			c++ and objc++
 -Wjump-misses-init			only useful for code meant to be compiled by a C++ compiler
 -Wlarger-than-				gcc --help=warnings artifact
 -Wlarger-than=<byte-size>		FIXME: choose something sane?
 -Wline-truncation			fortran
 -Wliteral-suffix			c++ and objc++
+-Wlogical-not-parentheses		enabled by -Wall
 -Wlong-long				obsolescent
 -Wlto-type-mismatch			c++ and objc++
+-Wmain					enabled by -Wall
+-Wmaybe-uninitialized			enabled by -Wall or -Wextra
+-Wmemset-elt-size			enabled by -Wall
+-Wmemset-transposed-args		enabled by -Wall
+-Wmisleading-indentation		enabled by -Wall
 -Wmismatched-tags			c++ and objc++
+-Wmissing-attributes			enabled by -Wall
+-Wmissing-braces			enabled by -Wall
+-Wmissing-field-initializers		enabled by -Wextra
 -Wmissing-format-attribute		obsolescent
 -Wmissing-noreturn			obsolescent
+-Wmissing-parameter-type		enabled by -Wextra
+-Wmissing-profile			default
+-Wmultichar				default
 -Wmultiple-inheritance			c++ and objc++
+-Wmultistatement-macros			enabled by -Wall
 -Wnamespaces				c++
+-Wnarrowing				enabled by -Wall
 -Wno-alloc-size-larger-than		see -Walloc-size-larger-than
 -Wno-alloca-larger-than			see -Walloca-larger-than
 -Wno-frame-larger-than			see -Wframe-larger-than
@@ -98,21 +182,35 @@
 -Wnoexcept-type				c++
 -Wnon-template-friend			c++
 -Wnon-virtual-dtor			c++
--Wnormalized				covered by -Wnormalized=
--Wnormalized=[none|id|nfc|nfkc]		handled specially by gl_MANYWARN_ALL_GCC
+-Wnonnull				enabled by -Wall or -Wformat
+-Wnonnull-compare			enabled by -Wall
+-Wnormalized				default
+-Wnormalized=[none|id|nfc|nfkc]		defaults to nfc
+-Wodr					default
 -Wold-style-cast			c++ and objc++
+-Wold-style-declaration			enabled by -Wextra
+-Woverflow				default
 -Woverloaded-virtual			c++
+-Woverride-init				enabled by -Wextra
 -Woverride-init-side-effects		c++ and objc++
 -Woverwrite-recursive			fortran
+-Wpacked-bitfield-compat		default
+-Wpacked-not-aligned			enabled by -Wall
 -Wpadded				FIXME maybe?  warns about "stabil" member in /usr/include/bits/timex.h
+-Wparentheses				enabled by -Wall
 -Wpedantic				FIXME: too strict?
 -Wpessimizing-move			c++ and objc++
 -Wplacement-new				c++
 -Wplacement-new=<0,2>			c++
 -Wpmf-conversions			c++ and objc++
+-Wpointer-compare			default
+-Wpointer-sign				enabled by -Wall
+-Wpointer-to-int-cast			default
+-Wpragmas				default
 -Wprio-ctor-dtor			c++
 -Wproperty-assign-default		objc++
 -Wprotocol				objc++
+-Wpsabi					default
 -Wreal-q-constant			fortran
 -Wrealloc-lhs				fortran
 -Wrealloc-lhs-all			fortran
@@ -121,53 +219,87 @@
 -Wredundant-tags			c++ and objc++
 -Wregister				c++ and objc++
 -Wreorder				c++ and objc++
+-Wrestrict				enabled by -Wall
+-Wreturn-local-addr			default
+-Wreturn-type				enabled by -Wall
+-Wscalar-storage-order			default
 -Wselector				objc and objc++
+-Wsequence-point			enabled by -Wall
 -Wshadow-compatible-local		covered by -Wshadow
 -Wshadow-ivar				objc
 -Wshadow-local				covered by -Wshadow
 -Wshadow=compatible-local		covered by -Wshadow
 -Wshadow=global				covered by -Wshadow
 -Wshadow=local				covered by -Wshadow
+-Wshift-count-negative			default
+-Wshift-count-overflow			default
+-Wshift-negative-value			enabled by -Wextra
 -Wshift-overflow			covered by -Wshift-overflow=2
 -Wshift-overflow=<0,2>			gcc --help=warnings artifact
 -Wsign-compare				FIXME maybe? borderline.  some will want this
 -Wsign-conversion			FIXME maybe? borderline.  some will want this
 -Wsign-promo				c++ and objc++
 -Wsized-deallocation			c++ and objc++
+-Wsizeof-array-argument			default
+-Wsizeof-pointer-div			enabled by -Wall
+-Wsizeof-pointer-memaccess		enabled by -Wall
 -Wstack-usage=<byte-size>		FIXME: choose something sane?
+-Wstrict-aliasing			enabled by -Wall
 -Wstrict-aliasing=<0,3>			FIXME: choose something sane?
 -Wstrict-null-sentinel			c++ and objc++
 -Wstrict-overflow=<0,5>			FIXME: choose something sane?
 -Wstrict-selector-match			objc and objc++
--Wstringop-overflow			covered by -Wstringop-overflow=
--Wstringop-overflow=<0,4>		handled specially by gl_MANYWARN_ALL_GCC
+-Wstring-compare			enabled by -Wextra
+-Wstringop-overflow			covered by -Wstringop-overflow=2
+-Wstringop-overflow=<0,4>		defaults to 2
+-Wstringop-truncation			default
 -Wsubobject-linkage			c++ and objc++
 -Wsuggest-override			c++ and objc++
 -Wsurprising				fortran
+-Wswitch				enabled by -Wall
+-Wswitch-bool				default
 -Wswitch-default			https://lists.gnu.org/r/bug-gnulib/2018-05/msg00179.html
 -Wswitch-enum				FIXME maybe? borderline.  some will want this
+-Wswitch-outside-range			default
+-Wswitch-unreachable			default
 -Wsynth					deprecated
 -Wtabs					fortran
 -Wtarget-lifetime			fortran
+-Wtautological-compare			enabled by -Wall
 -Wtemplates				c++ and objc++
 -Wterminate				c++ and objc++
 -Wtraditional				obsolescent
 -Wtraditional-conversion		obsolescent
+-Wtrigraphs				enabled by -Wall
+-Wtype-limits				enabled by -Wextra
 -Wundeclared-selector			objc and objc++
 -Wundef					FIXME maybe? too many false positives
 -Wundefined-do-loop			fortran
 -Wunderflow				fortran
 -Wunreachable-code			obsolescent no-op
 -Wunsuffixed-float-constants		triggers warning in gnulib's timespec.h
--Wunused-const-variable			covered by -Wunusec-const-variable=2
+-Wunused				enabled by -Wall
+-Wunused-but-set-parameter		enabled by -Wunused
+-Wunused-but-set-variable		enabled by -Wunused
+-Wunused-const-variable			covered by -Wunused-const-variable=2
 -Wunused-const-variable=<0,2>		gcc --help=warnings artifact
 -Wunused-dummy-argument			fortran
+-Wunused-function			enabled by -Wunused
+-Wunused-label				enabled by -Wunused
+-Wunused-local-typedefs			enabled by -Wunused
+-Wunused-parameter			enabled by -Wunused
+-Wunused-result				enabled by -Wunused
+-Wunused-value				enabled by -Wunused
+-Wunused-variable			enabled by -Wunused
 -Wuse-without-only			fortran
 -Wuseless-cast				c++ and objc++
+-Wvarargs				default
 -Wvirtual-inheritance			c++
 -Wvirtual-move-assign			c++
 -Wvla-larger-than=<number>		handled specially by gl_MANYWARN_ALL_GCC
 -Wvolatile				c++ and objc++
+-Wvolatile-register-var			enabled by -Wall
 -Wzero-as-null-pointer-constant		c++ and objc++
+-Wzero-length-bounds			enabled by -Wall
 -Wzerotrip				fortran
 -frequire-return-statement		go
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 719bafb29..d18da048d 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,4 +1,4 @@
-# manywarnings.m4 serial 19
+# manywarnings.m4 serial 20
 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,7 +21,7 @@ AC_DEFUN([gl_MANYWARN_COMPLEMENT],
       *" $gl_warn_item "*)
         ;;
       *)
-        gl_warn_set="$gl_warn_set $gl_warn_item"
+        gl_AS_VAR_APPEND([gl_warn_set], [" $gl_warn_item"])
         ;;
     esac
   done
@@ -49,12 +49,12 @@ m4_defun([gl_MANYWARN_ALL_GCC(C)],
   AC_REQUIRE([AC_PROG_CC])
   if test -n "$GCC"; then
 
-    dnl Check if -W -Werror -Wno-missing-field-initializers is supported
+    dnl Check if -Wextra -Werror -Wno-missing-field-initializers is supported
     dnl with the current $CC $CFLAGS $CPPFLAGS.
     AC_CACHE_CHECK([whether -Wno-missing-field-initializers is supported],
       [gl_cv_cc_nomfi_supported],
       [gl_save_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS -W -Werror -Wno-missing-field-initializers"
+       CFLAGS="$CFLAGS -Wextra -Werror -Wno-missing-field-initializers"
        AC_COMPILE_IFELSE(
          [AC_LANG_PROGRAM([[]], [[]])],
          [gl_cv_cc_nomfi_supported=yes],
@@ -68,7 +68,7 @@ m4_defun([gl_MANYWARN_ALL_GCC(C)],
       AC_CACHE_CHECK([whether -Wno-missing-field-initializers is needed],
         [gl_cv_cc_nomfi_needed],
         [gl_save_CFLAGS="$CFLAGS"
-         CFLAGS="$CFLAGS -W -Werror"
+         CFLAGS="$CFLAGS -Wextra -Werror"
          AC_COMPILE_IFELSE(
            [AC_LANG_PROGRAM(
               [[int f (void)
@@ -105,153 +105,41 @@ m4_defun([gl_MANYWARN_ALL_GCC(C)],
   # To compare this list to your installed GCC's, run this Bash command:
   #
   # comm -3 \
-  #  <((sed -n 's/^  *\(-[^ 0-9][^ ]*\) .*/\1/p' manywarnings.m4; \
+  #  <((sed -n 's/^  *\(-[^ 0-9][^ ]*\).*/\1/p' manywarnings.m4; \
   #     awk '/^[^#]/ {print $1}' ../build-aux/gcc-warning.spec) | sort) \
   #  <(LC_ALL=C gcc --help=warnings | sed -n 's/^  \(-[^ ]*\) .*/\1/p' | sort)
 
-  gl_manywarn_set=
-  for gl_manywarn_item in -fno-common \
-    -W \
-    -Wabsolute-value \
-    -Waddress \
-    -Waddress-of-packed-member \
-    -Waggressive-loop-optimizations \
+  $1=
+  for gl_manywarn_item in -fanalyzer -fno-common \
     -Wall \
-    -Wanalyzer-double-fclose \
-    -Wanalyzer-double-free \
-    -Wanalyzer-exposure-through-output-file \
-    -Wanalyzer-file-leak \
-    -Wanalyzer-free-of-non-heap \
-    -Wanalyzer-malloc-leak \
-    -Wanalyzer-null-argument \
-    -Wanalyzer-null-dereference \
-    -Wanalyzer-possible-null-argument \
-    -Wanalyzer-possible-null-dereference \
-    -Wanalyzer-stale-setjmp-buffer \
-    -Wanalyzer-tainted-array-index \
-    -Wanalyzer-too-complex \
-    -Wanalyzer-unsafe-call-within-signal-handler \
-    -Wanalyzer-use-after-free \
-    -Wanalyzer-use-of-pointer-in-stale-stack-frame \
     -Warith-conversion \
-    -Wattribute-warning \
-    -Wattributes \
     -Wbad-function-cast \
-    -Wbool-compare \
-    -Wbool-operation \
-    -Wbuiltin-declaration-mismatch \
-    -Wbuiltin-macro-redefined \
-    -Wcannot-profile \
-    -Wcast-align \
     -Wcast-align=strict \
-    -Wcast-function-type \
-    -Wchar-subscripts \
-    -Wclobbered \
-    -Wcomment \
-    -Wcomments \
-    -Wcoverage-mismatch \
-    -Wcpp \
-    -Wdangling-else \
     -Wdate-time \
-    -Wdeprecated \
-    -Wdeprecated-declarations \
-    -Wdesignated-init \
     -Wdisabled-optimization \
-    -Wdiscarded-array-qualifiers \
-    -Wdiscarded-qualifiers \
-    -Wdiv-by-zero \
     -Wdouble-promotion \
     -Wduplicated-branches \
     -Wduplicated-cond \
-    -Wduplicate-decl-specifier \
-    -Wempty-body \
-    -Wendif-labels \
-    -Wenum-compare \
-    -Wenum-conversion \
-    -Wexpansion-to-defined \
     -Wextra \
-    -Wformat-contains-nul \
-    -Wformat-diag \
-    -Wformat-extra-args \
-    -Wformat-nonliteral \
-    -Wformat-security \
     -Wformat-signedness \
-    -Wformat-y2k \
-    -Wformat-zero-length \
-    -Wframe-address \
-    -Wfree-nonheap-object \
-    -Whsa \
-    -Wif-not-aligned \
-    -Wignored-attributes \
-    -Wignored-qualifiers \
-    -Wimplicit \
-    -Wimplicit-function-declaration \
-    -Wimplicit-int \
-    -Wincompatible-pointer-types \
     -Winit-self \
     -Winline \
-    -Wint-conversion \
-    -Wint-in-bool-context \
-    -Wint-to-pointer-cast \
-    -Winvalid-memory-model \
     -Winvalid-pch \
-    -Wlogical-not-parentheses \
     -Wlogical-op \
-    -Wmain \
-    -Wmaybe-uninitialized \
-    -Wmemset-elt-size \
-    -Wmemset-transposed-args \
-    -Wmisleading-indentation \
-    -Wmissing-attributes \
-    -Wmissing-braces \
     -Wmissing-declarations \
-    -Wmissing-field-initializers \
     -Wmissing-include-dirs \
-    -Wmissing-parameter-type \
-    -Wmissing-profile \
     -Wmissing-prototypes \
-    -Wmultichar \
-    -Wmultistatement-macros \
-    -Wnarrowing \
     -Wnested-externs \
-    -Wnonnull \
-    -Wnonnull-compare \
     -Wnull-dereference \
-    -Wodr \
-    -Wold-style-declaration \
     -Wold-style-definition \
     -Wopenmp-simd \
-    -Woverflow \
     -Woverlength-strings \
-    -Woverride-init \
     -Wpacked \
-    -Wpacked-bitfield-compat \
-    -Wpacked-not-aligned \
-    -Wparentheses \
     -Wpointer-arith \
-    -Wpointer-compare \
-    -Wpointer-sign \
-    -Wpointer-to-int-cast \
-    -Wpragmas \
-    -Wpsabi \
-    -Wrestrict \
-    -Wreturn-local-addr \
-    -Wreturn-type \
-    -Wscalar-storage-order \
-    -Wsequence-point \
     -Wshadow \
-    -Wshift-count-negative \
-    -Wshift-count-overflow \
-    -Wshift-negative-value \
-    -Wsizeof-array-argument \
-    -Wsizeof-pointer-div \
-    -Wsizeof-pointer-memaccess \
     -Wstack-protector \
-    -Wstrict-aliasing \
     -Wstrict-overflow \
     -Wstrict-prototypes \
-    -Wstring-compare \
-    -Wstringop-truncation \
     -Wsuggest-attribute=cold \
     -Wsuggest-attribute=const \
     -Wsuggest-attribute=format \
@@ -260,95 +148,63 @@ m4_defun([gl_MANYWARN_ALL_GCC(C)],
     -Wsuggest-attribute=pure \
     -Wsuggest-final-methods \
     -Wsuggest-final-types \
-    -Wswitch \
-    -Wswitch-bool \
-    -Wswitch-outside-range \
-    -Wswitch-unreachable \
     -Wsync-nand \
     -Wsystem-headers \
-    -Wtautological-compare \
     -Wtrampolines \
-    -Wtrigraphs \
-    -Wtype-limits \
     -Wuninitialized \
     -Wunknown-pragmas \
     -Wunsafe-loop-optimizations \
-    -Wunused \
-    -Wunused-but-set-parameter \
-    -Wunused-but-set-variable \
-    -Wunused-function \
-    -Wunused-label \
-    -Wunused-local-typedefs \
     -Wunused-macros \
-    -Wunused-parameter \
-    -Wunused-result \
-    -Wunused-value \
-    -Wunused-variable \
-    -Wvarargs \
     -Wvariadic-macros \
     -Wvector-operation-performance \
     -Wvla \
-    -Wvolatile-register-var \
     -Wwrite-strings \
-    -Wzero-length-bounds \
     \
     ; do
-    gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+    gl_AS_VAR_APPEND([$1], [" $gl_manywarn_item"])
   done
 
   # gcc --help=warnings outputs an unusual form for these options; list
   # them here so that the above 'comm' command doesn't report a false match.
-  # Would prefer "min (PTRDIFF_MAX, SIZE_MAX)", but it must be a literal.
-  # Also, AC_COMPUTE_INT requires it to fit in a long; it is 2**63 on
-  # the only platforms where it does not fit in a long, so make that
-  # a special case.
-  AC_MSG_CHECKING([max safe object size])
-  AC_COMPUTE_INT([gl_alloc_max],
-    [LONG_MAX < (PTRDIFF_MAX < (size_t) -1 ? PTRDIFF_MAX : (size_t) -1)
-     ? -1
-     : PTRDIFF_MAX < (size_t) -1 ? (long) PTRDIFF_MAX : (long) (size_t) -1],
-    [[#include <limits.h>
-      #include <stddef.h>
-      #include <stdint.h>
-    ]],
-    [gl_alloc_max=2147483647])
-  case $gl_alloc_max in
-    -1) gl_alloc_max=9223372036854775807;;
-  esac
-  AC_MSG_RESULT([$gl_alloc_max])
-  gl_manywarn_set="$gl_manywarn_set -Walloc-size-larger-than=$gl_alloc_max"
-  gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
-  gl_manywarn_set="$gl_manywarn_set -Wattribute-alias=2"
-  gl_manywarn_set="$gl_manywarn_set -Wformat-overflow=2"
-  gl_manywarn_set="$gl_manywarn_set -Wformat-truncation=2"
-  gl_manywarn_set="$gl_manywarn_set -Wimplicit-fallthrough=5"
-  gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
-  gl_manywarn_set="$gl_manywarn_set -Wshift-overflow=2"
-  gl_manywarn_set="$gl_manywarn_set -Wstringop-overflow=2"
-  gl_manywarn_set="$gl_manywarn_set -Wunused-const-variable=2"
-  gl_manywarn_set="$gl_manywarn_set -Wvla-larger-than=4031"
+  gl_AS_VAR_APPEND([$1], [' -Warray-bounds=2'])
+  gl_AS_VAR_APPEND([$1], [' -Wattribute-alias=2'])
+  gl_AS_VAR_APPEND([$1], [' -Wformat-overflow=2'])
+  gl_AS_VAR_APPEND([$1], [' -Wformat=2'])
+  gl_AS_VAR_APPEND([$1], [' -Wformat-truncation=2'])
+  gl_AS_VAR_APPEND([$1], [' -Wimplicit-fallthrough=5'])
+  gl_AS_VAR_APPEND([$1], [' -Wshift-overflow=2'])
+  gl_AS_VAR_APPEND([$1], [' -Wunused-const-variable=2'])
+  gl_AS_VAR_APPEND([$1], [' -Wvla-larger-than=4031'])
 
   # These are needed for older GCC versions.
   if test -n "$GCC"; then
     case `($CC --version) 2>/dev/null` in
       'gcc (GCC) '[[0-3]].* | \
       'gcc (GCC) '4.[[0-7]].*)
-        gl_manywarn_set="$gl_manywarn_set -fdiagnostics-show-option"
-        gl_manywarn_set="$gl_manywarn_set -funit-at-a-time"
+        gl_AS_VAR_APPEND([$1], [' -fdiagnostics-show-option'])
+        gl_AS_VAR_APPEND([$1], [' -funit-at-a-time'])
           ;;
     esac
   fi
 
   # Disable specific options as needed.
   if test "$gl_cv_cc_nomfi_needed" = yes; then
-    gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
+    gl_AS_VAR_APPEND([$1], [' -Wno-missing-field-initializers'])
   fi
 
   if test "$gl_cv_cc_uninitialized_supported" = no; then
-    gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
+    gl_AS_VAR_APPEND([$1], [' -Wno-uninitialized'])
   fi
 
-  $1=$gl_manywarn_set
+  # Some warnings have too many false alarms in GCC 10.1.
+  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93695
+  gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-double-free'])
+  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94458
+  gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-malloc-leak'])
+  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94851
+  gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-null-dereference'])
+  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95758
+  gl_AS_VAR_APPEND([$1], [' -Wno-analyzer-use-after-free'])
 
   AC_LANG_POP([C])
 ])
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: coreutils and GCC -fanalyzer
  2020-07-02  0:26             ` Paul Eggert
@ 2020-07-10 21:21               ` Pádraig Brady
  2020-07-10 21:37                 ` Jeffrey Walton
  2020-07-11  0:58                 ` Paul Eggert
  0 siblings, 2 replies; 7+ messages in thread
From: Pádraig Brady @ 2020-07-10 21:21 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Gnulib bugs, coreutils

On 02/07/2020 01:26, Paul Eggert wrote:
> On 5/23/20 9:08 AM, Paul Eggert wrote:
> 
>> So I am thinking of killing two
>> stones by doing the following.
>>
>> 1. Test for -fanalyzer, -Wall, -Wextra.
>>
>> 2. Test for flags not automatically enabled by -fanalyzer, -Wall, -Wextra but
>> flags that we want anyway.
>>
>> 3. Test for flags automatically enabled by -fanalyzer, -Wall, -Wextra that are
>> also flags that we don't want.
> 
> I did that in Gnulib by installing the attached patch. This could greatly
> increase compile times due to the -fanalyzer option, so let's keep an eye out
> for that.

s/could/does/.
compile time has gone from seconds to minutes for coreutils at least.

I'd be inclined to not enable -fanalyzer by default.
At least not until it matures more.
-fanalyzer didn't find any actual issues in coreutils,
and currently bails on most files (after taking lots of time about it),
as indicated with the -Wanalyzer-too-complex option.

cheers,
Pádraig


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: coreutils and GCC -fanalyzer
  2020-07-10 21:21               ` Pádraig Brady
@ 2020-07-10 21:37                 ` Jeffrey Walton
  2020-07-11  0:58                 ` Paul Eggert
  1 sibling, 0 replies; 7+ messages in thread
From: Jeffrey Walton @ 2020-07-10 21:37 UTC (permalink / raw)
  To: bug-gnulib, coreutils

On Fri, Jul 10, 2020 at 5:22 PM Pádraig Brady <P@draigbrady.com> wrote:
>
> On 02/07/2020 01:26, Paul Eggert wrote:
> > On 5/23/20 9:08 AM, Paul Eggert wrote:
> >
> >> So I am thinking of killing two
> >> stones by doing the following.
> >>
> >> 1. Test for -fanalyzer, -Wall, -Wextra.
> >>
> >> 2. Test for flags not automatically enabled by -fanalyzer, -Wall, -Wextra but
> >> flags that we want anyway.
> >>
> >> 3. Test for flags automatically enabled by -fanalyzer, -Wall, -Wextra that are
> >> also flags that we don't want.
> >
> > I did that in Gnulib by installing the attached patch. This could greatly
> > increase compile times due to the -fanalyzer option, so let's keep an eye out
> > for that.
>
> s/could/does/.
> compile time has gone from seconds to minutes for coreutils at least.
>
> I'd be inclined to not enable -fanalyzer by default.
> At least not until it matures more.
> -fanalyzer didn't find any actual issues in coreutils,
> and currently bails on most files (after taking lots of time about it),
> as indicated with the -Wanalyzer-too-complex option.

Just my 2 cents, but leave analyzer options to testing and QA folks.
Make the option available for convenience, but leave it off by
default.

The testers and QA folks will perform the enhanced testing on
occasion, like during a CI build or manually before a release. The
remainder of the time, regular users get a regular build.

Jeff


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: coreutils and GCC -fanalyzer
  2020-07-10 21:21               ` Pádraig Brady
  2020-07-10 21:37                 ` Jeffrey Walton
@ 2020-07-11  0:58                 ` Paul Eggert
  2020-07-11 14:26                   ` Pádraig Brady
  1 sibling, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2020-07-11  0:58 UTC (permalink / raw)
  To: Pádraig Brady; +Cc: Gnulib bugs, coreutils

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

On 7/10/20 2:21 PM, Pádraig Brady wrote:
> 
> I'd be inclined to not enable -fanalyzer by default.
> At least not until it matures more.
> -fanalyzer didn't find any actual issues in coreutils,

Yes, the only bug I found related to coreutils:

https://gmplib.org/list-archives/gmp-bugs/2020-July/004844.html

is a bug in library code that coreutils never triggers.

> I'd be inclined to not enable -fanalyzer by default.

I installed the attached patch into coreutils; will that do? The basic idea is 
that you get -fanalyzer only if you configure with the new 
--enable-gcc-warnings=expensive option.

[-- Attachment #2: 0001-build-be-less-aggressive-about-fanalyzer.patch --]
[-- Type: text/x-patch, Size: 2658 bytes --]

From 6b6f0f54c0eca06345b7741e5fd37b4500675286 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 10 Jul 2020 15:54:51 -0700
Subject: [PATCH] build: be less aggressive about -fanalyzer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* configure.ac: Don’t enable -fanalyzer unless configured with the
new --enable-gcc-warnings=expensive option.  See thread at:
https://lists.gnu.org/r/coreutils/2020-07/msg00011.html
---
 configure.ac | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0afbff627..69d4e7d7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,10 +89,14 @@ AC_DEFUN([gl_GCC_VERSION_IFELSE],
 )
 
 AC_ARG_ENABLE([gcc-warnings],
-  [AS_HELP_STRING([--enable-gcc-warnings],
-     [turn on many GCC warnings (for developers; best with GNU make)])],
+  [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
+    [control generation of GCC warnings.  The TYPE 'no' disables
+     warnings (default for non-developer builds); 'yes' generates
+     cheap warnings if available (default for developer builds);
+     'expensive' in addition generates expensive-to-compute warnings
+     if available.])],
   [case $enableval in
-     yes|no) ;;
+     no|yes|expensive) ;;
      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
    esac
    gl_gcc_warnings=$enableval],
@@ -108,12 +112,18 @@ AC_ARG_ENABLE([gcc-warnings],
                           && gl_gcc_warnings=yes])]
 )
 
-if test "$gl_gcc_warnings" = yes; then
+if test $gl_gcc_warnings != no; then
   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
   AC_SUBST([WERROR_CFLAGS])
 
-  nw=
+  ew=
+  AS_IF([test $gl_gcc_warnings != expensive],
+    [# -fanalyzer and related options slow GCC considerably.
+     ew="$ew -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
+     ew="$ew -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"])
+
   # This, $nw, is the list of warnings we disable.
+  nw=$ew
   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
   nw="$nw -Waggregate-return"       # anachronistic
   nw="$nw -Wlong-long"              # C90 is anachronistic (lib/gethrxtime.h)
@@ -190,7 +200,7 @@ if test "$gl_gcc_warnings" = yes; then
 
   # We use a slightly smaller set of warning options for lib/.
   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
-  nw=
+  nw=$ew
   nw="$nw -Wduplicated-branches"    # Too many false alarms
   nw="$nw -Wformat-truncation=2"
   nw="$nw -Wstrict-overflow"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: coreutils and GCC -fanalyzer
  2020-07-11  0:58                 ` Paul Eggert
@ 2020-07-11 14:26                   ` Pádraig Brady
  0 siblings, 0 replies; 7+ messages in thread
From: Pádraig Brady @ 2020-07-11 14:26 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Gnulib bugs, coreutils

On 11/07/2020 01:58, Paul Eggert wrote:
> On 7/10/20 2:21 PM, Pádraig Brady wrote:
>>
>> I'd be inclined to not enable -fanalyzer by default.
>> At least not until it matures more.
>> -fanalyzer didn't find any actual issues in coreutils,
> 
> Yes, the only bug I found related to coreutils:
> 
> https://gmplib.org/list-archives/gmp-bugs/2020-July/004844.html
> 
> is a bug in library code that coreutils never triggers.
> 
>> I'd be inclined to not enable -fanalyzer by default.
> 
> I installed the attached patch into coreutils; will that do? The basic idea is
> that you get -fanalyzer only if you configure with the new
> --enable-gcc-warnings=expensive option.

That's better, for coreutils at least.
It's good that you included all fanalyzer related options set by gnulib,
as that allows projects to more easily control those themselves.

thanks!
Pádraig


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-11 14:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <edfafbde-9e71-f8a9-600d-23cdfaee52a5@cs.ucla.edu>
     [not found] ` <77400f8a-59ca-6d02-e5b1-e01ba0619237@draigBrady.com>
     [not found]   ` <a554e905-fa73-6618-90d7-ae3cb136e19d@cs.ucla.edu>
     [not found]     ` <e551aac0-e2fe-920a-d0ea-ca80695283d0@draigBrady.com>
     [not found]       ` <4aa67590-a0c3-603d-d2b1-f0751a28df29@cs.ucla.edu>
     [not found]         ` <3a074086-47f7-638f-50a8-cd7ceb46a11a@draigBrady.com>
2020-05-23 16:08           ` coreutils and GCC -fanalyzer Paul Eggert
2020-05-23 16:22             ` Tim Rühsen
2020-07-02  0:26             ` Paul Eggert
2020-07-10 21:21               ` Pádraig Brady
2020-07-10 21:37                 ` Jeffrey Walton
2020-07-11  0:58                 ` Paul Eggert
2020-07-11 14:26                   ` Pádraig Brady

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).