From patchwork Mon Feb 10 16:40:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 37856 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-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@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 11:40:22 -0500 Message-Id: <20200210164024.32445-1-simon.marchi@efficios.com> MIME-Version: 1.0 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 += $(CXX_DIALECT) override CC := $(CXX) override CFLAGS := $(CXXFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) + noinst_LIBRARIES = libgdbsupport.a 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 = $(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 = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ @@ -287,6 +288,8 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WERROR_CFLAGS = @WERROR_CFLAGS@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -350,6 +353,7 @@ AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../gdb \ -I../gnulib/import -I$(srcdir)/../gnulib/import \ -I.. -I$(srcdir)/.. $(INCINTL) -I../bfd -I$(srcdir)/../bfd +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) noinst_LIBRARIES = libgdbsupport.a @SELFTEST_TRUE@selftest = selftest.c libgdbsupport_a_SOURCES = \ 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='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='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 used + --enable-gdb-build-warnings + enable GDB specific build-time compiler warnings if + gcc is used Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -10806,6 +10816,190 @@ _ACEOF fi +# Detect support warning flags. + +# Check whether --enable-werror was given. +if test "${enable_werror+set}" = set; then : + enableval=$enable_werror; case "${enableval}" in + yes | y) ERROR_ON_WARNING="yes" ;; + no | n) ERROR_ON_WARNING="no" ;; + *) as_fn_error $? "bad value ${enableval} for --enable-werror" "$LINENO" 5 ;; + esac +fi + + +# Enable -Werror by default when using gcc. Turn it off for releases. +if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then + ERROR_ON_WARNING=yes +fi + +WERROR_CFLAGS="" +if test "${ERROR_ON_WARNING}" = yes ; then + WERROR_CFLAGS="-Werror" +fi + +# The options we'll try to enable. +build_warnings="-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=maybe-uninitialized \ +-Wno-mismatched-tags \ +-Wno-error=deprecated-register \ +-Wsuggest-override \ +-Wimplicit-fallthrough=3 \ +-Wduplicated-cond \ +-Wshadow=local \ +-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="$build_warnings -Wno-format" ;; + *-*-solaris*) + # Solaris 11.4 uses #pragma no_inline that GCC + # doesn't understand. + build_warnings="$build_warnings -Wno-unknown-pragmas" + # Solaris 11 marks vfork deprecated. + build_warnings="$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="$build_warnings -Wformat-nonliteral" ;; +esac + +# Check whether --enable-build-warnings was given. +if test "${enable_build_warnings+set}" = set; then : + enableval=$enable_build_warnings; case "${enableval}" in + yes) ;; + no) build_warnings="-w";; + ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings="${build_warnings} ${t}";; + *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings="${t} ${build_warnings}";; + *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; +esac +if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then + echo "Setting compiler warning flags = $build_warnings" 6>&1 +fi +fi +# Check whether --enable-gdb-build-warnings was given. +if test "${enable_gdb_build_warnings+set}" = set; then : + enableval=$enable_gdb_build_warnings; case "${enableval}" in + yes) ;; + no) build_warnings="-w";; + ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings="${build_warnings} ${t}";; + *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` + build_warnings="${t} ${build_warnings}";; + *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; +esac +if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then + echo "Setting GDB specific compiler warning flags = $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=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +WARN_CFLAGS="" +if test "x${build_warnings}" != x -a "x$GCC" = xyes +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning flags" >&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=`echo $w | sed 's/-Wno-/-W/g'` ;; + -Wformat-nonliteral) + # gcc requires -Wformat before -Wformat-nonliteral + # will work, so stick them together. + w="-Wformat $w" + wtest="$w" + ;; + *) + wtest=$w ;; + esac + + case $w in + -Werr*) WERROR_CFLAGS=-Werror ;; + *) + # Check whether GCC accepts it. + saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror $wtest" + saved_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -Werror $wtest" + if test "x$w" = "x-Wunused-variable"; then + # Check for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38958, + # 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 = scoped_restore_tmpl(); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + WARN_CFLAGS="${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="${WARN_CFLAGS} $w" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + CFLAGS="$saved_CFLAGS" + CXXFLAGS="$saved_CXXFLAGS" + esac + done + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5 +$as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; } +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + TARGET_WORD_SIZE=`sed -n 's,#define BFD_ARCH_SIZE \(.*\)$,\1,p' ../bfd/bfd-in3.h` 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 +# Detect support warning flags. +AM_GDB_WARNINGS + TARGET_WORD_SIZE=`sed -n 's,#define BFD_ARCH_SIZE \(.*\)$,\1,p' ../bfd/bfd-in3.h` AC_DEFINE_UNQUOTED(TARGET_WORD_SIZE, $TARGET_WORD_SIZE, [Define to the word size for the target.])