summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-09-21 17:09:22 -0400
committerZack Weinberg <zackw@panix.com>2020-09-22 15:46:44 -0400
commitedcb0925a54cc7bd96e444925aa8fa1e9294b713 (patch)
tree9007a68b7a73b895833c8a0ae5cb6d1ac16c91c0
parent218cc1e49224765788aa368fe4a2e27c6652df5d (diff)
downloadautoconf-edcb0925a54cc7bd96e444925aa8fa1e9294b713.tar.gz
Use WARNINGS to pass down warnings options from autoreconf.
autoreconf runs a bunch of subsidiary tools, and is expected to pass along various command-line settings, such as those controlling warnings. It has historically done this via the command line. However, not all of the tools recognize the same set of command-line warnings options. There’s an existing check for whether aclocal and automake understand ‘--warnings’ at all, but it currently assumes that automake will accept the same set of warnings *categories* that autoconf does. This hasn’t actually been true for many years and is known to cause problems; see the discussion starting at <https://lists.gnu.org/archive/html/autoconf/2020-09/msg00000.html>. Previous patches in this series (and related patches applied to automake) have restored agreement between the current development trunks of the two sets of tools on the set of warnings categories, but we still need to deal with the possibility of the *installed* tools not being in agreement. If we use the WARNINGS environment variable to pass down warnings options, instead of the command line, then all the tools are already coded to ignore unknown warning categories, and this ceases to be an issue. And we no longer need the check for ‘--warnings’ support in automake, either. Also, autoreconf as well should suppress warnings from its first invocation of autoconf, which is for tracing purposes only and may emit spurious warnings because aclocal.m4 is not yet in place. * bin/autoreconf.in ($aclocal_supports_warnings, $automake_supports_warnings): Delete. (@warning): Make local to sub parse_args. (parse_args): Do not add --warnings options to $autoconf, $autoheader, $aclocal, or $automake. Instead, set $ENV{WARNINGS} appropriately. No longer necessary to probe for --warnings support from aclocal and automake. (autoreconf_current_directory): Set $ENV{WARNINGS} temporarily to “none” when running autoconf in trace mode. Fix typo in comment. Close $traces immediately after we’re done with it. * tests/torture.at (Specific warnings options for autoreconf): New test.
-rw-r--r--bin/autoreconf.in85
-rw-r--r--tests/torture.at47
2 files changed, 88 insertions, 44 deletions
diff --git a/bin/autoreconf.in b/bin/autoreconf.in
index 80185ba9..2ea917b5 100644
--- a/bin/autoreconf.in
+++ b/bin/autoreconf.in
@@ -126,17 +126,10 @@ my $make = $ENV{'MAKE'} || 'make';
my $install = 0;
# symlink -- when --install, use symlinks instead.
my $symlink = 0;
-# Does aclocal support -Wfoo?
-my $aclocal_supports_warnings = 0;
-# Does automake support -Wfoo?
-my $automake_supports_warnings = 0;
my @prepend_include;
my @include;
-# List of command line warning requests.
-my @warning;
-
# Rerun './configure && make'?
my $run_make = 0;
@@ -155,6 +148,9 @@ sub parse_args ()
{
my $srcdir;
+ # List of command line warning requests.
+ my @warning;
+
getopt ("W|warnings=s" => \@warning,
'I|include=s' => \@include,
'B|prepend-include=s' => \@prepend_include,
@@ -190,11 +186,6 @@ sub parse_args ()
}
}
- my $aclocal_help = `$aclocal --help 2>/dev/null`;
- my $automake_help = `$automake --help 2>/dev/null`;
- $aclocal_supports_warnings = $aclocal_help =~ /--warnings/;
- $automake_supports_warnings = $automake_help =~ /--warnings/;
-
# Dispatch autoreconf's option to the tools.
# --include;
$aclocal .= join (' -I ', '', map { shell_quote ($_) } @include);
@@ -241,17 +232,15 @@ sub parse_args ()
$autoheader .= ' --debug';
$libtoolize .= ' --debug';
}
- # --warnings;
- if (@warning)
- {
- my $warn = ' --warnings=' . join (',', @warning);
- $autoconf .= $warn;
- $autoheader .= $warn;
- $automake .= $warn
- if $automake_supports_warnings;
- $aclocal .= $warn
- if $aclocal_supports_warnings;
- }
+
+ # Pass down warnings via the WARNINGS environment variable, instead
+ # of via --warnings, so that unrecognized warning categories are
+ # silently ignored. We already issued diagnostics about warning
+ # categories *we* don't recognize; older subsidiary tools may not
+ # know all of them, and may treat unrecognized warning categories on
+ # the command line as a fatal error when -Werror is in effect.
+ $ENV{WARNINGS} = merge_WARNINGS @warning;
+ verb "export WARNINGS=$ENV{WARNINGS}";
}
@@ -297,7 +286,7 @@ sub autoreconf_current_directory ($)
# ------------------- #
# Gettext is a bit of a problem: its macros are not necessarily
- # visible to aclocal, so if we start with a completely striped down
+ # visible to aclocal, so if we start with a completely stripped down
# package (think of a fresh CVS checkout), running 'aclocal' first
# will fail: the Gettext macros are missing.
#
@@ -397,6 +386,9 @@ sub autoreconf_current_directory ($)
# Perform a single trace reading to avoid --force forcing a rerun
# between two --trace, that's useless. If there is no AC_INIT, then
# we are not interested: it looks like a Cygnus thingy.
+ # Suppress all warnings from this invocation; they may be spurious
+ # due to out-of-date files, and in any case they'll duplicate warnings
+ # from the final autoconf invocation.
my $aux_dir;
my $uses_gettext_via_traces;
my $uses_libtool;
@@ -406,27 +398,31 @@ sub autoreconf_current_directory ($)
my $uses_autoheader;
my $uses_automake;
my @subdir;
+ my $traces;
verb "$configure_ac: tracing";
- my $traces = new Autom4te::XFile
- ("$autoconf"
- . join (' ',
- map { ' --trace=' . $_ . ':\$n::\${::}%' }
- # If you change this list, update the
- # 'Autoreconf-preselections' section of autom4te.in.
- 'AC_CONFIG_AUX_DIR',
- 'AC_CONFIG_HEADERS',
- 'AC_CONFIG_SUBDIRS',
- 'AC_INIT',
- 'AC_PROG_LIBTOOL',
- 'AM_PROG_LIBTOOL',
- 'LT_INIT',
- 'LT_CONFIG_LTDL_DIR',
- 'AM_GNU_GETTEXT',
- 'AM_INIT_AUTOMAKE',
- 'IT_PROG_INTLTOOL',
- 'GTK_DOC_CHECK',
- )
- . ' |');
+ {
+ local $ENV{WARNINGS} = 'none';
+ $traces = new Autom4te::XFile
+ ("$autoconf"
+ . join (' ',
+ map { ' --trace=' . $_ . ':\$n::\${::}%' }
+ # If you change this list, update the
+ # 'Autoreconf-preselections' section of autom4te.in.
+ 'AC_CONFIG_AUX_DIR',
+ 'AC_CONFIG_HEADERS',
+ 'AC_CONFIG_SUBDIRS',
+ 'AC_INIT',
+ 'AC_PROG_LIBTOOL',
+ 'AM_PROG_LIBTOOL',
+ 'LT_INIT',
+ 'LT_CONFIG_LTDL_DIR',
+ 'AM_GNU_GETTEXT',
+ 'AM_INIT_AUTOMAKE',
+ 'IT_PROG_INTLTOOL',
+ 'GTK_DOC_CHECK',
+ )
+ . ' |');
+ }
while ($_ = $traces->getline)
{
chomp;
@@ -445,6 +441,7 @@ sub autoreconf_current_directory ($)
push @subdir, split (' ', $args[0])
if $macro eq "AC_CONFIG_SUBDIRS" && $recursive;
}
+ $traces->close;
# The subdirs are *optional*, they may not exist.
foreach (@subdir)
diff --git a/tests/torture.at b/tests/torture.at
index 82706d34..ff0f53f3 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -1857,3 +1857,50 @@ AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
AT_CHECK([test -f HeeHee.in])
AT_CLEANUP
+
+## ------------------------------ ##
+## Specific warnings options. ##
+## ------------------------------ ##
+
+AT_SETUP([Specific warnings options for autoreconf])
+AT_KEYWORDS([autoreconf])
+
+# If autoreconf is given a -W option that's mentioned in its own
+# --help output, that option should not cause errors, even if some
+# of the subsidiary programs don't support it.
+
+# We use aclocal and automake via autoreconf.
+AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT(GNU foo, 1.0)
+AM_INIT_AUTOMAKE
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.am],
+[[AUTOMAKE_OPTIONS = foreign
+]])
+
+# To silence complaints about required helper scripts from automake.
+# We aren't going to run the generated Makefile so we don't need the
+# real helper scripts.
+AT_DATA([install-sh], [])
+AT_DATA([missing], [])
+
+# In order to cut down the time this test takes, we do not test all
+# of the supported warning categories, just the most common case
+# (-Wall) and some specific categories that are known to have been a
+# problem in the past.
+AT_CHECK([autoreconf -Werror -Wall], 0, [], [])
+rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
+
+AT_CHECK([autoreconf -Werror -Wcross], 0, [], [])
+rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
+
+AT_CHECK([autoreconf -Werror -Wportability-recursive], 0, [], [])
+rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
+
+AT_CLEANUP