From 4c3ff68495f5fddfa9691130532ac1d4920ff040 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Fri, 26 Aug 2022 00:38:26 +0200 Subject: [configure.ac] Only check for compiler options late in the process Setting too many options already breaks some of autoconf's standard checks, e.g. for stdbool.h. configure:5449: checking for stdbool.h that conforms to C99 configure:5565: gcc -c -g -O2 -Wall -Werror -pedantic -pedantic-errors -Werror=pedantic -Wformat=2 -Wformat-overflow=2 -fstack-protector-strong -fstack-clash-protection -fsanitize=leak -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500 conftest.c >&5 conftest.c: In function 'main': conftest.c:125:14: error: the address of 's' will always evaluate as 'true' [-Werror=address] 125 | bool ps = &s; | ^~~~ conftest.c:130:16: error: the address of 't' will always evaluate as 'true' [-Werror=address] 130 | _Bool pt = &t; | ^~~~~ conftest.c:137:22: error: the address of 'a' will always evaluate as 'true' [-Werror=address] 137 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k | ^ conftest.c:137:27: error: the address of 'b' will always evaluate as 'true' [-Werror=address] 137 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k | ^ conftest.c:137:32: error: the address of 'c' will always evaluate as 'true' [-Werror=address] 137 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k | ^ conftest.c:137:37: error: the address of 'd' will always evaluate as 'true' [-Werror=address] 137 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k | ^ conftest.c:137:62: error: the address of 'i' will always evaluate as 'true' [-Werror=address] 137 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k | ^ --- configure.ac | 112 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 9d10ffb..ce13421 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,62 @@ m4_version_prereq([2.70],[],[AC_PROG_CC_C99]) AC_PROG_CPP AC_PROG_MAKE_SET +# Checks for libraries. + +# Check POSIX conformance level. +_want_posix_level=200112L +_posix_level_human=POSIX.1-2001 +AC_MSG_CHECKING([if the POSIX conformance level can be set to ${_posix_level_human}]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#define _POSIX_C_SOURCE ${_want_posix_level} +#include +#if _POSIX_VERSION != ${_want_posix_level} +#error incorrect _POSIX_VERSION +#endif +])], +[AC_MSG_RESULT([yes])], +[AC_MSG_RESULT([no]); + AC_MSG_FAILURE([this system does not conform to the ${_posix_level_human} standard]) +]) +AC_DEFINE_UNQUOTED([_POSIX_C_SOURCE], [${_want_posix_level}], [define the POSIX conformance level]) +CFLAGS=${CFLAGS-}${CFLAGS:+ }-D_POSIX_C_SOURCE=${_want_posix_level} + +# Define X/Open conformance level. +_want_xopen_level=500 +AC_DEFINE_UNQUOTED([_XOPEN_SOURCE], [${_want_xopen_level}], [define the X/Open conformance level]) +CFLAGS=${CFLAGS-}${CFLAGS:+ }-D_XOPEN_SOURCE=${_want_xopen_level} + +# Checks for header files. +AC_HEADER_STDC +AC_HEADER_STDBOOL +AC_HEADER_STAT + +AC_CHECK_HEADERS_ONCE([stdarg.h]) +AC_CHECK_HEADERS_ONCE([linux/limits.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_C_RESTRICT +AC_C_STRINGIZE +AC_C_VARARRAYS +AC_TYPE_SIZE_T +AC_TYPE_UINT8_T + +if test x"$ac_cv_c_vararrays" != x'yes' +then + AC_MSG_ERROR([$CC does not support variable-length arrays (VLAs)]) +fi + +# Checks for library functions. + +AC_CHECK_FUNCS_ONCE([getenv getpwuid stat]) +AC_CHECK_FUNCS_ONCE([strdup strncpy strncat]) + +AC_CHECK_FUNCS_ONCE([mktemp mkdtemp tempnam]) +AC_CHECK_DECLS([mkdtemp, mktemp], [], [], [[#include ]]) +AC_CHECK_DECLS([tempnam], [], [], [[#include ]]) + # Checks for compiler options. _cccheckingopts=$( # clang (newer versions) don't fail if they see an unknown argument. @@ -129,62 +185,6 @@ AC_DEFINE_UNQUOTED([SK_WARN_UNUSED_RESULT], [${_sk_warn_unused_result:-/* warn_u AC_DEFINE_UNQUOTED([HAVE_CC_NONNULL_CHECK], $((_sk_cc_nonnull_check)), [Define to 1 if the CC supports __attribute__(nonnull)]) -# Checks for libraries. - -# Check POSIX conformance level. -_want_posix_level=200112L -_posix_level_human=POSIX.1-2001 -AC_MSG_CHECKING([if the POSIX conformance level can be set to ${_posix_level_human}]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -#define _POSIX_C_SOURCE ${_want_posix_level} -#include -#if _POSIX_VERSION != ${_want_posix_level} -#error incorrect _POSIX_VERSION -#endif -])], -[AC_MSG_RESULT([yes])], -[AC_MSG_RESULT([no]); - AC_MSG_FAILURE([this system does not conform to the ${_posix_level_human} standard]) -]) -AC_DEFINE_UNQUOTED([_POSIX_C_SOURCE], [${_want_posix_level}], [define the POSIX conformance level]) -CFLAGS=${CFLAGS-}${CFLAGS:+ }-D_POSIX_C_SOURCE=${_want_posix_level} - -# Define X/Open conformance level. -_want_xopen_level=500 -AC_DEFINE_UNQUOTED([_XOPEN_SOURCE], [${_want_xopen_level}], [define the X/Open conformance level]) -CFLAGS=${CFLAGS-}${CFLAGS:+ }-D_XOPEN_SOURCE=${_want_xopen_level} - -# Checks for header files. -AC_HEADER_STDC -AC_HEADER_STDBOOL -AC_HEADER_STAT - -AC_CHECK_HEADERS_ONCE([stdarg.h]) -AC_CHECK_HEADERS_ONCE([linux/limits.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_C_INLINE -AC_C_RESTRICT -AC_C_STRINGIZE -AC_C_VARARRAYS -AC_TYPE_SIZE_T -AC_TYPE_UINT8_T - -if test x"$ac_cv_c_vararrays" != x'yes' -then - AC_MSG_ERROR([$CC does not support variable-length arrays (VLAs)]) -fi - -# Checks for library functions. - -AC_CHECK_FUNCS_ONCE([getenv getpwuid stat]) -AC_CHECK_FUNCS_ONCE([strdup strncpy strncat]) - -AC_CHECK_FUNCS_ONCE([mktemp mkdtemp tempnam]) -AC_CHECK_DECLS([mkdtemp, mktemp], [], [], [[#include ]]) -AC_CHECK_DECLS([tempnam], [], [], [[#include ]]) - # Add debug support AC_ARG_ENABLE( [debug], -- cgit v1.2.3