diff options
author | Dan Liew <daniel.liew@imperial.ac.uk> | 2014-08-20 18:29:36 +0100 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2014-09-14 15:41:24 -0700 |
commit | 1d3c741c7f074df863e94e9dfb70630eaadac6d2 (patch) | |
tree | 83775a93e424a77c1c8a9b388ea1ccc0a3848339 /autoconf | |
parent | 0aa44d4f61032836744d7a20f219af4463e99a23 (diff) | |
download | klee-1d3c741c7f074df863e94e9dfb70630eaadac6d2.tar.gz |
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.
Diffstat (limited to 'autoconf')
-rw-r--r-- | autoconf/configure.ac | 35 |
1 files changed, 33 insertions, 2 deletions
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 <atomic> +std::atomic<float> 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]) |