From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128530 invoked by alias); 10 Feb 2020 16:40:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 128447 invoked by uid 89); 10 Feb 2020 16:40:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_PASS autolearn=ham version=3.3.1 spammy=stick, SHELL, LDFLAGS, CPPFLAGS X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.26.124) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Feb 2020 16:40:34 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id D8B9E244939 for ; Mon, 10 Feb 2020 11:40:32 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1NCiExSsYnnx; Mon, 10 Feb 2020 11:40:32 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 078A9244739; Mon, 10 Feb 2020 11:40:32 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 078A9244739 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1581352832; bh=XACJnRMO51T7HrMoTC2kRG9abYaU4WBpSVSXB8gI69o=; h=From:To:Date:Message-Id:MIME-Version; b=TNXgRubJtRVmg3S73rF31nEp/P6aPKx7qhSyiqyRIHo8QxkJieDcmwlSfgFI89RSs TmufoeJrZtNhCV6QUIPtEabnPxUgIXPxaYE6EUGvqifa9jk2QCD7z/z82dhqwEBeFt /wqf9PYB6me+uNZJa+V2uQxOdmRzflHJRfG5oCKcGaOphFAD2F5JM3hlqavRVTBI78 W6YiXgjR0r0tByZ1DRXdoO0aID3AteP4VwcHLaN/UErlc8l6nKXU/8S8zxJiLI8MLm CSg8VAL8nSJtFd2cqio3yvOrcQrm8zNBCSOLo5oa4t0TWtpCfixjey1aSroa0aaA/B Pnfj7izX7/FIA== Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id r88p6ZyzJE0h; Mon, 10 Feb 2020 11:40:31 -0500 (EST) Received: from smarchi-efficios.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id D20AC244737; Mon, 10 Feb 2020 11:40:31 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/3] gdbsupport: use AM_GDB_WARNINGS Date: Mon, 10 Feb 2020 16:40:00 -0000 Message-Id: <20200210164024.32445-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2020-02/txt/msg00287.txt.bz2 Since gdbsupport has been given its own build system, it is no longer compiled with the warning flags specified in gdb/warning.m4. This patch makes it use AM_GDB_WARNINGS. gdbsupport/ChangeLog: * acinclude.m4: Include ../gdb/warning.m4. * configure.ac: Use AM_GDB_WARNINGS. * Makefile.am: Set AM_CFLAGS to WARN_CFLAGS and WERROR_CFLAGS. * Makefile.in: Re-generate. * configure: Re-generate. --- gdbsupport/Makefile.am | 2 + gdbsupport/Makefile.in | 6 +- gdbsupport/acinclude.m4 | 3 + gdbsupport/configure | 194 ++++++++++++++++++++++++++++++++++++++++ gdbsupport/configure.ac | 3 + 5 files changed, 207 insertions(+), 1 deletion(-) diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am index 4b8a604ce52e..cd7b0adf6b4c 100644 --- a/gdbsupport/Makefile.am +++ b/gdbsupport/Makefile.am @@ -29,6 +29,8 @@ override CXX +=3D $(CXX_DIALECT) override CC :=3D $(CXX) override CFLAGS :=3D $(CXXFLAGS) =20 +AM_CFLAGS =3D $(WARN_CFLAGS) $(WERROR_CFLAGS) + noinst_LIBRARIES =3D libgdbsupport.a =20 if SELFTEST diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in index 31065af2440a..91164175bc04 100644 --- a/gdbsupport/Makefile.in +++ b/gdbsupport/Makefile.in @@ -124,7 +124,8 @@ am__aclocal_m4_deps =3D $(top_srcdir)/../config/codeset= .m4 \ $(top_srcdir)/../gdb/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../gdb/libiberty.m4 \ $(top_srcdir)/../gdb/selftest.m4 \ - $(top_srcdir)/../gdb/ptrace.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/../gdb/ptrace.m4 $(top_srcdir)/../gdb/warning.m4 \ + $(top_srcdir)/configure.ac am__configure_deps =3D $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON =3D $(srcdir)/Makefile.am $(top_srcdir)/configure \ @@ -287,6 +288,8 @@ SHELL =3D @SHELL@ STRIP =3D @STRIP@ USE_NLS =3D @USE_NLS@ VERSION =3D @VERSION@ +WARN_CFLAGS =3D @WARN_CFLAGS@ +WERROR_CFLAGS =3D @WERROR_CFLAGS@ XGETTEXT =3D @XGETTEXT@ abs_builddir =3D @abs_builddir@ abs_srcdir =3D @abs_srcdir@ @@ -350,6 +353,7 @@ AM_CPPFLAGS =3D -I$(srcdir)/../include -I$(srcdir)/../g= db \ -I../gnulib/import -I$(srcdir)/../gnulib/import \ -I.. -I$(srcdir)/.. $(INCINTL) -I../bfd -I$(srcdir)/../bfd =20 +AM_CFLAGS =3D $(WARN_CFLAGS) $(WERROR_CFLAGS) noinst_LIBRARIES =3D libgdbsupport.a @SELFTEST_TRUE@selftest =3D selftest.c libgdbsupport_a_SOURCES =3D \ diff --git a/gdbsupport/acinclude.m4 b/gdbsupport/acinclude.m4 index fe08bb36fe0b..3598b201b94b 100644 --- a/gdbsupport/acinclude.m4 +++ b/gdbsupport/acinclude.m4 @@ -5,3 +5,6 @@ m4_include([../gdb/ax_cxx_compile_stdcxx.m4]) m4_include([../gdb/libiberty.m4]) m4_include([../gdb/selftest.m4]) m4_include([../gdb/ptrace.m4]) + +dnl This gets AM_GDB_WARNINGS. +m4_include(../gdb/warning.m4) diff --git a/gdbsupport/configure b/gdbsupport/configure index cf943e69ef5c..197749b5d0ca 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -624,6 +624,8 @@ ac_subst_vars=3D'am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +WERROR_CFLAGS +WARN_CFLAGS SELFTEST_FALSE SELFTEST_TRUE LTLIBIPT @@ -769,6 +771,9 @@ with_gnu_ld enable_rpath with_libipt_prefix enable_unit_tests +enable_werror +enable_build_warnings +enable_gdb_build_warnings ' ac_precious_vars=3D'build_alias host_alias @@ -1415,6 +1420,11 @@ Optional Features: --disable-rpath do not hardcode runtime library paths --enable-unit-tests Enable the inclusion of unit tests when compiling GDB + --enable-werror treat compile warnings as errors + --enable-build-warnings enable build-time compiler warnings if gcc is us= ed + --enable-gdb-build-warnings + enable GDB specific build-time compiler warnings= if + gcc is used =20 Optional Packages: --with-PACKAGE[=3DARG] use PACKAGE [ARG=3Dyes] @@ -10806,6 +10816,190 @@ _ACEOF fi =20 =20 +# Detect support warning flags. + +# Check whether --enable-werror was given. +if test "${enable_werror+set}" =3D set; then : + enableval=3D$enable_werror; case "${enableval}" in + yes | y) ERROR_ON_WARNING=3D"yes" ;; + no | n) ERROR_ON_WARNING=3D"no" ;; + *) as_fn_error $? "bad value ${enableval} for --enable-werror" "$LINE= NO" 5 ;; + esac +fi + + +# Enable -Werror by default when using gcc. Turn it off for releases. +if test "${GCC}" =3D yes -a -z "${ERROR_ON_WARNING}" && $development; then + ERROR_ON_WARNING=3Dyes +fi + +WERROR_CFLAGS=3D"" +if test "${ERROR_ON_WARNING}" =3D yes ; then + WERROR_CFLAGS=3D"-Werror" +fi + +# The options we'll try to enable. +build_warnings=3D"-Wall -Wpointer-arith \ +-Wno-unused -Wunused-value -Wunused-variable -Wunused-function \ +-Wno-switch -Wno-char-subscripts \ +-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \ +-Wno-sign-compare -Wno-error=3Dmaybe-uninitialized \ +-Wno-mismatched-tags \ +-Wno-error=3Ddeprecated-register \ +-Wsuggest-override \ +-Wimplicit-fallthrough=3D3 \ +-Wduplicated-cond \ +-Wshadow=3Dlocal \ +-Wdeprecated-copy \ +-Wdeprecated-copy-dtor \ +-Wredundant-move \ +-Wmissing-declarations" + +case "${host}" in + *-*-mingw32*) + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. + build_warnings=3D"$build_warnings -Wno-format" ;; + *-*-solaris*) + # Solaris 11.4 uses #pragma no_inline that GCC + # doesn't understand. + build_warnings=3D"$build_warnings -Wno-unknown-pragmas" + # Solaris 11 marks vfork deprecated. + build_warnings=3D"$build_warnings -Wno-deprecated-declarations" ;; + *) + # Note that gcc requires -Wformat for -Wformat-nonliteral to work, + # but there's a special case for this below. + build_warnings=3D"$build_warnings -Wformat-nonliteral" ;; +esac + +# Check whether --enable-build-warnings was given. +if test "${enable_build_warnings+set}" =3D set; then : + enableval=3D$enable_build_warnings; case "${enableval}" in + yes) ;; + no) build_warnings=3D"-w";; + ,*) t=3D`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings=3D"${build_warnings} ${t}";; + *,) t=3D`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings=3D"${t} ${build_warnings}";; + *) build_warnings=3D`echo "${enableval}" | sed -e "s/,/ /g"`;; +esac +if test x"$silent" !=3D x"yes" && test x"$build_warnings" !=3D x""; then + echo "Setting compiler warning flags =3D $build_warnings" 6>&1 +fi +fi +# Check whether --enable-gdb-build-warnings was given. +if test "${enable_gdb_build_warnings+set}" =3D set; then : + enableval=3D$enable_gdb_build_warnings; case "${enableval}" in + yes) ;; + no) build_warnings=3D"-w";; + ,*) t=3D`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings=3D"${build_warnings} ${t}";; + *,) t=3D`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings=3D"${t} ${build_warnings}";; + *) build_warnings=3D`echo "${enableval}" | sed -e "s/,/ /g"`;; +esac +if test x"$silent" !=3D x"yes" && test x"$build_warnings" !=3D x""; then + echo "Setting GDB specific compiler warning flags =3D $build_warnings" 6= >&1 +fi +fi + +# The set of warnings supported by a C++ compiler is not the same as +# of the C compiler. +ac_ext=3Dcpp +ac_cpp=3D'$CXXCPP $CPPFLAGS' +ac_compile=3D'$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link=3D'$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftes= t.$ac_ext $LIBS >&5' +ac_compiler_gnu=3D$ac_cv_cxx_compiler_gnu + + +WARN_CFLAGS=3D"" +if test "x${build_warnings}" !=3D x -a "x$GCC" =3D xyes +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning fla= gs" >&5 +$as_echo_n "checking compiler warning flags... " >&6; } + # Separate out the -Werror flag as some files just cannot be + # compiled with it enabled. + for w in ${build_warnings}; do + # GCC does not complain about -Wno-unknown-warning. Invert + # and test -Wunknown-warning instead. + case $w in + -Wno-*) + wtest=3D`echo $w | sed 's/-Wno-/-W/g'` ;; + -Wformat-nonliteral) + # gcc requires -Wformat before -Wformat-nonliteral + # will work, so stick them together. + w=3D"-Wformat $w" + wtest=3D"$w" + ;; + *) + wtest=3D$w ;; + esac + + case $w in + -Werr*) WERROR_CFLAGS=3D-Werror ;; + *) + # Check whether GCC accepts it. + saved_CFLAGS=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS -Werror $wtest" + saved_CXXFLAGS=3D"$CXXFLAGS" + CXXFLAGS=3D"$CXXFLAGS -Werror $wtest" + if test "x$w" =3D "x-Wunused-variable"; then + # Check for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D38958, + # fixed in GCC 4.9. This test is derived from the gdb + # source code that triggered this bug in GCC. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +struct scoped_restore_base {}; + struct scoped_restore_tmpl : public scoped_restore_base { + ~scoped_restore_tmpl() {} + }; +int +main () +{ +const scoped_restore_base &b =3D scoped_restore_tmpl(); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + WARN_CFLAGS=3D"${WARN_CFLAGS} $w" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + WARN_CFLAGS=3D"${WARN_CFLAGS} $w" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + CFLAGS=3D"$saved_CFLAGS" + CXXFLAGS=3D"$saved_CXXFLAGS" + esac + done + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERR= OR_CFLAGS}" >&5 +$as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; } +fi + + + +ac_ext=3Dc +ac_cpp=3D'$CPP $CPPFLAGS' +ac_compile=3D'$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link=3D'$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$= ac_ext $LIBS >&5' +ac_compiler_gnu=3D$ac_cv_c_compiler_gnu + + + TARGET_WORD_SIZE=3D`sed -n 's,#define BFD_ARCH_SIZE \(.*\)$,\1,p' ../bfd/b= fd-in3.h` =20 cat >>confdefs.h <<_ACEOF diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac index 6002871c9691..401e16f821da 100644 --- a/gdbsupport/configure.ac +++ b/gdbsupport/configure.ac @@ -48,6 +48,9 @@ AM_CONDITIONAL(SELFTEST, $enable_unittests) # Check the return and argument types of ptrace. GDB_AC_PTRACE =20 +# Detect support warning flags. +AM_GDB_WARNINGS + TARGET_WORD_SIZE=3D`sed -n 's,#define BFD_ARCH_SIZE \(.*\)$,\1,p' ../bfd/b= fd-in3.h` AC_DEFINE_UNQUOTED(TARGET_WORD_SIZE, $TARGET_WORD_SIZE, [Define to the word size for the target.]) --=20 2.25.0