The minimum Perl version was raised to 5.8.0 from 5.6.0 in commit
3a9802d601 (but not documented as
such until e8c2d79ec4, and not
actually *enforced* by our own configure script until, er, now)
in order to use Time::HiRes::stat.
Unfortunately, while the Time::HiRes *module* was added in 5.8.0, it
did not export a ‘stat’ function until 5.8.9. More precisely, this
feature was added to Time::HiRes in version 1.92 of that module; Perl
core 5.8.8 shipped Time::HiRes 1.86, 5.8.9 shipped 1.9715. The only
system I have convenient access to, that has older Perls installed,
offers me a choice of 5.8.8 or 5.10.1, so the new requirement means
I cannot test with 5.8.x anymore.
Per https://perldoc.perl.org/perlhist the release history of these
versions of Perl is, in chronological order,
5.8.0 2002-Jul-18
5.8.8 2006-Jan-31
5.10.0 2007-Dec-18
5.8.9 2008-Dec-14 <-- almost a year later than 5.10.0
5.10.1 2009-Aug-22
5.12.0 2010-Apr-12
Per https://perldoc.perl.org/perl5101delta the differences between
5.10.0 and 5.10.1 are small, and do not make me worry about
accidentally introducing code that works on my test boxes but not for
our users, unlike the gulf between 5.8.x and 5.10.x.
Requiring 5.10 will mean that we have access to Digest::SHA, the //
and //= operators, the regexp \K escape, and ‘state’ variables
(lexical scope, persistent value) all of which I can think
of uses for (but none of them are actually used in this patch).
Putting it all together, I think a requirement bump to version 5.10.0
is justified. We are already chopping off the trailing edge at 2006
due to the requirement for M4 1.4.8 (/de facto/ since 2.70) and late
2007 is still 15 years ago.
This patch also makes configure search $PATH for executables named
‘perl5*’ and ‘perl-5.*’ if bare ‘perl’ is too old. To do this, it
introduces a helper macro AClocal_PATH_PROG_GLOBS_FEATURE_CHECK, which
I would *like* to promote to a new Autoconf feature, but I got stuck
on quoting issues — see comments in m4/perl-time-hires.m4.
* NEWS: Document requirement for Perl 5.10.
* m4/perl-time-hires.m4: New file.
* configure.ac: Use AC_PATH_PERL_WITH_TIME_HIRES_STAT to probe for
perl.
* build-aux/fetch.pl (fetch): For .pm files fetched from Automake,
rewrite “use 5.006” to “use 5.010”.
* build-aux/help-extract.pl
* lib/Autom4te/C4che.pm
* lib/Autom4te/ChannelDefs.pm
* lib/Autom4te/Channels.pm
* lib/Autom4te/Config.pm
* lib/Autom4te/Configure_ac.pm
* lib/Autom4te/FileUtils.pm
* lib/Autom4te/General.pm
* lib/Autom4te/Getopt.pm
* lib/Autom4te/Request.pm
* lib/Autom4te/XFile.pm
* tests/mktests.pl: Change “use 5.006” to “use 5.010”.
* lib/autoconf/functions.m4 (AC_FUNC_ALLOCA): Simplify and use
AS_IF. Had I done it this way originally I would have avoided the
bug that Jim just fixed.
"autoconf quoting is a pain"
* lib/autoconf/functions.m4 (AC_FUNC_ALLOCA): Its AC_CACHE_CHECK
contains an if/else block, but the closing "fi" lay just after its ")".
Before, this error didn't trigger any failure because the if/else code was
in the "else" block of AC_CACHE_CHECK's AS_IF invocation and AS_IF was also
implemented using an if..fi block. So the ostensibly-"outer" "fi" provided
by AS_IF matched the inner "if/else", and that stray-after-end "fi" served
to close the AS_IF block. However, when AS_IF switched from if..fi to
case..esac, this became a nesting error: no matching "fi".
Initially-harmless error introduced by v2.69-52-gfd29dbd7 in 2012.
Error exposed by v2.72a-30-gc8d6d6eb.
* tests/mktests.pl (scan_m4_files): Do not elide direct test
of AC_FUNC_ALLOCA.
FTR, here's the list of macros whose direct tests were being suppressed:
AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET
AC_CHECK_INCLUDES_DEFAULT AC_DISABLE_OPTION_CHECKING
AC_ERLANG_NEED_ERL AC_ERLANG_NEED_ERLC AC_ERLANG_SUBST_ERTS_VER
AC_ERLANG_SUBST_INSTALL_LIB_DIR AC_ERLANG_SUBST_LIB_DIR AC_F77_DUMMY_MAIN
AC_F77_LIBRARY_LDFLAGS AC_FC_DUMMY_MAIN AC_FC_LIBRARY_LDFLAGS
AC_FUNC_ALLOCA AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_GNU_SOURCE
AC_HEADER_DIRENT AC_HEADER_SYS_WAIT AC_PATH_X AC_PROG_CPP AC_PROG_CXX
AC_PROG_CXXCPP AC_PROG_F77 AC_PROG_FC AC_PROG_GO AC_PROG_GREP
AC_PROG_OBJC AC_PROG_OBJCPP AC_PROG_OBJCXX AC_PROG_OBJCXXCPP
AC_STRUCT_TM AC_TYPE_GETGROUPS AC_TYPE_LONG_LONG_INT AC_TYPE_MBSTATE_T
AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_UID_T AC_TYPE_UNSIGNED_LONG_LONG_INT
AC_USE_SYSTEM_EXTENSIONS
Also, port AC_EGREP_CPP to AT&T UnixPC.
Latter problem reported by Alain Knaff [sr #110657].
* lib/autoconf/general.m4 (AC_EGREP_CPP): Use new _AC_PROG_GREP.
Work even if the pattern starts with "-".
* lib/autoconf/programs.m4 (_AC_PROG_GREP):
New optional arg ACTION-IF-NOT-FOUND.
(_AC_PROG_EGREP_TRADITIONAL): New macro.
* lib/m4sugar/m4sh.m4: Work around bug in ancient sed.
Problem reported by Alain Knaff [sr#110654] for AT&T 3b1.
The Autoconf manual says this sed bug also occurs for
RISC/OS and IRIX 5.3.
Problem reported by Raphael Isemann in:
https://lists.gnu.org/r/autoconf-patches/2022-03/msg00007.html
* lib/autoconf/c.m4 (_AC_C_C99_TEST_MAIN, AC_C_FLEXIBLE_ARRAY_MEMBER):
* tests/data/gnulib_std_gnu11_2020_08_17.m4 (_AC_C_C99_TEST_HEADER):
Free storage allocated via malloc, to pacify overly-picky
implementations that issue false alarms about memory leaks.
Problem reported by Peter Johansson in:
https://lists.gnu.org/r/bug-autoconf/2022-03/msg00009.html
The bug was introduced in 2020-11-15T18:56:18Z!zackw@panix.com
with commit message saying “If anyone has a better idea for how to
make this work I will be glad to hear it”, and this patch uses a
trick with ‘case’ that should be a better idea.
* lib/m4sugar/m4sh.m4 (as_nop, as_fn_nop, _AS_EMPTY_ELSE_PREPARE):
Remove. All uses removed.
(_AS_IF_ELSE): Wrap the non-blank IF-ELSE inside a no-op case,
which works since a case branch can be empty in the shell.
* tests/m4sh.at (AS_IF and AS_CASE): Test the fix.
Problem reported by mirabilos via Eric Blake in:
https://www.austingroupbugs.net/view.php?id=1558https://lists.gnu.org/r/bug-autoconf/2022-02/msg00003.html
* lib/m4sugar/m4sh.m4 (_AS_TR_SH_PREPARE):
Define as_sed_sh as the sed script. All uses of as_tr_sh changed.
Define as_tr_sh as before, but only for compatibility with scripts
that mistakenly use as_tr_sh directly.
(AS_TR_CPP_PREPARE): Likewise for as_sed_cpp and as_tr_cpp.
This mirrors the existing RANLIB and related toolchain macros that
autoconf already exports. Some projects assume `ar` is available
which isn't always safe, so provide a macro that probes the full
toolchain settings.
This also makes it easier to use AC_REQUIRE with the macro instead
of duplicating the AC_CHECK_TOOL call in projects.
* lib/autoconf/programs.m4 (AC_PROG_AR): New macro.
* doc/autoconf.texi: Document it.
* tests/local.at (_AT_CHECK_ENV): Allow $AR output variable.
This simplifies the Makefile a bit and also paves the way for a
bootstrap script (replacing the process of re-running autoreconf with
the just-built autoconf) which will be able to cope with generated
files that get installed in @pkgdatadir@ but not in @pkgdatadir@/m4sugar.
* lib/version.in: New file, contents extracted from lib/local.mk.
* lib/local.mk: Do not generate version.m4 here.
* configure.ac: Generate lib/version.m4 from lib/version.in via
config.status.
* lib/freeze.mk, lib/local.mk, lib/m4sugar/m4sugar.m4:
version.m4 now lives in @pkgdatadir@ rather than @pkgdatadir@/m4sugar.
This patch adds the AC_F77_CRAY_POINTERS and AC_FC_CRAY_POINTERS macros,
which test if the Fortran compiler supports Cray pointers.
The macros are written such that the tests share a common backend
(_AC_FC_CRAY_POINTERS) which works on both F77 and FC compilers.
Wrappers are provided to address any future potential compatibility
issues.
The macros include additional tests for particular flags required by
GFortran and PGI compilers. The current set of flags is sparse, but can
be extended for other compilers if needed.
Documentation and a minimal test of the macro have been included.
Two minor variable name typos (@EXEEXT@ as @EEXEXT@) were also fixed in
two of the other Fortran tests.
Autoconf’s diagnostics now follow current GNU coding standards,
which say that diagnostics in the C locale should quote 'like this'
with plain apostrophes instead of the older GNU style `like this'
with grave accent and apostrophe.
Problem reported by Bruno Haible (sr #110518).
* doc/autoconf.texi (Generating Sources)
(Running the Preprocessor, Running the Compiler)
(Running the Linker, Runtime): Briefly mention that the program
snippets are expanded as unquoted here-documents.
(Here-Documents): Document escaping needed in unquoted
here-documents. Remove mention of \" glitch in OpenBSD 2.7 sh;
that old system has not been supported for many years.
Remove advice that every \ must be quoted, as that sort
of quoting (though harmless) is not needed and is rarely done.
* lib/autoconf/c.m4 (AC_C_BIGENDIAN, _AC_LANG_OPENMP(Fortran 77)):
* lib/autoconf/types.m4 (AC_TYPE_LONG_LONG_INT): Properly quote
code snippets. The backslash-newline typos were harmless, and the
backslash-$ typo has unspecified behavior as per POSIX though the
typo is harmless on all shells I know of. However, Autoconf
should follow its own quoting advice.
The typo causes "ac_prog_cxx_stdcxx" to be always set to "cxx11",
regardless of whether the C++ compiler supports C++11.
Message-Id: <YJ4TXAeJcvU0oSec@FSAPPLE2215.fi.f-secure.com>
(tiny change)
Gnulib’s std-gnu11.m4 backports C11 and C++11 detection to autoconf
2.69. It does this by replacing the definitions of AC_PROC_CC and
AC_PROG_CXX and most of their subroutines. In particular, it replaces
the definitions of _AC_PROG_CC_C11, _AC_PROG_CC_C99, and _AC_C_STD_TRY,
but it does *not* replace the definition of _AC_PROG_CC_C89.
Autoconf commit 131d8c69f3 changed the
calling convention of _AC_C_STD_TRY, and changed the internal
definitions of _AC_PROG_CC_C{11,99,89} to match. If std-gnu11.m4 is
in use, our _AC_PROG_CC_C89 calls their _AC_C_STD_TRY with the new
calling convention, and this produces a syntactically invalid
configure script. (This is is fortunate: it could easily have been a
runtime malfunction that only manifested with compilers that only
implement C89, and then we might not have noticed the problem for
years.)
Gnulib commit a3b3fc85e3e632374811b27cb2111e50fa177e36 makes
std-gnu11.m4 do nothing when used with autoconf >=2.70, but older
versions of the file will circulate for years to come, so this patch
works around the problem in autoconf. It does this by renaming all of
the internal macros involved with C and C++ standard edition
detection, *except* _AC_PROG_CC_C89. AC_PROG_CC now calls
_AC_PROG_CC_STDC_EDITION, which loops over all supported editions
calling _AC_PROG_CC_STDC_EDITION_TRY, which uses the data provided by
the existing _AC_C_C${edition}_TEST_PROGRAM macros and a new set of
macros called _AC_C_C${edition}_OPTIONS to perform the test for that
edition of the standard. Similarly, AC_PROG_CXX calls
_AC_PROG_CXX_STDCXX_EDITION, which loops calling
_AC_PROG_CXX_STDCXX_EDITION_TRY, which uses data from
_AC_CXX_CXX${edition}_TEST_PROGRAM and _AC_CXX_CXX${edition}_OPTIONS.
_AC_PROG_CC_C89 is the only macro from the old set that we still
define, and its definition is reverted to what std-gnu11.m4 expects it
to be. Nothing in Autoconf proper uses it anymore.
foreign.at grows a test to verify that the compatibility stub version
of _AC_PROG_CC_C89 does its job. Since this is now the third test
involving an embedded copy of a third-party macro, I broke them all
out of foreign.at to separate files in test/data/.
In addition to fixing the breakage, this patch should make it easier
to extend C / C++ standard edition detection in the future, by getting
rid of the if-else chains in AC_PROG_CC/CXX and by disentangling the
lists of command-line options to test from the logic.
I also changed the manual to suggest people refer to the variables
‘ac_prog_cc_stdc’ and ‘ac_prog_cxx_stdcxx’ to learn which edition
of the C and C++ standards are selected; these are much easier to
work with than the ac_cv_prog_cc_cNN cache variables.
* lib/autoconf/c.m4 (_AC_C_STD_TRY, _AC_PROG_CC_C99, _AC_PROG_CC_C11)
(_AC_CXX_STD_TRY, _AC_PROG_CXX_CXX98, _AC_PROG_CXX_CXX11): Remove macro.
(_AC_C_C89_OPTIONS, _AC_C_C99_OPTIONS, _AC_C_C11_OPTIONS)
(_AC_PROG_CC_STDC_EDITION, _AC_PROG_CC_STDC_EDITION_TRY)
(_AC_CXX_CXX98_OPTIONS, _AC_CXX_CXX11_OPTIONS)
(_AC_PROG_CXX_STDCXX_EDITION, _AC_PROG_CXX_STDCXX_EDITION_TRY): New macros.
(_AC_PROG_CC_C89): Convert to compatibility stub for std-gnu11.m4.
(AC_PROG_CC): Use _AC_PROG_CC_STDC_EDITION.
(AC_PROG_CXX): Use _AC_PROG_CXX_STDCXX_EDITION.
* tests/data/ax_prog_cc_for_build_v18.m4
* tests/data/ax_prog_cxx_for_build_v3.m4
* tests/data/gnulib_std_gnu11_2020_08_17.m4: New files.
* tests/foreign.at (AX_PROG_CC_FOR_BUILD, AX_PROG_CXX_FOR_BUILD):
Remove embedded copy of ax_prog_cc_for_build_v18.m4,
ax_prog_cxx_for_build_v3.m4 respectively.
(gnulib-std-gnu11.m4): New test.
* tests/local.mk: Distribute tests/data/*.m4.
* doc/autoconf.texi (AC_PROG_CC, AC_PROG_CXX): Document use of
ac_prog_cc_stdc / ac_prog_cxx_stdcxx, respectively, to tell which
edition of the C / C++ standards are selected, instead of looking
through a series of cache variables with awkward definitions.
clang issues only a warning, not an error, when an undeclared
identifier that names a built-in function is used: for instance
char *(*p)(const char *, int) = strchr;
(with no `#include <string.h>`) is an error with most compilers,
a warning with clang. This broke the 2.69 implementation of
AC_CHECK_DECL. In commit 82ef7805fa,
we tried to work around this quirk by using -Werror, but that put us
at risk of being tripped up by other warnings. Bug 110400 reports,
for instance, that this fragment (which is roughly what you get, after
preprocessing, when AC_CHECK_DECL is applied to a function that *is*
properly declared)
extern void ac_decl (int, char *);
int main (void)
{
(void) ac_decl;
;
return 0;
}
provokes a warning from clang (and thus an error) when -Wextra-semi-stmt
has been added to CFLAGS earlier in the configure script. The extra
semicolon comes from AC_LANG_PROGRAM, and we can’t get rid of it
because we have no way of telling reliably when someone wrote
something like
AC_LANG_PROGRAM([[#include <stdio.h>]],
[[puts("hello world")]])
with no semicolon at the end of the statement; this has been
acceptable for decades. Besides, that’s just one warning, who knows
what compilers will start complaining about tomorrow?
So: change AC_CHECK_DECL to compile its programs with -fno-builtin,
instead, when the default compilation mode fails to detect an
undeclared strchr. The code is restructured so that we can try other
options as well, if we find another compiler with the same quirk but
different command-line syntax.
(All of this logic is very C-family specific, but it appears to me
that AC_CHECK_DECL has never worked with other languages, so we can
continue to live with that for now.)
Fixes bug 110400; partially reverts 82ef7805fa.
* lib/autoconf/general.m4 (_AC_UNDECLARED_WARNING): Rename to
_AC_UNDECLARED_BUILTIN. Instead of looking at diagnostic output,
loop trying to find a command-line option that makes the compiler
error out on undeclared builtins.
(_AC_CHECK_DECL_BODY): Don’t AC_REQUIRE anything here.
Make shell code language-agnostic, except for the actual test program.
Add arguments to the shell function for additional compiler options
to use.
(AC_CHECK_DECL): AC_REQUIRE _AC_UNDECLARED_BUILTIN here.
Supply $ac_{AC_LANG_ABBREV}_undeclared_builtin_options to
ac_fn_check_decl.
* tests/local.at (AT_CONFIG_CMP): Update list of variables to ignore
when comparing C and C++ configure runs.
* tests/semantics.at (AC_CHECK_DECLS): Add memcpy and strchr to
AC_CHECK_DECLS call for functions that may be known to the compiler.
* doc/autoconf.texi (AC_CHECK_DECL, AC_CHECK_DECLS): Remove note
about compiler warnings.
* lib/autoconf/functions.m4 (_AC_LIBOBJ_ALLOCA, AC_FUNC_ALLOCA):
Use ' not ` in generated comments, as per current GNU coding style.
(_AC_LIBOBJ_ALLOCA): Use plain # instead of unnecessary quadrigraph.
This patch is adapted from Gnulib.
Problem reported by Christian Biesinger in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00159.html
* lib/autoconf/c.m4 (AC_C_RESTRICT): Port better to
Oracle Developer Studio C++ 12.5 or later.
This patch is adapted from Gnulib.
_AC_PROG_CC_C99 was using the wrong test program.
Fixes#110396, reported anonymously.
* lib/autoconf/c.m4 (_AC_PROG_CC_C99): Use the C99 test program, not
the C89 test program.
The absolute-path case in AT_TESTED had a typo in it, causing bizarre
error messages and preventing programs identified by absolute path
from being logged properly.
* lib/autotest/general.m4 (AT_TESTED): Fix typoed shell syntax in
handling of programs identified by absolute path.
The list of macros documented as being defined by
AC_USE_SYSTEM_EXTENSIONS had gotten out of sync with the actual list.
Update it thoroughly.
Also, I introduced an error into the commentary when I merged Julien
ÉLIE’s patch to define _NETBSD_SOURCE and _OPENBSD_SOURCE in
AC_USE_SYSTEM_EXTENSIONS. _OPENBSD_SOURCE does something on NetBSD
and *doesn’t* do anything on OpenBSD. This is corrected.
Clean up the code in AC_USE_SYSTEM_EXTENSIONS a bit while I’m in
there; we now had a redundant definition of _NETBSD_SOURCE (one
unconditional and one conditional on minix/config.h existing).
Reorganize the macro to make it easier to catch problems like this in
the future.
* lib/autoconf/specific.m4 (AC_USE_SYSTEM_EXTENSIONS): Reorganize;
remove redundant AC_DEFINE of _NETBSD_SOURCE; add some missing
AC_BEFOREs; use _AC_CHECK_HEADER_ONCE for header checks;
revise all commentary.
* doc/autoconf.texi (AC_USE_SYSTEM_EXTENSIONS): Update.
Makes the documentation of AC_PROG_CC consistent with the
documentation of AC_PROG_CXX. Also removes a bunch of redundant text
from c.m4 and adds lists of the headers that *can* be used in the
conformance tests, so future hackers don’t have to look them up.
* doc/autoconf.texi (AC_PROG_CC): Make description consistent with
description of AC_PROG_CXX.
* lib/autoconf/c.m4: Clean up some outdated or repetitive commentary
and add lists of the freestanding headers above the code that needs
to avoid using non-freestanding headers.
This makes the C conformance tests more consistent with the C++
conformance tests, and should also speed up cycling through the
possible options to turn on C99/C11.
Tested with gcc, clang, SunPRO C, and AIX xlc.
* lib/autoconf/c.m4 (_AC_C_C89_TEST_GLOBALS): Add preprocessor test
for __STDC__ being defined (to any value).
(_AC_C_C99_TEST_GLOBALS, _AC_C_C11_TEST_GLOBALS): Add preprocessor
test of the value of __STDC_VERSION__.
The tests for the level of the C and C++ standard supported by their
respective compilers should also avoid using any headers that are not
guaranteed to be available in the respective freestanding environment.
Unlike the previous change, the only user-visible consequence of this
one should be that C11/C99/C89/C++11/C++98 *compiler* support is now
correctly detected when the compilation target is a freestanding
environment.
This patch also refactors how we “emit [the text of the C/C++
standard-conformance test programs] only once per [configure script],
into shell variables which can then be referenced repeatedly,” from
c3853873, because editing them just a little made the M4 quotation
break. Clearly too fragile.
I believe this completes the fix for bug #110393.
* lib/autoconf/c.m4 (_AC_PROG_CC_C89, _AC_PROG_CC_C99, _AC_PROG_CC_C11)
_AC_C_C99_TEST_HEADER, _AC_C_C99_TEST_BODY): Move all test program
fragments into new macros that can be AC_REQUIREd individually:
_AC_C_C89_TEST_GLOBALS, _AC_C_C89_TEST_MAIN, _AC_C_C89_TEST_PROGRAM,
_AC_C_C99_TEST_GLOBALS, _AC_C_C99_TEST_MAIN, _AC_C_C99_TEST_PROGRAM,
_AC_C_C11_TEST_GLOBALS, _AC_C_C11_TEST_MAIN, _AC_C_C11_TEST_PROGRAM.
Each emits test code at most once, into a shell variable in the
INIT_PREPARE diversion.
Revise each test program to use only library features of the
respective standard’s freestanding environment.
(_AC_C_STD_TRY): Take the *name* of the shell variable holding the
complete test program as an argument, not the code itself. All
callers adjusted to match.
(_AC_PROG_CXX_CXX98, _AC_PROG_CXX_CXX11, _AC_CXX_STD_TRY)
(_AC_CXX_CXX98_TEST_HEADER, _AC_CXX_CXX98_TEST_BODY)
(_AC_CXX_CXX11_TEST_HEADER, _AC_CXX_CXX11_TEST_BODY): Similarly.
New macros are:
_AC_CXX_CXX98_TEST_GLOBALS, _AC_CXX_CXX98_TEST_MAIN,
_AC_CXX_CXX98_TEST_PROGRAM,
_AC_CXX_CXX11_TEST_GLOBALS, _AC_CXX_CXX11_TEST_MAIN,
_AC_CXX_CXX11_TEST_PROGRAM.
Since 1993, Autoconf has been assuming that it is safe to include any
of the headers defined by ISO C90 without checking for them; this is
inaccurate, since only a subset are necessarily available in a
C90 *freestanding* environment.
It is OK to assume the presence of a header in a macro that checks
specifically for something declared by that header (if the header is
not present, we will think the specific declaration is unavailable,
which is probably accurate for modern embedded environments). It is
also OK to continue recommending that user code use these headers
unconditionally—anyone working with a freestanding environment knows
it. But it is not OK for very generic code within Autoconf itself,
such as AC_INCLUDES_DEFAULT, to make this assumption.
Note that the set of headers that are not always available includes
stdio.h, which we have been assuming can be included unconditionally
for even longer.
In AC_INCLUDES_DEFAULT, revert to checking for string.h and stdlib.h
before including them. Also revert to defining STDC_HEADERS only when
string.h and stdlib.h are available (but do not check for float.h and
stdarg.h, as these are part of the freestanding set). Add a new check
for stdio.h. Sort the inclusion list by standard (C90 freestanding;
C90 hosted; C99; POSIX) and alphabetically within each group. Revise
all the documentation and update the testsuite.
This partially reverts commit 86c213d0e3
and is a partial fix for bug #110393.
* lib/autoconf/headers.m4 (AC_CHECK_INCLUDES_DEFAULT): Check for
stdio.h, stdlib.h, and string.h before including them. Define
STDC_HEADERS only when string.h and stdlib.h are both available.
Organize includes list by standard, then alphabetically.
* doc/autoconf.texi, NEWS: Update to match.
* tests/local.at (AT_CHECK_DEFINES): Make regexes more specific.
Also expect a definition of HAVE_STDIO_H.
* tests/c.at, tests/semantics.at, tests/tools.at: Use <float.h>,
not <stdio.h>, as a header that we expect always to exist.
Add HAVE_STDIO_H to various lists of macros that are expected to
appear in config.h.
Revert commit 18c140b50b, restoring
AC_PROG_CC to being defined as an ordinary AC_DEFUN. This broke
third-party macros (e.g. the Autoconf Macro Archive’s
AX_PROG_CC_FOR_BUILD) that intentionally invoked AC_PROG_CC a second
time with its guts redefined via a whole bunch of ‘pushdef’s. I don’t
think we want to support this long-term, but needing access to a
build-native compiler in cross-compilation is common enough that we
should have *some* supported way to do it, and it may as well be
AX_PROG_CC_FOR_BUILD until we come up with something better.
If we go back to AC_DEFUN_ONCE for AC_PROG_CC in the future, we should
do it consistently for all the “find me a compiler” macros -- it
was *only* done for AC_PROG_CC in 18c140b5.
The rationale for AC_DEFUN_ONCE seems to have been to reduce the size
of the generated configure script. The bulk of the size accountable to
AC_PROG_CC is the test programs for figuring out which version of the
C standard is available, so I tweaked _AC_C_STD_TRY (and _AC_CXX_STD_TRY)
to emit that text only once per program, into shell variables which
can then be referenced repeatedly.
Fixes bug #110350.
* NEWS, doc/autoconf.texi: Revert documentation changes associated
with AC_PROG_CC being a one-shot macro.
* lib/autoconf/c.m4 (AC_PROG_CC): Revert to defining with AC_DEFUN.
(_AC_C_STD_TRY, _AC_CXX_STD_TRY): Emit the test program only once,
even if invoked multiple times with the same arguments.
* tests/foreign.at (AX_PROG_CC_FOR_BUILD, AX_PROG_CXX_FOR_BUILD):
New tests.
Currently, there isn’t any documented way for an Autotest testsuite to
add custom code to be run either right before the main driver loop, or
at the point of each AT_SETUP. For instance, there’s no good place to
put environment variable sanitization that should apply to the entire
testsuite (but isn’t universally relevant), or shell function
definitions to be used by custom test macros.
Autoconf’s test suite is poking shell functions directly into the
PREPARE_TESTS diversion, and doing environment variable sanitization
in each individual test. Both of these are obviously undesirable.
This patch adds three new AT_* macros that can be used to do these
things in an officially-supported way: AT_PREPARE_TESTS adds code to
be run right before the main driver loop, AT_PREPARE_EACH_TEST adds
code to be run at the beginning of each test, and AT_TEST_HELPER_FN
defines a shell function that will be available to each test. In
Autoconf’s test suite, I use AT_PREPARE_TESTS to factor out
environment variable sanitization that *ought* to apply across the
board, and AT_TEST_HELPER_FN for the helper function used by
AT_CHECK_ENV.
(This fixes the testsuite bug reported by Jannick at
https://lists.gnu.org/archive/html/autoconf/2020-10/msg00052.html :
CONFIG_SITE in the parent environment will no longer be visible to tests.)
It would be nice to give an example of when AT_PREPARE_EACH_TEST is
useful, in the documentation, but I didn’t find one in the autoconf
test suite.
* lib/autotest/general.m4 (AT_PREPARE_TESTS, AT_PREPARE_EACH_TEST)
(AT_TEST_HELPER_FN): New macros.
(AT_INIT, AT_TESTED): Emit the code to report tested programs only
if it’s needed, and make sure it’s after any code added by
AT_PREPARE_TESTS.
* tests/local.at: Add AT_PREPARE_TESTS block that ensures
$MAKE is set sensibly and $MAKEFLAGS and $CONFIG_SITE are unset.
Use AT_TEST_HELPER_FN for the helper function needed by AT_CHECK_ENV.
(AT_CHECK_MAKE): No need to sanitize $MAKE or $MAKEFLAGS here.
* tests/base.at, tests/compile.at, tests/m4sh.at, tests/torture.at:
No need to unset or neutralize $CONFIG_SITE in individual tests.
* tests/autotest.at: Add tests for new macros.
* doc/autoconf.texi, NEWS: Document new macros.
Erlang is similar to Java in that it doesn’t compile to standalone
machine code; the output of ‘erlc’ is byte-code files that are then
interpreted by ‘erl’. We handle this poorly in a whole bunch of ways,
particularly when cross-compiling. This patch fixes up the more
serious problems:
- AC_COMPILE_IFELSE now actually works when AC_LANG([Erlang]) is in
effect.
- ‘conftest.beam’ is now deleted in several more places where it
could be created.
- The various AC_ERLANG_* macros that interrogate the runtime
environment do so by invoking ‘$ERL’ directly, rather than using
AC_RUN_IFELSE, and thus do not crash the configure script when
we think we’re cross-compiling. (It is not clear to me whether
they get the correct answer when cross-compiling, but this should
still be strictly an improvement.)
- The Erlang-related tests have been streamlined.
Further improvements are definitely possible, but we’d have to teach
the infrastructure to make $ac_objext language-specific first, which
seems like too big of a change for 2.70.
(This patch is all fallout from a logically unrelated testsuite change
which is coming up next. Gotta love the fundamental interconnectedness
of things.)
* lib/autoconf/general.m4 (_AC_COMPILE_IFELSE_BODY)
(_AC_LINK_IFELSE_BODY): Delete conftest.beam as well as conftest.$ac_objext.
* lib/autoconf/erlang.m4 (AC_ERLANG_PATH_ERLC, AC_ERLANG_PATH_ERL):
Don’t repeat work done by AC_PATH_TOOL.
(Erlang $ac_compile): Fake an .o file so AC_TRY_COMPILE will be happy.
(AC_LANG_COMPILER(Erlang)): AC_REQUIRE AC_ERLANG_NEED_ERLC, not
AC_ERLANG_PATH_ERLC. Also AC_REQUIRE AC_ERLANG_NEED_ERL so
AC_RUN_IFELSE works reliably.
(AC_ERLANG_CHECK_LIB, AC_ERLANG_SUBST_ROOT_DIR)
(AC_ERLANG_SUBST_LIB_DIR, AC_ERLANG_SUBST_ERTS_VER):
Use $ERL -eval, not AC_RUN_IFELSE.
No need to AC_REQUIRE AC_ERLANG_NEED_ERLC.
* tests/erlang.at: Don’t test anything here that’s tested adequately
by acerlang.at; document which macros those are expected to be.
Remove unnecessary AC_ERLANG_PATH_ERL/ERLC invocations throughout.
(AT_CHECK_MACRO([Erlang])): Rename test to ‘Erlang basic compilation’;
expect both AC_COMPILE_IFELSE and AC_RUN_IFELSE to work;
handle cross compilation mode properly.
* tests/mktests.sh: Exclude from acerlang.at all macros completely
covered by erlang.at.
AC_CHECK_HEADER_STDBOOL is documented to make two checks: whether the
C99 header <stdbool.h> is available and fulfills its
specification (i.e. including it makes the type ‘bool’ and the
constants ‘true’ and ‘false’ available), and, independently, whether
the type ‘_Bool’ is available.
In C++, the type ‘_Bool’ is usually _not_ available, but <stdbool.h>
is still supposed to be include-able and the type ‘bool’ and the
constants ‘true’ and ‘false’ are still supposed to be available
(unconditionally). However, the test for <stdbool.h> fulfilling its
specification freely used _Bool, and would therefore fail spuriously.
Correct this by checking for _Bool first, and then refactoring the
test program for <stdbool.h> so that it does all its tests using bool,
then repeats them with _Bool only when available.
* lib/autoconf/headers.m4 (AC_CHECK_HEADER_STDBOOL): Do the test for
_Bool before the test for stdbool.h. Test semantics of bool
unconditionally; test _Bool only when HAVE__BOOL is defined.
AC_FUNC_SETPGRP determines whether you have the historic BSD setpgrp,
which takes two arguments and returns int, or the historic POSIX
setpgrp, which takes no arguments and returns int. Solaris has yet a
third variant, which takes no arguments and returns a pid_t (the new
process group ID). This difference causes AC_FUNC_SETPGRP’s test
program to fail to compile under AC_LANG([C++]), which in turn causes
the macro to report that setpgrp does take arguments, which is wrong.
It is not worth adding a new result #define for this variant,
since *all* forms of setpgrp are deprecated in favor of setpgid, which
is old enough that it can be used unconditionally. However, it is
worth documenting that this variant exists, and fixing AC_FUNC_SETPGRP
to produce the right value for its existing result #define on Solaris
with C++.
* lib/autoconf/functions.m4 (AC_FUNC_SETPGRP): Redesign test program to
not depend on the return type of setpgrp.
* doc/autoconf.texi (AC_FUNC_SETPGRP): Mention that the macro does not
check for the Solaris variant of setpgrp that returns pid_t. Change
programming advice to recommend use of setpgid.
On systems where plain ‘char’ is unsigned (e.g. AIX) we would define
__CHAR_UNSIGNED__ only when $GCC was not true at configure time.
If AC_LANG([C++]) has been in effect since the beginning of the
script (so AC_PROG_CC was never invoked), $GCC will be false
regardless; this causes an inconsistency between the C and C++
behaviors, even when both compilers are GNU.
The point of checking $GCC here is that GCC has command line options
to override the signedness of plain ‘char’, and it predefines
__CHAR_UNSIGNED__ to indicate what the signedness actually is.
We don’t want config.h to override that. However, there is already
a special autoheader template for __CHAR_UNSIGNED__ that prevents it
being redefined if it’s defined already, so checking $GCC at
configure time is redundant and can safely be removed.
* lib/autoconf/c.m4 (AC_C_CHAR_UNSIGNED): Do not make result depend on
value of $GCC. Adjust commentary.
Fix some subtle quotation bugs in _AC_INIT_PACKAGE that made it
impossible to put ‘,’ or an unbalanced close parenthesis in some of
the arguments to AC_INIT. Document that arguments to AC_INIT
containing parentheses, square brackets, ‘,’ or ‘#’ may need to be
double-quoted. Provide more detailed examples and exposition re
computing the arguments to AC_INIT when autoconf is run (e.g. with
git-version-gen). Add a whole bunch more tests for unusual arguments
to AC_INIT, and a test that the backward-compatibility behavior of
AC_INIT with only one argument is still correct.
This may still break some of the existing configure scripts described
in the threads at
https://lists.gnu.org/r/autoconf/2020-10/msg00013.html and
https://lists.gnu.org/r/bug-autoconf/2020-10/msg00012.html
but, I hope, only in ways covered by the existing warning in NEWS
about pickier M4 quotation.
* lib/autoconf/general.m4 (_AC_INIT_PACKAGE): Redo argument
normalization and default value selection in a simpler, less
error-prone fashion.
(_AC_INIT_PACKAGE_N): New helper subroutine.
(AC_INIT): Always call _AC_INIT_PACKAGE, but supply no arguments if
we were called with only one argument.
* tests/base.at (AC_INIT (obsolete invocation)): New test.
(AC_INIT with unusual version strings): Expand test.
* doc/autoconf.texi (AC_INIT): Revise.
AS_ECHO expands to ‘printf "%s\n" $1’. If a configure script defines
an M4 macro named ‘s’ or ‘n’ it will be expanded in the first argument
to printf, which is almost certainly not what was intended.
The configure script for ruby 2.7.2 uses ‘AS_VAR_PUSHDEF([s], ...)’
and breaks with 2.69d because of this.
Add some extra quoting so that the ‘%s\n’ is treated as literal;
similarly for AS_ECHO_N and the legacy shell variables $as_echo
and $as_echo_n.
For now, anyway, don’t quote the word ‘printf’; if someone does
define that as a M4 macro they might well mean to affect AS_ECHO.
(Whether this is something we *want* to allow, we can worry about
when it comes up.)
Fixes bug #110377.
* lib/m4sugar/m4sh.m4 (_AS_ECHO_N_PREPARE, AS_ECHO, AS_ECHO_N):
Add another layer of quoting around the first argument to printf.
* tests/m4sh.at (Redefining AS_ECHO internals): New test.
The most recently released version of libtool.m4 is five years old as
of this commit, and no new release is likely to appear anytime soon.
It uses AC_LANG_SAVE and AC_LANG_RESTORE, in a way that doesn’t
obviously translate to AC_LANG_PUSH and AC_LANG_POP. This will need
to be fixed by libtool upstream. Until that actually happens, disable
the -Wobsolete warnings for AC_LANG_SAVE and AC_LANG_RESTORE. (They
are still documented as obsolete in the manual, as they have been for
many years.)
Fixes bug #110375.
* lib/autoconf/lang.m4 (AC_LANG_SAVE, AC_LANG_RESTORE): Define with
AC_DEFUN, not AU_DEFUN; remove manual -Wobsolete warnings.
AS_IF can emit a syntactically invalid shell if-then-else,
if CONDITION
then :
# ...
else
fi
when its IF-FALSE argument consists of macros that don’t produce any
shell code. This was a documented limitation in AS_IF, but it’s a bad
limitation to have, because macros that *used* to expand to shell
commands might start expanding to nothing in future releases. For
instance, this broke the libzmq configure script, which did
AC_PROG_CC
AX_CHECK_COMPILE_FLAG([-std=gnu11],
[CFLAGS+=" -std=gnu11"],
[AC_PROG_CC_C99])
Perfectly valid in 2.69, but in 2.70 AC_PROG_CC_C99 doesn’t produce
any shell code and the script crashes.
We had that limitation for good reason: we can’t just put ‘:’ at the
beginning of the else-clause, like we do for the then-clause, because
that would clobber $? and the IF-FALSE commands might want to inspect
it. (This doesn’t matter for the then-clause, because $? is always
zero at the beginning of a then-clause anyway.) The simplest and
least inefficient shell construct I can find that works in this
context is a shell function that does ‘return $?’. Due to awkward
M4sh initialization ordering constraints (AS_IF gets used before we
can safely use shell functions) an indirection through a shell
variable is necessary. The structure of a m4sh script is now
#! /bin/sh
## M4sh Initialization
as_nop=:
...
## M4sh Shell Functions
as_fn_nop () { return $?; }
as_nop=as_fn_nop
...
and AS_IF emits
if CONDITION
then :
# ...
else $as_nop
# ...
fi
The uses of AS_IF that appear before the beginning of the M4sh Shell
Functions section are all under our control and they don’t need to
look at $?.
If anyone has a better idea for how to make this work I will be glad
to hear it.
Fixes bug #110369.
* lib/m4sugar/m4sh.m4
(_AS_IF_ELSE): When $1 is nonempty, invoke _AS_EMPTY_ELSE_PREPARE.
Emit $as_nop at beginning of else clause.
(_AS_BOURNE_COMPATIBLE): Initialize as_nop to ‘:’.
(_AS_EMPTY_ELSE_PREPARE): New macro which emits a definition of
as_fn_nop and resets as_nop to as_fn_nop.
(AS_PREPARE, _AS_PREPARE): Invoke _AS_EMPTY_ELSE_PREPARE.
(_AS_UNSET_PREPARE): Tweak white space.
* tests/m4sh.at (AS_IF and AS_CASE): Test AS_IF’s IF-FALSE argument
being empty after macro expansion.
* doc/autoconf.texi (AS_IF): Remove warning about use with
‘run-if-false’ argument empty after macro expansion.
Instead of treating CONFIG_SITE as a single path, treat it as a
space-separated list of paths and load them in order.
Also remove the special-casing of entries starting with a dash, this is
redundant as they'll be caught by the wildcard case.
Finally add a test case to verify that multiple files are loaded
correctly.
* lib/autoconf/general.m4 (AC_SITE_LOAD): Treat CONFIG_SITE as a
space-separated list of scripts to be sourced. Simplify handling
of default config.site locations using this capability.
* tests/base.at (AC_CACHE_CHECK): Test loading of multiple site files.
* doc/autoconf.texi (Site Defaults): Update documentation of CONFIG_SITE.