diff options
author | Zack Weinberg <zackw@panix.com> | 2020-12-23 12:14:06 -0500 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-12-23 13:12:57 -0500 |
commit | ec90049dfcf4538750e61d675d885157fa5ca7f8 (patch) | |
tree | 31aa0e5ab7d8d77f670bf23cece711ac9b0da09c /doc | |
parent | ea9d7d9f1fc8a2ed91a8017683acf424ac7886ed (diff) | |
download | autoconf-ec90049dfcf4538750e61d675d885157fa5ca7f8.tar.gz |
Use -fno-builtin, not -Werror, in AC_CHECK_DECLS (#110400)
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 82ef7805faffa151e724aa76c245ec590d174580,
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 82ef7805faffa151e724aa76c245ec590d174580.
* 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.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/autoconf.texi | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/doc/autoconf.texi b/doc/autoconf.texi index a67cccb2..5e17280e 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -6583,12 +6583,6 @@ parentheses for types which can be zero-initialized: AC_CHECK_DECL([basename(char *)]) @end example -Some compilers don't indicate every missing declaration by the error -status. This macro checks the standard error from such compilers and -considers a declaration missing if any warnings have been reported. For -most compilers, though, warnings do not affect this macro's outcome -unless @code{AC_LANG_WERROR} is also specified. - This macro caches its result in the @code{ac_cv_have_decl_@var{symbol}} variable, with characters not suitable for a variable name mapped to underscores. @@ -6649,12 +6643,6 @@ You fall into the second category only in extreme situations: either your files may be used without being configured, or they are used during the configuration. In most cases the traditional approach is enough. -Some compilers don't indicate every missing declaration by the error -status. This macro checks the standard error from such compilers and -considers a declaration missing if any warnings have been reported. For -most compilers, though, warnings do not affect this macro's outcome -unless @code{AC_LANG_WERROR} is also specified. - This macro caches its results in @code{ac_cv_have_decl_@var{symbol}} variables, with characters not suitable for a variable name mapped to underscores. |