autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 2/3] Use WARNINGS=none to suppress warnings from autom4te run


From: Zack Weinberg
Subject: [RFC PATCH 2/3] Use WARNINGS=none to suppress warnings from autom4te runs.
Date: Tue, 22 Sep 2020 16:34:33 -0400

aclocal uses autom4te in trace mode to scan configure.ac for macros whose
definition is not yet available.  It has a kludge to prevent this from
producing spurious warnings, but a cleaner, fully backward compatible, way to
get the same effect is to set WARNINGS=none in the environment and not pass
down any -W options.  (This is better than passing -Wnone on the command line
because it automatically inherits to any subprocesses started by autom4te.)

Perl’s ‘local’ feature can be used to make the enviironment variable setting
temporary, reverting to the previous value when we exit the function.

automake also runs autom4te (technically autoconf) in trace mode; warnings
from this invocation will not be *spurious*, but in the common case where
the person running automake is going to run autoconf next, they will be
duplicated.  Therefore, make the same change to automake.

* bin/aclocal.in (trace_used_macros)
* bin/automake.in (scan_autoconf_traces):
  Use “local $ENV{WARNINGS}='none'” to suppress warnings from autom4te.
---
 bin/aclocal.in  | 19 ++++++++-----------
 bin/automake.in |  7 ++++++-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/bin/aclocal.in b/bin/aclocal.in
index 42e8d839a..ca2f96324 100644
--- a/bin/aclocal.in
+++ b/bin/aclocal.in
@@ -762,22 +762,19 @@ sub trace_used_macros ()
   my %files = map { $map{$_} => 1 } keys %macro_seen;
   %files = strip_redundant_includes %files;
 
-  # When AC_CONFIG_MACRO_DIRS is used, avoid possible spurious warnings
-  # from autom4te about macros being "m4_require'd but not m4_defun'd";
-  # for more background, see:
-  # https://lists.gnu.org/archive/html/autoconf-patches/2012-11/msg00004.html
-  # as well as autoconf commit 'v2.69-44-g1ed0548', "warn: allow aclocal
-  # to silence m4_require warnings".
-  my $early_m4_code .= "m4_define([m4_require_silent_probe], [-])";
+  # Suppress all warnings from this invocation of autom4te.
+  # In particular we want to avoid spurious warnings about
+  # macros being "m4_require'd but not m4_defun'd" because
+  # aclocal.m4 is not yet available.
+  local $ENV{WARNINGS} = 'none';
 
   my $traces = ($ENV{AUTOM4TE} || '@am_AUTOM4TE@');
   $traces .= " --language Autoconf-without-aclocal-m4 ";
-  $traces = "echo '$early_m4_code' | $traces - ";
 
   # Support AC_CONFIG_MACRO_DIRS also with older autoconf.
   # Note that we can't use '$ac_config_macro_dirs_fallback' here, because
-  # a bug in option parsing code of autom4te 2.68 and earlier will cause
-  # it to read standard input last, even if the "-" argument is specified
+  # a bug in option parsing code of autom4te 2.68 and earlier would cause
+  # it to read standard input last, even if the "-" argument was specified
   # early.
   # FIXME: To be removed in Automake 2.0, once we can assume autoconf
   #        2.70 or later.
@@ -807,7 +804,7 @@ sub trace_used_macros ()
                   # characters (like newlines).
                   (map { "--trace='$_:\$f::\$n'" } (keys %macro_seen)));
 
-  verb "running $traces $configure_ac";
+  verb "running WARNINGS=$ENV{WARNINGS} $traces $configure_ac";
 
   my $tracefh = new Automake::XFile ("$traces $configure_ac |");
 
diff --git a/bin/automake.in b/bin/automake.in
index 67b729045..a88b835a5 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -5249,6 +5249,11 @@ sub scan_autoconf_traces
                sinclude => 1,
              );
 
+  # Suppress all warnings from this invocation of autoconf.
+  # The user is presumably about to run autoconf themselves
+  # and will see its warnings then.
+  local $ENV{WARNINGS} = 'none';
+
   my $traces = ($ENV{AUTOCONF} || '@am_AUTOCONF@') . " ";
 
   # Use a separator unlikely to be used, not ':', the default, which
@@ -5257,8 +5262,8 @@ sub scan_autoconf_traces
                   map { "--trace=$_" . ':\$f:\$l::\$d::\$n::\${::}%' }
                   (keys %traced));
 
+  verb "running WARNINGS=$ENV{WARNINGS} $traces";
   my $tracefh = new Automake::XFile ("$traces $filename |");
-  verb "reading $traces";
 
   @cond_stack = ();
   my $where;
-- 
2.28.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]