Package: autoconf Version: 2.69-11 Severity: normal Tags: upstream Dear Maintainer,
When AC_CHECK_FUNC or AC_CHECK_FUNCS is called on a builtin function in gcc, the compiler emits a warning. For example, using memset() as an example builtin: warning: conflicting types for built-in function 'memset' [-Wbuiltin-declaration-mismatch] When -Werror is in CFLAGS, this is promoted to an error, causing configure to believe memset() was not found. See this very simple example configure.ac file: AC_INIT([test], [0.0]) AC_PROG_CC AC_CHECK_FUNC([memset]) AC_OUTPUT When the resulting configure script is run, you will find the line checking for memset... yes in the output. This is expected, since memset() is available. However, when the configure script is run as "./configure CFLAGS=-Werror", you will find this line in the output: checking for memset... no This is not the expected behavior because, as we have seen above, memset() is indeed available. Here is the relevant part of config.log: configure:2614: checking for memset configure:2614: gcc -o conftest -Werror conftest.c >&5 conftest.c:32:6: error: conflicting types for built-in function 'memset' [-Werror=builtin-declaration-mismatch] char memset (); ^~~~~~ cc1: all warnings being treated as errors configure:2614: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "test" | #define PACKAGE_TARNAME "test" | #define PACKAGE_VERSION "0.0" | #define PACKAGE_STRING "test 0.0" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | /* end confdefs.h. */ | /* Define memset to an innocuous variant, in case <limits.h> declares memset. | For example, HP-UX 11i <limits.h> declares gettimeofday. */ | #define memset innocuous_memset | | /* System header to define __stub macros and hopefully few prototypes, | which can conflict with char memset (); below. | Prefer <limits.h> to <assert.h> if __STDC__ is defined, since | <limits.h> exists even on freestanding compilers. */ | | #ifdef __STDC__ | # include <limits.h> | #else | # include <assert.h> | #endif | | #undef memset | | /* Override any GCC internal prototype to avoid an error. | Use char because int might match the return type of a GCC | builtin and then its argument prototype would still apply. */ | #ifdef __cplusplus | extern "C" | #endif | char memset (); | /* The GNU C library defines this for functions which it implements | to always fail with ENOSYS. Some functions are actually named | something starting with __ and the normal name is an alias. */ | #if defined __stub_memset || defined __stub___memset | choke me | #endif | | int | main () | { | return memset (); | ; | return 0; | } configure:2614: result: no When the configure script is run with CFLAGS='-Werror -Wno-builtin-declaration-mismatch', however, it *does* find memset(). That is because, with the warning disabled, it is not promoted to an error and therefore compiles successfully. My suggestion is to always append '-Wno-builtin-declaration-mismatch' to CFLAGS when checking for functions with AC_CHECK_FUNC and AC_CHECK_FUNCS. That way, those macros would find both library functions and builtins even when -Werror is in CFLAGS. Thanks, Asher P.S. A real world example of this bug is my "c2py" program at sv.nongnu.org/p/c2py. If you checkout the latest sources with cvs and configure with "./configure --enable-Werror", it will fail since some of the functions it requires are builtin. -- System Information: Debian Release: buster/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 4.19.0-4-amd64 (SMP w/2 CPU cores) Kernel taint flags: TAINT_FIRMWARE_WORKAROUND Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages autoconf depends on: ii debianutils 4.8.6.1 ii m4 1.4.18-2 ii perl 5.28.1-6 Versions of packages autoconf recommends: ii automake [automaken] 1:1.16.1-4 Versions of packages autoconf suggests: ii autoconf-archive 20180313-1 ii autoconf-doc 2.69-11 ii gettext 0.19.8.1-9 ii gnu-standards 2010.03.11-1 ii libtool 2.4.6-9 -- no debconf information