summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Camera <skonfig@dtnr.ch>2022-08-26 00:31:18 +0200
committerDennis Camera <skonfig@dtnr.ch>2022-08-26 00:31:18 +0200
commitae193be2239144acb306b8ffac408130db441ce9 (patch)
tree429f970d7acfb7648fe156360982816e38949376
parent494fe560e6e0367cc64f6796d103a296e49191ec (diff)
downloadskonfig-c-ae193be2239144acb306b8ffac408130db441ce9.tar.gz
skonfig-c-ae193be2239144acb306b8ffac408130db441ce9.zip
[configure.ac] Fix false positive for -fstack-clash-protection with Apple Clang
Newer (> ~10) versions of Clang don't exit if they see an unknown argument but only log a warning by default. So we check if the compiler supports
-Werror=unused-command-line-argument and if so, we use it to check if the compiler options are supported.
-rw-r--r--configure.ac11
1 files changed, 8 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index debf933..199a2fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,7 +48,12 @@ AC_DEFINE_UNQUOTED([_XOPEN_SOURCE], [${_want_xopen_level}], [define the X/Open c
CFLAGS=${CFLAGS-}${CFLAGS:+ }-D_XOPEN_SOURCE=${_want_xopen_level}
-# Check compiler options
+# Checks for compiler options.
+_cccheckingopts=$(
+ # clang (newer versions) don't fail if they see an unknown argument.
+ CFLAGS=-Werror=unused-command-line-argument
+ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [])], [echo "${CFLAGS}"], [])
+)
check_ccopt() { (
_ccopt=${1:?}
case ${CFLAGS-} in
@@ -59,7 +64,7 @@ check_ccopt() { (
esac
AC_MSG_CHECKING([whether ${CC} supports ${_ccopt}])
- CFLAGS=${CFLAGS-}${CFLAGS:+ }${_ccopt}
+ CFLAGS="${CFLAGS-} ${_cccheckingopts-} ${_ccopt}"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [])],
[AC_MSG_RESULT([yes]); return 0],
@@ -89,7 +94,7 @@ check_set_ccopt -fsanitize=address && {
}
check_set_ccopt -fsanitize=undefined
-# Check compiler capabilities
+# Checks for compiler "C" capabilities
AX_C___ATTRIBUTE__
if test x"${ax_cv___attribute__}" = x'yes'