From 1d3c741c7f074df863e94e9dfb70630eaadac6d2 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 20 Aug 2014 18:29:36 +0100 Subject: Provide --enable-cxx11 configure option to enable building with C++11. For LLVM >= 3.5 explicitly force this to be enabled otherwise we can't compile against LLVM. - Some minor tweaks to the configure logic by me (Daniel Dunbar), to ensure C++ compiler is tested before these checks run, and to properly restore CXXFLAGS. --- autoconf/configure.ac | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'autoconf') diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 18822396..97bd5eb6 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -32,8 +32,9 @@ AH_TOP([#ifndef KLEE_CONFIG_CONFIG_H #define KLEE_CONFIG_CONFIG_H]) AH_BOTTOM([#endif]) -dnl FIXME: Make out of tree builds work. - +dnl We need to check for the compiler up here to avoid anything else +dnl starting with a different one. +AC_PROG_CXX(g++ clang++ ) AC_LANG([C++]) dnl ************************************************************************** @@ -154,6 +155,36 @@ else fi AC_SUBST(REQUIRES_RTTI,$requires_rtti) +dnl Provide option to use C++11 +AC_ARG_ENABLE([cxx11],[ --enable-cxx11 Build using C++11], [klee_use_cxx11=1], [klee_use_cxx11=0]) + +dnl LLVM >= 3.5 requires C++11 +AC_MSG_CHECKING([if LLVM needs C++11]) +if test '(' $llvm_version_major -eq 3 -a $llvm_version_minor -ge 5 ')' -o '(' $llvm_version_major -gt 3 ')' ; then + klee_use_cxx11=1 + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +dnl Check if the compiler supports C++11 (this check is taken from LLVM's configure.ac). +if test X${klee_use_cxx11} = X1; then + klee_old_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=c++11" + AC_LINK_IFELSE([AC_LANG_SOURCE([[ +#include +std::atomic x(0.0f); +int main() { return (float)x; } +]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([C++11 not supported])]) + CXXFLAGS="$klee_old_cxxflags" +fi + +AC_SUBST(KLEE_USE_CXX11,$klee_use_cxx11) + + AC_ARG_WITH(llvm-build-mode, AS_HELP_STRING([--with-llvm-build-mode], [LLVM build mode (e.g. Debug or Release, default autodetect)]),,[with_llvm_build_mode=check]) -- cgit 1.4.1