Go to file
Zack Weinberg b8c150bd0d
AT_CHECK_MACRO: test C++ as well as C, cross as well as native
Many of the reported regressions in Autoconf 2.70 betas went unnoticed
for years because Autoconf’s bundled test suite didn’t test most of
the macros with a C++ compiler and/or in cross compilation mode.
There’s a special makefile target ‘maintainer-check-c++’ that runs all
the tests with CC=g++, but that doesn’t catch the regressions either,
because it doesn’t compare the configure results with what you’d have
gotten with a C compiler.  Also, C and C++ have diverged to the point
where setting CC to a C++ compiler doesn’t work reliably anymore.

This patch overhauls AT_CHECK_MACRO to test each macro four times:
(C compiler, C++ compiler) x (native mode, cross-compilation mode).
All four tests are expected to produce the same config.cache and
config.h, except for certain predictable differences due to running
AC_PROG_CXX instead of AC_PROG_CC, and a short list of known,
acceptable differences, maintained in mktests.pl.

There are two classes of known, acceptable differences.  Macros that
use AC_RUN_IFELSE aren’t tested in cross-compilation mode at all,
because they may crash the script (this is temporary and will be
revisited after 2.70).  Macros that correctly detect a difference
between C and C++ (e.g. AC_HEADER_STDBOOL will notice that C++ doesn’t
have the _Bool type) are annotated with the specific cache variable
and #define that varies.

mktests.pl now also has the capability to provide values for the
MACRO-USE, ADDITIONAL-COMMANDS, and AUTOCONF-FLAGS arguments to
AT_CHECK_(AU_)MACRO, on a per-macro basis, but that’s not used in this
patch.

Some of the manual uses of AT_CHECK_MACRO do not need to test C++
and/or cross compilation; for them, there is a new test helper,
AT_CHECK_CONFIGURE_AC.  Another new helper, AT_PRESERVE_CONFIG_STATUS,
is used extensively in AT_CHECK_(AU_)MACRO but may be also useful in
manual tests that need to do multiple configure runs.

This change supersedes AT_CHECK_MACRO_CROSS and
‘make maintainer-check-c++’, which are removed.

In my testing, setting CC to a C++ compiler no longer works at all,
for reasons that are impractical to fix (e.g. C++ compilers choke on
the test for C2011 features) so I have added a note to NEWS saying
that this is not supported anymore.

 * tests/local.at (AT_CHECK_MACRO): Default behavior is now to test
   the macro in both native and cross-compilation mode, and expect the
   results to be identical.  If the macro transitively required
   AC_PROG_CC, and a C++ compiler is available, then test it twice
   more with AC_LANG([C++]) in effect, and again expect the results to
   be identical.  New fifth argument TEST-PARAMETERS can modify this
   behavior.
   (_AT_FILTER_CXX_CV_VARIES, _AT_FILTER_CXX_DEFINE_VARIES): New,
   subroutines of AT_CHECK_MACRO.

   (AT_CHECK_MACRO_CROSS): Remove, subsumed by new AT_CHECK_MACRO
   behavior.
   (AT_CHECK_AU_MACRO): Forward to AT_CHECK_MACRO for the basic test;
   then do the same autoupdate test as before, as a separate test group.

   (at_check_env): Also ignore OPENMP_CXXFLAGS.
   (AT_CONFIG_CMP): Add third argument EXTRA-VARIANCE that specifies
   additional variables that are expected to vary in a particular test.
   (_AT_CONFIG_CMP_PRUNE): New, subroutine of AT_CONFIG_CMP.
   (AT_DEFINES_CMP): New helper macro that compares config.h headers,
   with the ability to ignore variation in specific defines.
   (_AT_DEFINES_CMP_PRUNE): New, subroutine of AT_DEFINES_CMP.

   (AT_PRESERVE_CONFIG_STATUS): New helper that makes copies of
   config.h, config.log, config.status, and state-env.after under
   names that won’t be clobbered by a subsequent run of configure.

   (AT_CHECK_CONFIGURE_AC): New helper that defines a complete test
   group consisting of a single invocation of _AT_CHECK_AC_MACRO;
   effectively what AT_CHECK_MACRO used to be.
   (_AT_CHECK_AC_MACRO): Correct documentation comment; the PRE-TESTS
   argument has always been optional.

 * tests/mktests.pl (test_parameters): New global data object giving
   extra arguments to pass to AT_CHECK_MACRO/AT_CHECK_AU_MACRO on a
   per-macro basis.
   (emit_test): New function that handles emitting calls to
   AT_CHECK_(AU_)MACRO with the desired arguments.
   (scan_m4_files): Use emit_test.

   (au_exclude_list): Add AC_HAVE_LIBRARY, AC_COMPILE_CHECK,
   AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK, and AC_TRY_RUN.

 * tests/semantics.at (AC_CHECK_LIB, AC_SEARCH_LIBS): Rewrite test
   using symbols from zlib instead of libm, to get consistent behavior
   from C and C++.
   (AC_SEARCH_LIBS (none needed)): Revise to clarify what is being tested.
   (AC_CHECK_DECLS): Use _AC_LANG_ABBREV when inspecting cache variables.
   (AC_CHECK_ALIGNOF, AC_CHECK_ALIGNOF struct)
   (AC_CHECK_SIZEOF, AC_CHECK_SIZEOF struct)
   No need for AT_CHECK_MACRO_CROSS.
   (AC_CHECK_FILES): Switch to AT_CHECK_CONFIGURE_AC.
   (AC_SYS_RESTARTABLE_SYSCALLS, AC_FUNC_WAIT3): Do not test in cross
   compilation mode.
   (AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK, AC_TRY_RUN)
   (AC_COMPILE_CHECK, AC_HAVE_LIBRARY): New manual AT_CHECK_AU_MACRO tests.

 * tests/c.at (Extensions, C keywords, AC_PROG_CPP requires AC_PROG_CC)
   (AC_NO_EXECUTABLES (working linker), AC_NO_EXECUTABLES (broken linker)):
   Switch to AT_CHECK_CONFIGURE_AC. Also convert case statements to AS_CASE.
   (Broken/missing compilers): Pass CC=no-such-compiler on the command
   line instead of hardwiring it in the configure script.

 * tests/local.mk (maintainer-check-c++): Remove target.
   (maintainer-check): Run the ordinary ‘make check’ as well as
   ‘make maintainer-check-posix’.
2020-11-30 11:45:27 -05:00
bin Avoid ‘new File::Temp’ in Perl scripts. 2020-11-30 11:45:26 -05:00
build-aux make fetch and update savannah gitweb urls to cgit. 2020-11-30 11:45:24 -05:00
doc AC_FUNC_SETPGRP: Don’t depend on the return type of setpgrp. 2020-11-30 11:45:25 -05:00
lib Overhaul Erlang support. 2020-11-30 11:45:27 -05:00
m4 make fetch 2020-09-03 12:08:31 -04:00
man Generate manpages directly from source code. 2020-08-21 16:23:32 -04:00
tests AT_CHECK_MACRO: test C++ as well as C, cross as well as native 2020-11-30 11:45:27 -05:00
.gitattributes maint: don't sync elisp-comp or missing from gnulib 2012-06-27 16:59:21 -06:00
.gitignore Check in install-sh as synced from automake (#110368) 2020-11-09 13:51:20 -05:00
.prev-version maint: post-release administrivia 2012-04-24 21:06:32 -06:00
.x-update-copyright
AUTHORS maint: make update-copyright 2020-01-01 11:45:50 -08:00
BUGS BUGS: Remove mention of old shells lacking functions. 2020-08-28 16:44:59 -04:00
cfg.mk Rewrite fetch.sh in Perl. 2020-09-11 14:51:00 -04:00
ChangeLog.0 Prefer HTTPS to FTP and HTTP 2017-09-16 17:48:51 -07:00
ChangeLog.1 Prefer HTTPS to FTP and HTTP 2017-09-16 17:48:51 -07:00
ChangeLog.2 Prefer HTTPS to FTP and HTTP 2017-09-16 17:48:51 -07:00
ChangeLog.3 maint: update URLs 2017-09-23 12:49:23 -07:00
configure.ac Add NetBSD /bin/sh to the -n whitelist. 2020-08-26 15:08:26 -04:00
COPYING Update links in COPYING, COPYINGv3, and COPYING.EXCEPTION. 2020-07-10 16:43:22 -04:00
COPYING.EXCEPTION Update links in COPYING, COPYINGv3, and COPYING.EXCEPTION. 2020-07-10 16:43:22 -04:00
COPYINGv3 Update links in COPYING, COPYINGv3, and COPYING.EXCEPTION. 2020-07-10 16:43:22 -04:00
GNUmakefile Partially revert e54e3f90: restore use of $(MAKE) in error message. 2020-08-04 08:46:59 -04:00
HACKING Update release advice 2020-06-29 17:08:27 -07:00
maint.mk sc_error_message_uppercase: allow fully uppercased words 2020-11-30 11:45:25 -05:00
Makefile.am Generate manpages directly from source code. 2020-08-21 16:23:32 -04:00
NEWS AT_CHECK_MACRO: test C++ as well as C, cross as well as native 2020-11-30 11:45:27 -05:00
README maint: make update-copyright 2020-01-01 11:45:50 -08:00
README-alpha maint: make update-copyright 2020-01-01 11:45:50 -08:00
README-hacking make fetch and update savannah gitweb urls to cgit. 2020-11-30 11:45:24 -05:00
THANKS maint: make update-copyright 2020-01-01 11:45:50 -08:00
TODO * TODO: Add -Werror support. 2020-08-06 12:28:40 -07:00

-*- text -*-

Autoconf

Autoconf is an extensible package of M4 macros that produce shell
scripts to automatically configure software source code packages.
These scripts can adapt the packages to many kinds of UNIX-like
systems without manual user intervention.  Autoconf creates a
configuration script for a package from a template file that lists the
operating system features that the package can use, in the form of M4
macro calls.

Producing configuration scripts using Autoconf requires GNU M4 and
Perl.  You should install GNU M4 (version 1.4.6 or later is required;
1.4.14 or later is recommended) and Perl (5.006 or later) before
configuring Autoconf, so that Autoconf's configure script can find
them.  The configuration scripts produced by Autoconf are
self-contained, so their users do not need to have Autoconf (or GNU
M4, Perl, etc.).

You can get GNU M4 here:

https://ftp.gnu.org/gnu/m4/

The file INSTALL should be distributed with packages that use
Autoconf-generated configure scripts and Makefiles that conform to the
GNU coding standards.  The package's README can just give an overview
of the package, where to report bugs, and a pointer to INSTALL for
instructions on compilation and installation.  This removes the need
to maintain many similar sets of installation instructions.

Be sure to read BUGS and INSTALL.

Mail suggestions to autoconf@gnu.org, report bugs to
bug-autoconf@gnu.org, and submit patches to autoconf-patches@gnu.org.
All changes can be tracked at the read-only autoconf-commit@gnu.org.
Always include the Autoconf version number, which you can get by
running `autoconf --version'.  Archives of bug-autoconf@gnu.org can be
found in <https://lists.gnu.org/archive/html/bug-autoconf/>, and
similarly for the other mailing lists.

Licensing

Autoconf is released under the General Public License version 3 (GPLv3+).
Additionally, Autoconf includes a licensing exception in some of its
source files; see the respective copyright notices for how your
project is impacted by including scripts generated by Autoconf, and the
COPYING.EXCEPTION file for the exception in terms of the Additional
Permissions as described in section 7 of GPLv3.

For more licensing information, see
<https://www.gnu.org/licenses/gpl-faq.html> and
<https://www.gnu.org/licenses/exceptions.html>.

For any copyright year range specified as YYYY-ZZZZ in this package
note that the range specifies every single year in that closed interval.

-----

Copyright (C) 1992-1994, 1998, 2000-2017, 2020 Free Software Foundation,
Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.  This file is offered as-is,
without warranty of any kind.