Blame SOURCES/glibc-rh1505492-werror-activate.patch

25845f
commit a4ecc9eb9b15bc51a1dc4726c06d35eaea74e162
25845f
Author: Joseph Myers <joseph@codesourcery.com>
25845f
Date:   Wed Dec 10 01:14:48 2014 +0000
25845f
25845f
    Use -Werror by default, add --disable-werror.
25845f
    
25845f
    As discussed starting at
25845f
    <https://sourceware.org/ml/libc-alpha/2014-11/msg00323.html>, this
25845f
    patch makes the glibc build use -Werror by default to avoid
25845f
    accidentally adding new warnings to the build.  The configure option
25845f
    --disable-werror can be used to disable this.
25845f
    
25845f
    -Wno-error=undef is temporarily used because the build isn't clean
25845f
    regarding -Wundef warnings.  The idea is that once the remaining
25845f
    -Wundef warnings have been cleaned up (in at least one configuration),
25845f
    -Wno-error=undef will be removed.
25845f
    
25845f
    I get a clean build and test on x86_64 (GCC 4.9 branch) with this
25845f
    patch.  The expectation is that this may well break the build for some
25845f
    other configurations, and people seeing such breakage should make
25845f
    appropriate fixes to fix or suppress the warnings for their
25845f
    configurations.  In some cases that may involve using pragmas as the
25845f
    right fix (I think that will be right for the -Wno-inline issue for
25845f
    MIPS I referred to in
25845f
    <https://sourceware.org/ml/libc-alpha/2012-11/msg00798.html>, for
25845f
    example), in some cases -Wno-error in sysdeps makefiles (__restore_rt
25845f
    in MIPS sigaction, for example), in some cases substantive fixes for
25845f
    the warnings.
25845f
    
25845f
    Note that if, with a view to listing all the warnings then fixing them
25845f
    all, you just look for "warning:" in output from building and testing
25845f
    with --disable-werror, you'll see lots of warnings from the linker
25845f
    about functions such as tmpnam.  Those warnings can be ignored - only
25845f
    compiler warnings are relevant to -Werror, not linker warnings.
25845f
    
25845f
            * configure.ac (--disable-werror): New configure option.
25845f
            (enable_werror): New AC_SUBST.
25845f
            * configure: Regenerated.
25845f
            * config.make.in (enable-werror): New variable.
25845f
            * Makeconfig [$(enable-werror) = yes] (+gccwarn): Add -Werror
25845f
            -Wno-error=undef.
25845f
            (+gccwarn-c): Do not use -Werror=implicit-function-declaration.
25845f
            * manual/install.texi (Configuring and compiling): Document
25845f
            --disable-werror.
25845f
            * INSTALL: Regenerated.
25845f
            * debug/Makefile (CFLAGS-tst-chk1.c): Add -Wno-error.
25845f
            (CFLAGS-tst-chk2.c): Likewise.
25845f
            (CFLAGS-tst-chk3.c): Likewise.
25845f
            (CFLAGS-tst-chk4.cc): Likewise.
25845f
            (CFLAGS-tst-chk5.cc): Likewise.
25845f
            (CFLAGS-tst-chk6.cc): Likewise.
25845f
            (CFLAGS-tst-lfschk1.c): Likewise.
25845f
            (CFLAGS-tst-lfschk2.c): Likewise.
25845f
            (CFLAGS-tst-lfschk3.c): Likewise.
25845f
            (CFLAGS-tst-lfschk4.cc): Likewise.
25845f
            (CFLAGS-tst-lfschk5.cc): Likewise.
25845f
            (CFLAGS-tst-lfschk6.cc): Likewise.
25845f
25845f
Conflicts:
25845f
	INSTALL
25845f
	manual/install.texi
25845f
	  (Textual conflicts due to elision backport;
25845f
          glibc-rh841653-0.patch and others)
25845f
	configure.ac
25845f
	  (Change applied to configure.in instead.) 
25845f
25845f
diff --git a/INSTALL b/INSTALL
25845f
index 264e57bc5f0316f7..82b29f5d8746f929 100644
25845f
--- a/INSTALL
25845f
+++ b/INSTALL
25845f
@@ -143,6 +143,13 @@ will be used, and CFLAGS sets optimization options for the compiler.
25845f
 `--enable-lock-elision=yes'
25845f
      Enable lock elision for pthread mutexes by default.
25845f
 
25845f
+`--disable-werror'
25845f
+     By default, the GNU C Library is built with `-Werror'.  If you wish
25845f
+     to build without this option (for example, if building with a newer
25845f
+     version of GCC than this version of the GNU C Library was tested
25845f
+     with, so new warnings cause the build with `-Werror' to fail), you
25845f
+     can configure with `--disable-werror'.
25845f
+
25845f
 `--build=BUILD-SYSTEM'
25845f
 `--host=HOST-SYSTEM'
25845f
      These options are for cross-compiling.  If you specify both
25845f
diff --git a/Makeconfig b/Makeconfig
25845f
index 02f1cc1255c5ac07..6f61e4835c0a7770 100644
25845f
--- a/Makeconfig
25845f
+++ b/Makeconfig
25845f
@@ -644,7 +644,10 @@ else
25845f
 +gccwarn := -Wall -Wwrite-strings -Winline
25845f
 endif
25845f
 +gccwarn += -Wundef
25845f
-+gccwarn-c = -Wstrict-prototypes -Werror=implicit-function-declaration
25845f
+ifeq ($(enable-werror),yes)
25845f
++gccwarn += -Werror -Wno-error=undef
25845f
+endif
25845f
++gccwarn-c = -Wstrict-prototypes
25845f
 
25845f
 # We do not depend on the address of constants in different files to be
25845f
 # actually different, so allow the compiler to merge them all.
25845f
diff --git a/config.make.in b/config.make.in
25845f
index d5490f61cd3faeba..3c65c9f03ab65a74 100644
25845f
--- a/config.make.in
25845f
+++ b/config.make.in
25845f
@@ -49,6 +49,7 @@ sysheaders = @sysheaders@
25845f
 sysincludes = @SYSINCLUDES@
25845f
 c++-sysincludes = @CXX_SYSINCLUDES@
25845f
 all-warnings = @all_warnings@
25845f
+enable-werror = @enable_werror@
25845f
 
25845f
 have-z-combreloc = @libc_cv_z_combreloc@
25845f
 have-z-execstack = @libc_cv_z_execstack@
25845f
diff --git a/configure b/configure
25845f
index b185b400dfbc21de..769f0fa149d0ef9c 100755
25845f
--- a/configure
25845f
+++ b/configure
25845f
@@ -660,6 +660,7 @@ build_pt_chown
25845f
 build_nscd
25845f
 link_obsolete_rpc
25845f
 libc_cv_nss_crypt
25845f
+enable_werror
25845f
 all_warnings
25845f
 force_install
25845f
 bindnow
25845f
@@ -758,6 +759,7 @@ enable_static_nss
25845f
 enable_force_install
25845f
 enable_kernel
25845f
 enable_all_warnings
25845f
+enable_werror
25845f
 enable_multi_arch
25845f
 enable_nss_crypt
25845f
 enable_obsolete_rpc
25845f
@@ -1419,6 +1421,7 @@ Optional Features:
25845f
   --enable-kernel=VERSION compile for compatibility with kernel not older than
25845f
                           VERSION
25845f
   --enable-all-warnings   enable all useful warnings gcc can issue
25845f
+  --disable-werror        do not build with -Werror
25845f
   --enable-multi-arch     enable single DSO with optimizations for multiple
25845f
                           architectures
25845f
   --enable-nss-crypt      enable libcrypt to use nss
25845f
@@ -3803,6 +3806,15 @@ fi
25845f
 
25845f
 
25845f
 
25845f
+# Check whether --enable-werror was given.
25845f
+if test "${enable_werror+set}" = set; then :
25845f
+  enableval=$enable_werror; enable_werror=$enableval
25845f
+else
25845f
+  enable_werror=yes
25845f
+fi
25845f
+
25845f
+
25845f
+
25845f
 # Check whether --enable-multi-arch was given.
25845f
 if test "${enable_multi_arch+set}" = set; then :
25845f
   enableval=$enable_multi_arch; multi_arch=$enableval
25845f
diff --git a/configure.in b/configure.in
25845f
index f8c36ba306e01f59..9feb463ddfed2a27 100644
25845f
--- a/configure.in
25845f
+++ b/configure.in
25845f
@@ -234,6 +234,13 @@ AC_ARG_ENABLE([all-warnings],
25845f
 	      [])
25845f
 AC_SUBST(all_warnings)
25845f
 
25845f
+AC_ARG_ENABLE([werror],
25845f
+	      AC_HELP_STRING([--disable-werror],
25845f
+			     [do not build with -Werror]),
25845f
+	      [enable_werror=$enableval],
25845f
+	      [enable_werror=yes])
25845f
+AC_SUBST(enable_werror)
25845f
+
25845f
 AC_ARG_ENABLE([multi-arch],
25845f
 	      AC_HELP_STRING([--enable-multi-arch],
25845f
 			     [enable single DSO with optimizations for multiple architectures]),
25845f
diff --git a/debug/Makefile b/debug/Makefile
25845f
index e4efd9bcc687e562..6588b6327ae01205 100644
25845f
--- a/debug/Makefile
25845f
+++ b/debug/Makefile
25845f
@@ -89,19 +89,21 @@ CFLAGS-tst-longjmp_chk2.c = -fexceptions -fasynchronous-unwind-tables
25845f
 CPPFLAGS-tst-longjmp_chk2.c = -D_FORTIFY_SOURCE=1
25845f
 
25845f
 # We know these tests have problems with format strings, this is what
25845f
-# we are testing.  Disable that warning.
25845f
-CFLAGS-tst-chk1.c = -Wno-format
25845f
-CFLAGS-tst-chk2.c = -Wno-format
25845f
-CFLAGS-tst-chk3.c = -Wno-format
25845f
-CFLAGS-tst-chk4.cc = -Wno-format
25845f
-CFLAGS-tst-chk5.cc = -Wno-format
25845f
-CFLAGS-tst-chk6.cc = -Wno-format
25845f
-CFLAGS-tst-lfschk1.c = -Wno-format
25845f
-CFLAGS-tst-lfschk2.c = -Wno-format
25845f
-CFLAGS-tst-lfschk3.c = -Wno-format
25845f
-CFLAGS-tst-lfschk4.cc = -Wno-format
25845f
-CFLAGS-tst-lfschk5.cc = -Wno-format
25845f
-CFLAGS-tst-lfschk6.cc = -Wno-format
25845f
+# we are testing.  Disable that warning.  They also generate warnings
25845f
+# from warning attributes, which cannot be disabled via pragmas, so
25845f
+# require -Wno-error to be used.
25845f
+CFLAGS-tst-chk1.c = -Wno-format -Wno-error
25845f
+CFLAGS-tst-chk2.c = -Wno-format -Wno-error
25845f
+CFLAGS-tst-chk3.c = -Wno-format -Wno-error
25845f
+CFLAGS-tst-chk4.cc = -Wno-format -Wno-error
25845f
+CFLAGS-tst-chk5.cc = -Wno-format -Wno-error
25845f
+CFLAGS-tst-chk6.cc = -Wno-format -Wno-error
25845f
+CFLAGS-tst-lfschk1.c = -Wno-format -Wno-error
25845f
+CFLAGS-tst-lfschk2.c = -Wno-format -Wno-error
25845f
+CFLAGS-tst-lfschk3.c = -Wno-format -Wno-error
25845f
+CFLAGS-tst-lfschk4.cc = -Wno-format -Wno-error
25845f
+CFLAGS-tst-lfschk5.cc = -Wno-format -Wno-error
25845f
+CFLAGS-tst-lfschk6.cc = -Wno-format -Wno-error
25845f
 LDLIBS-tst-chk4 = -lstdc++
25845f
 LDLIBS-tst-chk5 = -lstdc++
25845f
 LDLIBS-tst-chk6 = -lstdc++
25845f
diff --git a/manual/install.texi b/manual/install.texi
25845f
index 7fe6e005c3fdd5fb..3799cee621ddc4f9 100644
25845f
--- a/manual/install.texi
25845f
+++ b/manual/install.texi
25845f
@@ -177,6 +177,13 @@ you understand and accept those risks.
25845f
 @item --enable-lock-elision=yes
25845f
 Enable lock elision for pthread mutexes by default.
25845f
 
25845f
+@item --disable-werror
25845f
+By default, @theglibc{} is built with @option{-Werror}.  If you wish
25845f
+to build without this option (for example, if building with a newer
25845f
+version of GCC than this version of @theglibc{} was tested with, so
25845f
+new warnings cause the build with @option{-Werror} to fail), you can
25845f
+configure with @option{--disable-werror}.
25845f
+
25845f
 @item --build=@var{build-system}
25845f
 @itemx --host=@var{host-system}
25845f
 These options are for cross-compiling.  If you specify both options and