summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSitsofe Wheeler <sitsofe@yahoo.com>2020-07-25 08:46:15 +0100
committerSitsofe Wheeler <sitsofe@yahoo.com>2020-07-25 17:20:43 +0100
commitbb012314f734b9de3b2fc198db2c4e3e060db240 (patch)
tree877c3385a105da1f79d2449fdec5e387f09fd6ec
parent1d458e5b8044d81b96cccfc82e3fd99cbb1eebf9 (diff)
downloadfio-bb012314f734b9de3b2fc198db2c4e3e060db240.tar.gz
fio-bb012314f734b9de3b2fc198db2c4e3e060db240.tar.bz2
configure: check for C11 atomics support
Since 3932f8be718fc4ca3b863c51c0d567821d75c003 ("arch/arch.h: Introduce atomic_{load_acquire,store_release}()") fio has needed C11 atomic support and this is only provided from gcc 4.9 / clang 3.6 onwards (http://stdatomic.gforge.inria.fr/#sec-2 ). Make this clearer by doing the following: - Add configure check for C11 atomics support and bail out with a (friendly) message pointing at compiler version if it's not there - Remove the minimum compiler version check from compiler.h as it is now redundant I've avoided doing an explicit compiler version check because Apple's clang can have a wildly different version to upstream (https://stackoverflow.com/a/33614612 ). Tested on: - CentOS 7 with default gcc 4.8.5 (correctly errors with message) - CentOS 7 docker container using llvm-toolset-7 to provide clang 5.0.1 (works) - CentOS 7 docker container using devtool-toolset-7 to provide gcc 7.3.1 (works) - Ubuntu 16.04 with clang-3.5 (correctly errors with message) - Ubuntu 16.04 with clang-3.6 installed (works) - macOS 10.14.6 with clang-1001.0.46.4 (works) v2: - Rebase - Reword failure message and stop mentioning fio version number Fixes: https://github.com/axboe/fio/issues/1047 Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
-rw-r--r--compiler/compiler.h7
-rwxr-xr-xconfigure33
2 files changed, 19 insertions, 21 deletions
diff --git a/compiler/compiler.h b/compiler/compiler.h
index 8c0eb9d1..8a784b92 100644
--- a/compiler/compiler.h
+++ b/compiler/compiler.h
@@ -1,13 +1,6 @@
#ifndef FIO_COMPILER_H
#define FIO_COMPILER_H
-/* IWYU pragma: begin_exports */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __clang_major__ >= 6
-#else
-#error Compiler too old, need at least gcc 4.9
-#endif
-/* IWYU pragma: end_exports */
-
#define __must_check __attribute__((warn_unused_result))
#define __compiletime_warning(message) __attribute__((warning(message)))
diff --git a/configure b/configure
index 6a7bdeef..25216c63 100755
--- a/configure
+++ b/configure
@@ -496,20 +496,6 @@ else
fi
##########################################
-# check compiler version
-
-cat > $TMPC <<EOF
-#include "$(pwd)/compiler/compiler.h"
-int main(void)
-{
- return 0;
-}
-EOF
-if ! compile_prog "" "" "compiler check"; then
- fatal "Your compiler is too old, needs GCC 4.9 or higher"
-fi
-
-##########################################
# check endianness
if test "$bigendian" != "yes" ; then
bigendian="no"
@@ -565,6 +551,25 @@ fi
print_config "Static build" "$build_static"
##########################################
+# check for C11 atomics support
+cat > $TMPC <<EOF
+#include <stdatomic.h>
+int main(void)
+{
+ _Atomic unsigned v;
+ atomic_load(&v);
+ return 0;
+}
+EOF
+if ! compile_prog "" "" "C11 atomics"; then
+ echo
+ echo "Your compiler doesn't support C11 atomics. gcc 4.9/clang 3.6 are the"
+ echo "minimum versions with it - perhaps your compiler is too old?"
+ fatal "C11 atomics support not found"
+fi
+
+
+##########################################
# check for wordsize
wordsize="0"
cat > $TMPC <<EOF