From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.devel Subject: Re: Checking all C warning flags at once during configuration Date: Tue, 30 Apr 2019 12:52:21 -0600 Message-ID: <87y33rmil6.fsf@gmail.com> References: <87d0l4ooah.fsf@gmail.com> <55b92b63-d99d-fd5d-f6f0-58d8aec57f6a@cs.ucla.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="32461"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 30 20:59:04 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLXy3-0008J4-PE for ged-emacs-devel@m.gmane.org; Tue, 30 Apr 2019 20:59:03 +0200 Original-Received: from localhost ([127.0.0.1]:51797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLXy2-0003FP-NW for ged-emacs-devel@m.gmane.org; Tue, 30 Apr 2019 14:59:02 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLXws-00038m-Jk for emacs-devel@gnu.org; Tue, 30 Apr 2019 14:57:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLXra-0000Lh-FA for emacs-devel@gnu.org; Tue, 30 Apr 2019 14:52:23 -0400 Original-Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:38245) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLXra-0000Jc-3b for emacs-devel@gnu.org; Tue, 30 Apr 2019 14:52:22 -0400 Original-Received: by mail-pg1-x535.google.com with SMTP id j26so7262017pgl.5 for ; Tue, 30 Apr 2019 11:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=i4sekQPs9ymrvB5lVvZ7uSrsSRY17p52g6qMK03OfMM=; b=KYbKIUz3OZBIFHXdPi/7kbjNvi+BqFTLhG/FYDU5KgQONzKZBR1blkFeHCUonRWoqw Vyy/5n9rVkgf/CmjMXd5/O1h4qWcNq96/ft5Zi6RScbNy3UOTy3wK5lZ+Gyj7XDo9B5o Uv8eYn6pwN/MkqVpHMGHQu82idD456Nq7CIFjB0hhnx98S0mm6dOA7Pj0CIqXQjWvArB DatZ5qUTkcAtXxUB+S+ecS/5BkZTTlCSj1uRK9V+mmos/n8SJsMePJVZKSp26kyLSL1f 6juMWRu5Ft4Jer2jZQAeJKXB/s8zrB8yvADkdfmzIAogHsbXv6wIbwcFzLMAwyMktHQf nH9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=i4sekQPs9ymrvB5lVvZ7uSrsSRY17p52g6qMK03OfMM=; b=qAmzdMpoF3SF7o0YOpW3iH21IIY09dVNdV+dbFYbWnT/BA0qjJtIIkOj1xku1Cphtd Q6jOQU9Xm4FjS2S4Non4w5U1Wg5uGCiMd/OQ8FTAHLdmAq9ASkqfptt4a1Q8fgAUkIwJ pYlda2+Y4cXFzvSwi/uiYUVj0Y0RKkdIb5bnrw7TLAVyHT9+OqPOkfDFGDxTuL3qJIPh 95ue2YKay9nzXpGeBt+FgXaNFizTBeRsv/4wZoG46dYpYJCFEdvk0AZjIyeJR73jDTQd amvI6zy0bMPQLS677OKwUROdv9msaJFrN5nSzre7MIjmJs02JjPgqUb7KtQqyx9HsiPl bOqQ== X-Gm-Message-State: APjAAAU73LCbu5SnperFE1Q0AepQPEM6TKJ6C68k98vdQrWFaz5d+Sq/ iSBnHUIXVaBntUUyQw75NutZg149 X-Google-Smtp-Source: APXvYqyH37/gTAU1Y88liw0IAjfMsxSzpdXCmIWHs2Rul/gKwPvjar+XxQqVtT3ME3Y7VBuB8qTI/g== X-Received: by 2002:a65:60ca:: with SMTP id r10mr4137386pgv.64.1556650339918; Tue, 30 Apr 2019 11:52:19 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id d20sm48305971pfo.77.2019.04.30.11.52.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2019 11:52:18 -0700 (PDT) In-Reply-To: <55b92b63-d99d-fd5d-f6f0-58d8aec57f6a@cs.ucla.edu> (Paul Eggert's message of "Mon, 29 Apr 2019 12:39:10 -0700") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::535 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236066 Archived-At: --=-=-= Content-Type: text/plain Paul Eggert writes: > On 4/29/19 7:53 AM, Alex Gramiak wrote: >> would it make sense to first check _all_ (or, at least the >> commonly supported) warning flags simultaneously and then only check >> them individually if there was an error? > > Sure. That would be a nice thing to add to Gnulib (which is the upstream > source for this). Evidently I don't know enough autoconf to be able to do this myself, since I couldn't figure out how to implement the fallback behaviour. I've included a diff below that implements multiple-checking (~29s to ~22s configure time for me), with a faulty loop in the else clause commented out. Is this salvageable? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=warn-nocheck.diff Content-Description: nocheck diff --git a/configure.ac b/configure.ac index 79fe0c98c6..0be51e0236 100644 --- a/configure.ac +++ b/configure.ac @@ -1011,10 +1011,10 @@ AC_DEFUN AS_IF([test "$emacs_cv_clang" = yes], [ # Turn off some warnings if supported. - gl_WARN_ADD([-Wno-switch]) - gl_WARN_ADD([-Wno-pointer-sign]) - gl_WARN_ADD([-Wno-string-plus-int]) - gl_WARN_ADD([-Wno-unknown-attributes]) + gl_WARN_ADD_NOCHECK([-Wno-switch]) + gl_WARN_ADD_NOCHECK([-Wno-pointer-sign]) + gl_WARN_ADD_NOCHECK([-Wno-string-plus-int]) + gl_WARN_ADD_NOCHECK([-Wno-unknown-attributes]) ]) ],[ isystem='-isystem ' @@ -1091,25 +1091,25 @@ AC_DEFUN gl_MANYWARN_ALL_GCC([ws]) gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw]) for w in $ws; do - gl_WARN_ADD([$w]) + gl_WARN_ADD_NOCHECK([$w]) done - gl_WARN_ADD([-Wredundant-decls]) # Prefer this, as we don't use Bison. - gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one - gl_WARN_ADD([-Wno-override-init]) # More trouble than it is worth - gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now - gl_WARN_ADD([-Wno-type-limits]) # Too many warnings for now - gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now - gl_WARN_ADD([-Wno-format-nonliteral]) + gl_WARN_ADD_NOCHECK([-Wredundant-decls]) # Prefer this, as we don't use Bison. + gl_WARN_ADD_NOCHECK([-Wno-missing-field-initializers]) # We need this one + gl_WARN_ADD_NOCHECK([-Wno-override-init]) # More trouble than it is worth + gl_WARN_ADD_NOCHECK([-Wno-sign-compare]) # Too many warnings for now + gl_WARN_ADD_NOCHECK([-Wno-type-limits]) # Too many warnings for now + gl_WARN_ADD_NOCHECK([-Wno-unused-parameter]) # Too many warnings for now + gl_WARN_ADD_NOCHECK([-Wno-format-nonliteral]) # clang is unduly picky about some things. if test "$emacs_cv_clang" = yes; then - gl_WARN_ADD([-Wno-missing-braces]) - gl_WARN_ADD([-Wno-null-pointer-arithmetic]) + gl_WARN_ADD_NOCHECK([-Wno-missing-braces]) + gl_WARN_ADD_NOCHECK([-Wno-null-pointer-arithmetic]) fi # This causes too much noise in the MinGW build if test $opsys = mingw32; then - gl_WARN_ADD([-Wno-pointer-sign]) + gl_WARN_ADD_NOCHECK([-Wno-pointer-sign]) fi AC_DEFINE([GCC_LINT], [1], [Define to 1 if --enable-gcc-warnings.]) @@ -1127,11 +1127,13 @@ AC_DEFUN # clang is picky about these regardless of whether # --enable-gcc-warnings is specified. if test "$emacs_cv_clang" = yes; then - gl_WARN_ADD([-Wno-initializer-overrides]) - gl_WARN_ADD([-Wno-tautological-compare]) - gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare]) + gl_WARN_ADD_NOCHECK([-Wno-initializer-overrides]) + gl_WARN_ADD_NOCHECK([-Wno-tautological-compare]) + gl_WARN_ADD_NOCHECK([-Wno-tautological-constant-out-of-range-compare]) fi +gl_COMPILER_OPTIONS_CHECK + # Use a slightly smaller set of warning options for lib/. nw= nw="$nw -Wunused-macros" diff --git a/m4/warnings.m4 b/m4/warnings.m4 index 235cac6171..4d8831cd59 100644 --- a/m4/warnings.m4 +++ b/m4/warnings.m4 @@ -49,6 +49,53 @@ AC_DEFUN AS_VAR_POPDEF([gl_Warn])dnl ]) +# gl_COMPILER_OPTIONS_CHECK([VARIABLE = WARN_CFLAGS/WARN_CXXFLAGS], +# [PROGRAM = AC_LANG_PROGRAM()]) +# ----------------------------------------------------------------- +# Check if the compiler supports OPTIONS when compiling PROGRAM. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_COMPILER_OPTIONS_CHECK], +[ +dnl FIXME: gl_Warn must be used unquoted until we can assume Autoconf +dnl 2.64 or newer. +AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl +AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl +AS_VAR_PUSHDEF([gl_warnings], [[WARN_]_AC_LANG_PREFIX[FLAGS_ONCE]])dnl +gl_positives= +for gl_warn_item in $gl_warnings; do + case $gl_warn_item in + -Wno-*) gl_positives="$gl_positives -W`expr "X$gl_warn_item" : 'X-Wno-\(.*\)'`" ;; + *) gl_positives="$gl_positives $gl_warn_item" + esac +done +m4_pushdef([gl_Positives], [$gl_positives])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler handles $gl_warnings], m4_defn([gl_Warn]), [ + gl_save_compiler_FLAGS="$gl_Flags" + gl_AS_VAR_APPEND(m4_defn([gl_Flags]), + [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positives])["]) + AC_LINK_IFELSE([m4_default([$2], [AC_LANG_PROGRAM([])])], + [AS_VAR_SET(gl_Warn, [yes])], + [AS_VAR_SET(gl_Warn, [no])]) + gl_Flags="$gl_save_compiler_FLAGS" +]) +AS_VAR_IF(gl_Warn, + [yes], + [gl_AS_VAR_APPEND(m4_if([$1], [], [[WARN_]_AC_LANG_PREFIX[FLAGS]], [[$1]]), + [" $gl_warnings"])], + dnl [for gl_warn_item in $gl_warnings; do + dnl gl_WARN_ADD (gl_warn_item, [$1], [$2]) + dnl done + dnl ] + [echo ":("] + ) +m4_popdef([gl_Positives])dnl +AS_VAR_POPDEF([gl_warnings])dnl +AS_VAR_POPDEF([gl_Flags])dnl +AS_VAR_POPDEF([gl_Warn])dnl +AC_SUBST([WARN_]_AC_LANG_PREFIX[FLAGS]) +]) + # gl_UNKNOWN_WARNINGS_ARE_ERRORS # ------------------------------ # Clang doesn't complain about unknown warning options unless one also @@ -110,6 +157,11 @@ AC_DEFUN [AC_SUBST([WARN_]_AC_LANG_PREFIX[FLAGS])])dnl ]) +AC_DEFUN([gl_WARN_ADD_NOCHECK], +[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS(]_AC_LANG[)]) +gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_]_AC_LANG_PREFIX[FLAGS_ONCE]], [[$2]]), [" $1"]) +]) + # Local Variables: # mode: autoconf # End: --=-=-=--