diff mbox

PATCH to use -Wno-format during stage1

Message ID 52712A20.7040007@redhat.com
State New
Headers show

Commit Message

Jason Merrill Oct. 30, 2013, 3:47 p.m. UTC
I find -Wformat warnings about unknown % codes when building with an 
older GCC to be mildly annoying noise; this patch avoids them by passing 
-Wno-format during stage 1.

Tested x86_64-pc-linux-gnu.  Is this OK for trunk?  Do you have another 
theory of how this should work?

Comments

Paolo Bonzini Oct. 30, 2013, 4:11 p.m. UTC | #1
Il 30/10/2013 16:47, Jason Merrill ha scritto:
> I find -Wformat warnings about unknown % codes when building with an
> older GCC to be mildly annoying noise; this patch avoids them by passing
> -Wno-format during stage 1.
> 
> Tested x86_64-pc-linux-gnu.  Is this OK for trunk?

Ok.
Ian Lance Taylor Oct. 30, 2013, 7:55 p.m. UTC | #2
On Wed, Oct 30, 2013 at 8:47 AM, Jason Merrill <jason@redhat.com> wrote:
> I find -Wformat warnings about unknown % codes when building with an older
> GCC to be mildly annoying noise; this patch avoids them by passing
> -Wno-format during stage 1.
>
> Tested x86_64-pc-linux-gnu.  Is this OK for trunk?  Do you have another
> theory of how this should work?

Thank you!

Ian
Richard Biener Nov. 4, 2013, 12:41 p.m. UTC | #3
On Wed, Oct 30, 2013 at 8:55 PM, Ian Lance Taylor <iant@google.com> wrote:
> On Wed, Oct 30, 2013 at 8:47 AM, Jason Merrill <jason@redhat.com> wrote:
>> I find -Wformat warnings about unknown % codes when building with an older
>> GCC to be mildly annoying noise; this patch avoids them by passing
>> -Wno-format during stage 1.
>>
>> Tested x86_64-pc-linux-gnu.  Is this OK for trunk?  Do you have another
>> theory of how this should work?
>
> Thank you!

Please make sure the warning is preserved when not bootstrapping,
it's useful to have them in your dev-tree and not notice errors only
during -Werror bootstrap ...

Richard.

> Ian
Jason Merrill Nov. 4, 2013, 3:34 p.m. UTC | #4
On 11/04/2013 07:41 AM, Richard Biener wrote:
> Please make sure the warning is preserved when not bootstrapping,
> it's useful to have them in your dev-tree and not notice errors only
> during -Werror bootstrap ...

I found it to be useless noise when not bootstrapping, since my system 
compiler isn't likely to recognize recently added % codes any time soon.

Jason
Paolo Carlini Nov. 4, 2013, 3:41 p.m. UTC | #5
On 11/04/2013 04:34 PM, Jason Merrill wrote:
> On 11/04/2013 07:41 AM, Richard Biener wrote:
>> Please make sure the warning is preserved when not bootstrapping,
>> it's useful to have them in your dev-tree and not notice errors only
>> during -Werror bootstrap ...
>
> I found it to be useless noise when not bootstrapping, since my system 
> compiler isn't likely to recognize recently added % codes any time soon.
Likewise here.

Paolo.
Jakub Jelinek Nov. 4, 2013, 3:50 p.m. UTC | #6
On Mon, Nov 04, 2013 at 10:34:55AM -0500, Jason Merrill wrote:
> On 11/04/2013 07:41 AM, Richard Biener wrote:
> >Please make sure the warning is preserved when not bootstrapping,
> >it's useful to have them in your dev-tree and not notice errors only
> >during -Werror bootstrap ...
> 
> I found it to be useless noise when not bootstrapping, since my
> system compiler isn't likely to recognize recently added % codes any
> time soon.

That's true, but it is easy to ignore those, while without -Wformat
you won't notice until you bootstrap that you actually passed incorrect
parameters to some *printf etc. family function.  Generally, in
non-bootstrap compilers I tend to ignore warnings except for the
file(s) I've been hacking on.

	Jakub
Jason Merrill Nov. 4, 2013, 5:23 p.m. UTC | #7
On 11/04/2013 10:50 AM, Jakub Jelinek wrote:
> That's true, but it is easy to ignore those, while without -Wformat
> you won't notice until you bootstrap that you actually passed incorrect
> parameters to some *printf etc. family function.

Sure, but that is much less common than the false positives, and will be 
caught anyway when you actually bootstrap (or rebuild stage 3).

Jason
diff mbox

Patch

commit c40b06619fc9ef74e4d4d8b299a6c77c6fb63df5
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Oct 28 16:45:05 2013 -0400

    /
    	* Makefile.tpl (STAGE1_CONFIGURE_FLAGS): Pass
    	--disable-build-format-warnings.
    gcc/
    	* configure.ac (loose_warn): Add -Wno-format if
    	--disable-build-format-warnings.

diff --git a/Makefile.in b/Makefile.in
index 572b3d0..e0ba784 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -498,8 +498,10 @@  STAGE1_LANGUAGES = @stage1_languages@
 #   the last argument when conflicting --enable arguments are passed.
 # * Likewise, we force-disable coverage flags, since the installed
 #   compiler probably has never heard of them.
+# * We also disable -Wformat, since older GCCs don't understand newer %s.
 STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
-	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"
+	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)" \
+	  --disable-build-format-warnings
 
 STAGEprofile_CFLAGS = $(STAGE2_CFLAGS) -fprofile-generate
 STAGEprofile_TFLAGS = $(STAGE2_TFLAGS)
diff --git a/Makefile.tpl b/Makefile.tpl
index 3e187e1..65d070b 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -451,8 +451,10 @@  STAGE1_LANGUAGES = @stage1_languages@
 #   the last argument when conflicting --enable arguments are passed.
 # * Likewise, we force-disable coverage flags, since the installed
 #   compiler probably has never heard of them.
+# * We also disable -Wformat, since older GCCs don't understand newer %s.
 STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
-	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"
+	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)" \
+	  --disable-build-format-warnings
 
 STAGEprofile_CFLAGS = $(STAGE2_CFLAGS) -fprofile-generate
 STAGEprofile_TFLAGS = $(STAGE2_TFLAGS)
diff --git a/gcc/configure b/gcc/configure
index 1e7bcb6..ea91906 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -875,6 +875,7 @@  with_demangler_in_ld
 with_gnu_as
 with_as
 enable_largefile
+enable_build_format_warnings
 enable_werror_always
 enable_checking
 enable_coverage
@@ -1569,6 +1570,8 @@  Optional Features:
                           for creating source tarballs for users without
                           texinfo bison or flex
   --disable-largefile     omit support for large files
+  --disable-build-format-warnings
+                          don't use -Wformat while building GCC
   --enable-werror-always  enable -Werror despite compiler version
   --enable-checking[=LIST]
                           enable expensive run-time checks. With LIST, enable
@@ -6270,9 +6273,22 @@  fi
 # * C++11 narrowing conversions in { }
 # So, we only use -pedantic if we can disable those warnings.
 
+# In stage 1, disable -Wformat warnings from old GCCs about new % codes
+# Check whether --enable-build-format-warnings was given.
+if test "${enable_build_format_warnings+set}" = set; then :
+  enableval=$enable_build_format_warnings;
+else
+  enable_build_format_warnings=yes
+fi
+
+if test $enable_build_format_warnings = no; then :
+  wf_opt=-Wno-format
+else
+  wf_opt=
+fi
 loose_warn=
 save_CFLAGS="$CFLAGS"
-for real_option in -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual; do
+for real_option in -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual $wf_opt; do
   # Do the check with the no- prefix removed since gcc silently
   # accepts any -Wno-* option on purpose
   case $real_option in
@@ -17897,7 +17913,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17900 "configure"
+#line 17916 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18003,7 +18019,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18006 "configure"
+#line 18022 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 5e686db..3d3b26b 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -326,8 +326,14 @@  GCC_STDINT_TYPES
 # * C++11 narrowing conversions in { }
 # So, we only use -pedantic if we can disable those warnings.
 
+# 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]),
+  [],[enable_build_format_warnings=yes])
+AS_IF([test $enable_build_format_warnings = no],
+      [wf_opt=-Wno-format],[wf_opt=])
 ACX_PROG_CC_WARNING_OPTS(
-	m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual])), [loose_warn])
+	m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual $wf_opt])), [loose_warn])
 ACX_PROG_CC_WARNING_OPTS(
 	m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes])),
 	[c_loose_warn])