all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Gramiak <agrambot@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-devel@gnu.org
Subject: Re: Checking all C warning flags at once during configuration
Date: Wed, 01 May 2019 12:25:52 -0600	[thread overview]
Message-ID: <87tveem3pr.fsf@gmail.com> (raw)
In-Reply-To: <2e406efe-73ef-e1a8-ae87-01ca0f88eea8@cs.ucla.edu> (Paul Eggert's message of "Tue, 30 Apr 2019 12:38:21 -0700")

[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]

Paul Eggert <eggert@cs.ucla.edu> writes:

> On 4/30/19 11:52 AM, Alex Gramiak wrote:
>> Is this salvageable?
>
> It's a start. It's probably useful info for someone needing to write a
> patch. However, I expect that the patch should be against Gnulib, not
> against Emacs, as all programs (not just Emacs) could use the acceleration.

Right, I'm just using Emacs as a testing ground first. Should I post
this to the Gnulib mailing list at this stage?

m4_errprintn tells me that for some reason $1 of gl_WARN_ADD is empty
when using it inside the loop, which doesn't make sense to me since I'm
using it the same way that it's used in configure.ac. Even trying to
pass it a constant string results in an empty first argument.

I inlined (part of) the definition of gl_WARN_ADD and somehow that makes
it work. I tested with a nonexistent flag and a combination of
gl_WARN_ADD_NOCHECK and gl_WARN_ADD; both worked as expected.

Would you happen to know why the argument is always empty in the
commented out loop?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nocheck v2 --]
[-- Type: text/x-patch, Size: 5877 bytes --]

diff --git a/configure.ac b/configure.ac
index 79fe0c98c6..cc1385710d 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_UNCHECKED
+
 # 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..296bcf01c8 100644
--- a/m4/warnings.m4
+++ b/m4/warnings.m4
@@ -49,6 +49,62 @@ AC_DEFUN
 AS_VAR_POPDEF([gl_Warn])dnl
 ])
 
+# gl_COMPILER_OPTIONS_CHECK_UNCHECKED([VARIABLE = WARN_CFLAGS/WARN_CXXFLAGS],
+#                                     [PROGRAM = AC_LANG_PROGRAM()])
+# -----------------------------------------------------------------
+# Check if the compiler supports options added by gl_WARN_ADD_NOCHECK
+# when compiling PROGRAM.
+#
+# The effects of this macro depend on the current language (_AC_LANG).
+AC_DEFUN([gl_COMPILER_OPTIONS_CHECK_UNCHECKED],
+[
+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"])],
+          [for gl_warn_item in $gl_warnings; do
+             gl_COMPILER_OPTION_IF([$gl_warn_item],
+  [gl_AS_VAR_APPEND(m4_if([$1], [], [[WARN_]_AC_LANG_PREFIX[FLAGS]], [[$1]]), [" $gl_warn_item"])],
+  [],
+  [$2])
+           done
+          ]
+          dnl [for gl_warn_item in $gl_warnings; do
+          dnl    gl_WARN_ADD ([$gl_warn_item])
+          dnl  done
+          dnl ]
+          )
+m4_popdef([gl_Positives])dnl
+AS_VAR_POPDEF([gl_warnings])dnl
+AS_VAR_POPDEF([gl_Flags])dnl
+AS_VAR_POPDEF([gl_Warn])dnl
+m4_ifval([$1],
+         [AS_LITERAL_IF([$1], [AC_SUBST([$1])])],
+         [AC_SUBST([WARN_]_AC_LANG_PREFIX[FLAGS])])dnl
+])
+
 # gl_UNKNOWN_WARNINGS_ARE_ERRORS
 # ------------------------------
 # Clang doesn't complain about unknown warning options unless one also
@@ -110,6 +166,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:

  reply	other threads:[~2019-05-01 18:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29 14:53 Checking all C warning flags at once during configuration Alex Gramiak
2019-04-29 19:39 ` Paul Eggert
2019-04-30 18:52   ` Alex Gramiak
2019-04-30 19:38     ` Paul Eggert
2019-05-01 18:25       ` Alex Gramiak [this message]
2019-05-01 18:31         ` Paul Eggert
2019-05-01 23:13           ` Alex Gramiak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tveem3pr.fsf@gmail.com \
    --to=agrambot@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.