summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-08-25 16:50:52 +0200
committerHaru <haru@dotalux.com>2018-08-25 17:52:21 +0200
commit919f004106a705947a52ead1b6b23238cbe10218 (patch)
tree40040c86649ae45319c31f34db18692d955f8f03
parent234189f34e5f055c82654b8cd35330822e8aa4d7 (diff)
downloadhercules-919f004106a705947a52ead1b6b23238cbe10218.tar.gz
hercules-919f004106a705947a52ead1b6b23238cbe10218.tar.bz2
hercules-919f004106a705947a52ead1b6b23238cbe10218.tar.xz
hercules-919f004106a705947a52ead1b6b23238cbe10218.zip
Change language specification to c11 in the autoconf builds
Fixes an issue with certain glibc versions using the emulated `_Static_assert` (allowing only one assertion per scope) despite the compiler having built-in support for the c11 version. Fixes builds in Debian stretch and other distributions. Signed-off-by: Haru <haru@dotalux.com>
-rwxr-xr-xconfigure47
-rw-r--r--configure.ac32
-rw-r--r--src/common/cbasetypes.h6
3 files changed, 76 insertions, 9 deletions
diff --git a/configure b/configure
index 3a33cebd3..180fe971d 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.ac 515eed8ee.
+# From configure.ac 234189f34.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69.
#
@@ -4776,7 +4776,50 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# -Werror-implicit-function-declaration -Wtrampolines
# -Wjump-misses-init
-CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wextra -Wno-sign-compare -std=c99"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -std=c11" >&5
+$as_echo_n "checking whether $CC supports -std=c11... " >&6; }
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -std=c11"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -std=c1x" >&5
+$as_echo_n "checking whether $CC supports -std=c1x... " >&6; }
+ CFLAGS="$OLD_CFLAGS -std=c1x"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, falling back to -std=c99" >&5
+$as_echo "no, falling back to -std=c99" >&6; }
+ CFLAGS="$OLD_CFLAGS -std=c99"
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wextra -Wno-sign-compare"
CPPFLAGS="$CPPFLAGS -I../common"
LDFLAGS="$LDFLAGS"
diff --git a/configure.ac b/configure.ac
index 1bb30b09f..4d5f4bcfd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -638,7 +638,37 @@ AC_LANG([C])
# -Werror-implicit-function-declaration -Wtrampolines
# -Wjump-misses-init
-CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wextra -Wno-sign-compare -std=c99"
+AC_MSG_CHECKING([whether $CC supports -std=c11])
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -std=c11"
+AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+
+ AC_MSG_CHECKING([whether $CC supports -std=c1x])
+ CFLAGS="$OLD_CFLAGS -std=c1x"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no, falling back to -std=c99])
+ CFLAGS="$OLD_CFLAGS -std=c99"
+ ]
+ )
+ ],
+ [
+ AC_MSG_RESULT([guessing no])
+ CFLAGS="$OLD_CFLAGS -std=c99"
+ ]
+)
+
+CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wextra -Wno-sign-compare"
CPPFLAGS="$CPPFLAGS -I../common"
LDFLAGS="$LDFLAGS"
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index 3fc41bb23..89f7f8588 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -460,12 +460,6 @@ typedef char bool;
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
// C11 version
#define STATIC_ASSERT(ex, msg) _Static_assert(ex, msg)
-#elif __has_feature(c_static_assert)
-// Clang support (as per http://clang.llvm.org/docs/LanguageExtensions.html)
-#define STATIC_ASSERT(ex, msg) _Static_assert(ex, msg)
-#elif defined(__GNUC__) && GCC_VERSION >= 40700
-// GCC >= 4.7 is known to support it
-#define STATIC_ASSERT(ex, msg) _Static_assert(ex, msg)
#elif defined(_MSC_VER)
// MSVC doesn't support it, but it accepts the C++ style version
#define STATIC_ASSERT(ex, msg) static_assert(ex, msg)