Make `-Werror` optional in libatomic/libbacktrace/libgomp/libitm/libsanitizer
Commit Message
* `-Werror` can cause issues when a more recent version of GCC compiles
an older version:
- https://bugs.gentoo.org/229059
- https://bugs.gentoo.org/475350
- https://bugs.gentoo.org/667104
---
libatomic/configure.ac | 6 ++++--
libbacktrace/configure.ac | 7 ++++---
libgomp/configure.ac | 6 ++++--
libitm/configure.ac | 6 ++++--
libsanitizer/configure.ac | 9 +++++++++
libsanitizer/libbacktrace/Makefile.am | 2 --
6 files changed, 25 insertions(+), 11 deletions(-)
Comments
On Mon, Jan 17, 2022 at 3:05 PM David Seifert via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> * `-Werror` can cause issues when a more recent version of GCC compiles
> an older version:
> - https://bugs.gentoo.org/229059
> - https://bugs.gentoo.org/475350
> - https://bugs.gentoo.org/667104
> ---
> libatomic/configure.ac | 6 ++++--
> libbacktrace/configure.ac | 7 ++++---
> libgomp/configure.ac | 6 ++++--
> libitm/configure.ac | 6 ++++--
> libsanitizer/configure.ac | 9 +++++++++
> libsanitizer/libbacktrace/Makefile.am | 2 --
> 6 files changed, 25 insertions(+), 11 deletions(-)
Hi, thanks for the patch, I personally support it (assuming it goes
along with a regeneration of the configure scripts). Reading it,
though, reminded me of another quibble I had about warning options
used when building GCC: The GCC docs for -Wextra say "(This option
used to be called -W. The older name is still supported, but the newer
name is more descriptive.)" See:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options
This to me seems to imply that -Wextra is the preferred name, and that
the old name of -W should be replaced by it. Could we also make a
change to rename all instances of -W in configure scripts to -Wextra
too? Just a thought.
Thanks,
Eric
>
> diff --git a/libatomic/configure.ac b/libatomic/configure.ac
> index f350b9b3509..5a9f69bb74d 100644
> --- a/libatomic/configure.ac
> +++ b/libatomic/configure.ac
> @@ -251,10 +251,12 @@ LIBAT_ENABLE_SYMVERS
> CFLAGS="$save_CFLAGS"
> AC_CACHE_SAVE
>
> +AC_ARG_ENABLE([werror], [
> + AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
> # Add -Wall -Werror if we are using GCC.
> -if test "x$GCC" = "xyes"; then
> +AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"], [
> XCFLAGS="$XCFLAGS -Wall -Werror"
> -fi
> +])
>
> # Add CET specific flags if CET is enabled
> GCC_CET_FLAGS(CET_FLAGS)
> diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
> index 0dfd82bc03e..a2858e6ecde 100644
> --- a/libbacktrace/configure.ac
> +++ b/libbacktrace/configure.ac
> @@ -145,10 +145,11 @@ ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
> -Wmissing-format-attribute -Wcast-qual],
> [WARN_FLAGS])
>
> -if test -n "${with_target_subdir}"; then
> +AC_ARG_ENABLE([werror], [
> + AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
> +AS_IF([test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"], [
> WARN_FLAGS="$WARN_FLAGS -Werror"
> -fi
> -
> +])
> AC_SUBST(WARN_FLAGS)
>
> if test -n "${with_target_subdir}"; then
> diff --git a/libgomp/configure.ac b/libgomp/configure.ac
> index bfb613b91f0..c3062dc5a07 100644
> --- a/libgomp/configure.ac
> +++ b/libgomp/configure.ac
> @@ -121,10 +121,12 @@ AC_SUBST(CFLAGS)
> # in both places for now and restore CFLAGS at the end of config.
> save_CFLAGS="$CFLAGS"
>
> +AC_ARG_ENABLE([werror], [
> + AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
> # Add -Wall -Werror if we are using GCC.
> -if test "x$GCC" = "xyes"; then
> +AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"], [
> XCFLAGS="$XCFLAGS -Wall -Werror"
> -fi
> +])
>
> # Find other programs we need.
> AC_CHECK_TOOL(AR, ar)
> diff --git a/libitm/configure.ac b/libitm/configure.ac
> index ac81b146845..ad99d14098e 100644
> --- a/libitm/configure.ac
> +++ b/libitm/configure.ac
> @@ -261,10 +261,12 @@ GCC_CHECK_ELF_STYLE_WEAKREF
> CFLAGS="$save_CFLAGS"
> AC_CACHE_SAVE
>
> +AC_ARG_ENABLE([werror], [
> + AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
> # Add -Wall -Werror if we are using GCC.
> -if test "x$GCC" = "xyes"; then
> +AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"], [
> XCFLAGS="$XCFLAGS -Wall -Werror"
> -fi
> +])
>
> XCFLAGS="$XCFLAGS $XPCFLAGS"
>
> diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
> index 13cd302030d..64eb42afc83 100644
> --- a/libsanitizer/configure.ac
> +++ b/libsanitizer/configure.ac
> @@ -400,6 +400,15 @@ fi
> AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS])
> AC_SUBST([SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS])
>
> +AC_ARG_ENABLE([werror], [
> + AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
> +
> +WARN_FLAGS="-W -Wall -Wwrite-strings -Wmissing-format-attribute -Wcast-qual"
> +AS_IF([test "x$enable_werror" != "xno"], [
> + WARN_FLAGS="$WARN_FLAGS -Werror"
> +])
> +AC_SUBST([WARN_FLAGS])
> +
> # Determine what GCC version number to use in filesystem paths.
> GCC_BASE_VER
>
> diff --git a/libsanitizer/libbacktrace/Makefile.am b/libsanitizer/libbacktrace/Makefile.am
> index 16accd468df..0cf8d2104c0 100644
> --- a/libsanitizer/libbacktrace/Makefile.am
> +++ b/libsanitizer/libbacktrace/Makefile.am
> @@ -34,8 +34,6 @@ ACLOCAL_AMFLAGS = -I ../.. -I ../../config
> AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
> -I ../../libgcc -I .. -I $(top_srcdir) -I $(top_srcdir)/../libbacktrace
>
> -WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
> - -Wcast-qual -Werror
> C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition
> CXX_WARN_FLAGS = $(WARN_FLAGS) -Wno-unused-parameter
> AM_CFLAGS = $(C_WARN_FLAGS)
> --
> 2.34.1
>
@@ -251,10 +251,12 @@ LIBAT_ENABLE_SYMVERS
CFLAGS="$save_CFLAGS"
AC_CACHE_SAVE
+AC_ARG_ENABLE([werror], [
+ AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
# Add -Wall -Werror if we are using GCC.
-if test "x$GCC" = "xyes"; then
+AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"], [
XCFLAGS="$XCFLAGS -Wall -Werror"
-fi
+])
# Add CET specific flags if CET is enabled
GCC_CET_FLAGS(CET_FLAGS)
@@ -145,10 +145,11 @@ ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
-Wmissing-format-attribute -Wcast-qual],
[WARN_FLAGS])
-if test -n "${with_target_subdir}"; then
+AC_ARG_ENABLE([werror], [
+ AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
+AS_IF([test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"], [
WARN_FLAGS="$WARN_FLAGS -Werror"
-fi
-
+])
AC_SUBST(WARN_FLAGS)
if test -n "${with_target_subdir}"; then
@@ -121,10 +121,12 @@ AC_SUBST(CFLAGS)
# in both places for now and restore CFLAGS at the end of config.
save_CFLAGS="$CFLAGS"
+AC_ARG_ENABLE([werror], [
+ AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
# Add -Wall -Werror if we are using GCC.
-if test "x$GCC" = "xyes"; then
+AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"], [
XCFLAGS="$XCFLAGS -Wall -Werror"
-fi
+])
# Find other programs we need.
AC_CHECK_TOOL(AR, ar)
@@ -261,10 +261,12 @@ GCC_CHECK_ELF_STYLE_WEAKREF
CFLAGS="$save_CFLAGS"
AC_CACHE_SAVE
+AC_ARG_ENABLE([werror], [
+ AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
# Add -Wall -Werror if we are using GCC.
-if test "x$GCC" = "xyes"; then
+AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"], [
XCFLAGS="$XCFLAGS -Wall -Werror"
-fi
+])
XCFLAGS="$XCFLAGS $XPCFLAGS"
@@ -400,6 +400,15 @@ fi
AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS])
AC_SUBST([SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS])
+AC_ARG_ENABLE([werror], [
+ AS_HELP_STRING([--enable-werror], [turns on -Werror @<:@default=yes@:>@])])
+
+WARN_FLAGS="-W -Wall -Wwrite-strings -Wmissing-format-attribute -Wcast-qual"
+AS_IF([test "x$enable_werror" != "xno"], [
+ WARN_FLAGS="$WARN_FLAGS -Werror"
+])
+AC_SUBST([WARN_FLAGS])
+
# Determine what GCC version number to use in filesystem paths.
GCC_BASE_VER
@@ -34,8 +34,6 @@ ACLOCAL_AMFLAGS = -I ../.. -I ../../config
AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
-I ../../libgcc -I .. -I $(top_srcdir) -I $(top_srcdir)/../libbacktrace
-WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
- -Wcast-qual -Werror
C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition
CXX_WARN_FLAGS = $(WARN_FLAGS) -Wno-unused-parameter
AM_CFLAGS = $(C_WARN_FLAGS)