public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't'
@ 2018-08-27 17:29 Alexander Monakov
  2018-08-27 18:20 ` [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3 Alexander Monakov
  2018-08-30 12:12 ` [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't' Richard Sandiford
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Monakov @ 2018-08-27 17:29 UTC (permalink / raw)
  To: gcc-patches

Hello,

If patch 2/2 is approved, I'd like to apply this alongside with that.

Use positive form ("suppress") rather than negative ("don't") to explain
the option, because using the option results in passing -Wno-format 
rather than not passing -Wformat.  I felt confused when trying to follow
the logic of the option, and this change would clarify things for me.

Unpaired apostrophe in "don't" also happens to break syntax matching in Vim.

	* configure.ac (build-format-warnings): Reword help text.
	* configure: Regenerate.

diff --git a/gcc/configure b/gcc/configure
index b7a8e364377..be6f0be6ba2 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -1603,7 +1603,7 @@ Optional Features:
                           texinfo bison or flex
   --disable-largefile     omit support for large files
   --disable-build-format-warnings
-                          don't use -Wformat while building GCC
+                          suppress -Wformat while building GCC
   --enable-werror-always  enable -Werror despite compiler version
   --enable-checking[=LIST]
                           enable expensive run-time checks. With LIST, enable
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 65f9c92ec85..a693bfa0e31 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -478,7 +478,7 @@ AC_SUBST(aliasing_flags)
 
 # In stage 1, disable -Wformat warnings from old GCCs about new % codes
 AC_ARG_ENABLE(build-format-warnings,
-  AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
+  AS_HELP_STRING([--disable-build-format-warnings],[suppress -Wformat while building GCC]),
   [],[enable_build_format_warnings=yes])
 AS_IF([test $enable_build_format_warnings = no],
       [wf_opt=-Wno-format],[wf_opt=])
-- 
2.13.3

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

* [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3
  2018-08-27 17:29 [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't' Alexander Monakov
@ 2018-08-27 18:20 ` Alexander Monakov
  2018-08-27 18:56   ` Joseph Myers
  2018-08-27 19:05   ` Jeff Law
  2018-08-30 12:12 ` [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't' Richard Sandiford
  1 sibling, 2 replies; 5+ messages in thread
From: Alexander Monakov @ 2018-08-27 18:20 UTC (permalink / raw)
  To: gcc-patches

Currently bootstrap stages 2 and 3 use the same warning options, but that is
redundant: if any warnings are generated, they will be present in stage 2 (and
stop bootstrap).  By not enabling any warnings for stage 3, we would get
simple automated checking that warnings do not affect code generation.

I've checked GCC 5 managed to bootstrap in this manner, but starting from
GCC 6 we've gotten less lucky.  There's a bunch of options already confirmed
to affect code generation:

-Wnonnull/-Wrestrict/-Wformat/-Wsuggest-attribute=format (PR 86567)
-Wimplicit-fallthrough (PR 86575)
-Wsign-compare (PR 86586)

Individual bugs are linked from PR 86518.

The list is likely incomplete as usage of maybe_constant_value conditional on
some warning being enabled is a common source of divergence in the C++ frontend
(maybe_constant_value keeps a cache, so with warnings trees in the cache
may get lower uids than they otherwise would).

I imagine a possible solution to that would be making maybe_constant_value
not pollute its cache under warning context, but no idea how naive that is.

In the hope of refreshing the discussion I'm pasting a patch that implements
configure code to add the bootstrap check. In my testing only -Wsign-compare
makes bootstrap diverge.


	* Makefile.tpl (STAGE3_CONFIGURE_FLAGS): Pass --disable-build-warnings.
	* gcc/configure.ac (--disable-build-warnings): New option.
	* Makefile.in: Regenerate.
	* gcc/configure: Regenerate.

diff --git a/Makefile.tpl b/Makefile.tpl
index 447d324595f..d3ee9e07397 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -452,6 +452,8 @@ STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
 	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)" \
 	  --disable-build-format-warnings
 
+STAGE3_CONFIGURE_FLAGS = --disable-build-warnings
+
 # When using the slow stage1 compiler disable IL verification and forcefully
 # enable it when using the stage2 compiler instead.  As we later compare
 # stage2 and stage3 we are merely avoid doing redundant work, plus we apply
diff --git a/gcc/configure.ac b/gcc/configure.ac
index a693bfa0e31..c97dc0842b3 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -482,9 +482,22 @@ AC_ARG_ENABLE(build-format-warnings,
   [],[enable_build_format_warnings=yes])
 AS_IF([test $enable_build_format_warnings = no],
       [wf_opt=-Wno-format],[wf_opt=])
+
+# In stage 3, build without most warnings so bootstrap comparison against
+# stage 2 verifies that checks for warnings do not affect code generation
+AC_ARG_ENABLE(build-warnings,
+  AS_HELP_STRING([--disable-build-warnings],
+		 [do not enable most warnings while building GCC]),
+  [],[enable_build_warnings=yes])
+
+AS_IF([test "$enable_build_warnings" = yes],
+      [warn_opt="-W -Wall -Wcast-qual"],
+      # list warnings known to affect code generation: PR bootstrap/86518
+      [warn_opt="-Wsign-compare"])
+
 ACX_PROG_CXX_WARNING_OPTS(
-	m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
-		       [-Wcast-qual $wf_opt])), [loose_warn])
+	m4_quote(m4_do([$warn_opt $wf_opt -Wno-narrowing -Wwrite-strings])),
+	[loose_warn])
 ACX_PROG_CC_WARNING_OPTS(
 	m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes])),
 	[c_loose_warn])
diff --git a/Makefile.in b/Makefile.in
index e0dfad337a6..4d41595de3b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -529,6 +529,8 @@ STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
 	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)" \
 	  --disable-build-format-warnings
 
+STAGE3_CONFIGURE_FLAGS = --disable-build-warnings
+
 # When using the slow stage1 compiler disable IL verification and forcefully
 # enable it when using the stage2 compiler instead.  As we later compare
 # stage2 and stage3 we are merely avoid doing redundant work, plus we apply
diff --git a/gcc/configure b/gcc/configure
index be6f0be6ba2..25c669df0f3 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -898,6 +898,7 @@ with_gnu_as
 with_as
 enable_largefile
 enable_build_format_warnings
+enable_build_warnings
 enable_werror_always
 enable_checking
 enable_coverage
@@ -1604,6 +1605,8 @@ Optional Features:
   --disable-largefile     omit support for large files
   --disable-build-format-warnings
                           suppress -Wformat while building GCC
+  --disable-build-warnings
+                          do not enable most warnings while building GCC
   --enable-werror-always  enable -Werror despite compiler version
   --enable-checking[=LIST]
                           enable expensive run-time checks. With LIST, enable
@@ -6666,6 +6669,24 @@ if test $enable_build_format_warnings = no; then :
 else
   wf_opt=
 fi
+
+# In stage 3, build without most warnings so bootstrap comparison against
+# stage 2 verifies that checks for warnings do not affect code generation
+# Check whether --enable-build-warnings was given.
+if test "${enable_build_warnings+set}" = set; then :
+  enableval=$enable_build_warnings;
+else
+  enable_build_warnings=yes
+fi
+
+
+if test "$enable_build_warnings" = yes; then :
+  warn_opt="-W -Wall -Wcast-qual"
+else
+  # list warnings known to affect code generation: PR bootstrap/86518
+      warn_opt="-Wsign-compare"
+fi
+
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -6674,7 +6695,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 loose_warn=
 save_CXXFLAGS="$CXXFLAGS"
-for real_option in -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual $wf_opt; do
+for real_option in $warn_opt $wf_opt -Wno-narrowing -Wwrite-strings; do
   # Do the check with the no- prefix removed since gcc silently
   # accepts any -Wno-* option on purpose
   case $real_option in
@@ -18460,7 +18481,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18463 "configure"
+#line 18484 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18566,7 +18587,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18569 "configure"
+#line 18590 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19731,20 +19752,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	      prelink_cmds_CXX='tpldir=Template.dir~
 		rm -rf $tpldir~
 		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      old_archive_cmds_CXX='tpldir=Template.dir~
 		rm -rf $tpldir~
 		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
 		$RANLIB $oldlib'
 	      archive_cmds_CXX='tpldir=Template.dir~
 		rm -rf $tpldir~
 		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
 	      archive_expsym_cmds_CXX='tpldir=Template.dir~
 		rm -rf $tpldir~
 		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
 	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-- 
2.13.3

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

* Re: [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3
  2018-08-27 18:20 ` [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3 Alexander Monakov
@ 2018-08-27 18:56   ` Joseph Myers
  2018-08-27 19:05   ` Jeff Law
  1 sibling, 0 replies; 5+ messages in thread
From: Joseph Myers @ 2018-08-27 18:56 UTC (permalink / raw)
  To: Alexander Monakov; +Cc: gcc-patches

On Mon, 27 Aug 2018, Alexander Monakov wrote:

> 	* gcc/configure.ac (--disable-build-warnings): New option.

Note that for any version of this patch actually proposed for inclusion 
(as opposed to an RFC) you'll need to include documentation in 
install.texi for the new configure option.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3
  2018-08-27 18:20 ` [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3 Alexander Monakov
  2018-08-27 18:56   ` Joseph Myers
@ 2018-08-27 19:05   ` Jeff Law
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Law @ 2018-08-27 19:05 UTC (permalink / raw)
  To: Alexander Monakov, gcc-patches

On 08/27/2018 12:20 PM, Alexander Monakov wrote:
> Currently bootstrap stages 2 and 3 use the same warning options, but that is
> redundant: if any warnings are generated, they will be present in stage 2 (and
> stop bootstrap).  By not enabling any warnings for stage 3, we would get
> simple automated checking that warnings do not affect code generation.
> 
> I've checked GCC 5 managed to bootstrap in this manner, but starting from
> GCC 6 we've gotten less lucky.  There's a bunch of options already confirmed
> to affect code generation:
> 
> -Wnonnull/-Wrestrict/-Wformat/-Wsuggest-attribute=format (PR 86567)
> -Wimplicit-fallthrough (PR 86575)
> -Wsign-compare (PR 86586)
At least some of these are likely mine...  The range analyzer is
reflecting ranges it discovers back into the global state.  THe fix
ought to be easy, but I haven't gotten to it yet.

jeff

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

* Re: [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't'
  2018-08-27 17:29 [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't' Alexander Monakov
  2018-08-27 18:20 ` [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3 Alexander Monakov
@ 2018-08-30 12:12 ` Richard Sandiford
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Sandiford @ 2018-08-30 12:12 UTC (permalink / raw)
  To: Alexander Monakov; +Cc: gcc-patches

Alexander Monakov <amonakov@ispras.ru> writes:
> Hello,
>
> If patch 2/2 is approved, I'd like to apply this alongside with that.
>
> Use positive form ("suppress") rather than negative ("don't") to explain
> the option, because using the option results in passing -Wno-format 
> rather than not passing -Wformat.  I felt confused when trying to follow
> the logic of the option, and this change would clarify things for me.
>
> Unpaired apostrophe in "don't" also happens to break syntax matching in Vim.
>
> 	* configure.ac (build-format-warnings): Reword help text.
> 	* configure: Regenerate.
>
> diff --git a/gcc/configure b/gcc/configure
> index b7a8e364377..be6f0be6ba2 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -1603,7 +1603,7 @@ Optional Features:
>                            texinfo bison or flex
>    --disable-largefile     omit support for large files
>    --disable-build-format-warnings
> -                          don't use -Wformat while building GCC
> +                          suppress -Wformat while building GCC
>    --enable-werror-always  enable -Werror despite compiler version
>    --enable-checking[=LIST]
>                            enable expensive run-time checks. With LIST, enable
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 65f9c92ec85..a693bfa0e31 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -478,7 +478,7 @@ AC_SUBST(aliasing_flags)
>  
>  # In stage 1, disable -Wformat warnings from old GCCs about new % codes
>  AC_ARG_ENABLE(build-format-warnings,
> -  AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
> +  AS_HELP_STRING([--disable-build-format-warnings],[suppress -Wformat while building GCC]),
>    [],[enable_build_format_warnings=yes])
>  AS_IF([test $enable_build_format_warnings = no],
>        [wf_opt=-Wno-format],[wf_opt=])

This is OK independently of 2/2.  (And thanks for working on 2/2.)

Richard

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

end of thread, other threads:[~2018-08-30 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-27 17:29 [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't' Alexander Monakov
2018-08-27 18:20 ` [PATCH RFC 2/2] bootstrap: disable most warnings in stage 3 Alexander Monakov
2018-08-27 18:56   ` Joseph Myers
2018-08-27 19:05   ` Jeff Law
2018-08-30 12:12 ` [PATCH 1/2] configure.ac: use 'suppress' instead of 'don't' Richard Sandiford

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).