Skip to content

Commit

Permalink
Add checks for new-enough clang++, g++ and libstdc++ versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Mar 28, 2015
1 parent c3f7417 commit a367060
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test -z "$WFLAGS" || CFLAGS="$CFLAGS $WFLAGS" CXXFLAGS="$CXXFLAGS $WFLAGS"

AC_LANG(C++)
AX_CXX_COMPILE_STDCXX_11(noext,mandatory)
AX_FRESH_COMPILER

# Our large include path set makes for annoying warnings without this
AX_APPEND_COMPILE_FLAGS([-Wno-unused-command-line-argument])
Expand Down
57 changes: 57 additions & 0 deletions m4/ax_fresh_compiler.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2015 Stellar Development Foundation and contributors. Licensed
# under the ISC License. See the COPYING file at the top-level directory of
# this distribution or at http://opensource.org/licenses/ISC

AC_DEFUN([AX_FRESH_COMPILER],
[
# Check for compiler versions. We need g++ >= 4.9 and/or clang++ >= 3.5
AC_LANG_PUSH([C++])
case "${CXX}" in
*clang*)
AC_MSG_CHECKING([for clang >= 3.5])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 5)
#error old clang++
#endif
#if defined(__apple_build_version__)
#if __clang_major__ < 6
#error old clang++
#endif
#endif
)], [AC_MSG_RESULT(yes)], [AC_MSG_ERROR([clang++ is < required version 3.5])])
;;
*g++*)
AC_MSG_CHECKING([for g++ >= 4.9])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
#error old g++
#endif
)], [AC_MSG_RESULT(yes)], [AC_MSG_ERROR([g++ is < required version 4.9])])
;;
esac
# Even if we have clang++ >= 3.5 we need to be sure we don't have an
# old/broken libstdc++, which we often get if there's an old g++ install
# kicking around. Unfortunately there's no way to test this directly; we
# try a handful of tell-tale C++11 features completed in 4.9 instead.
AC_MSG_CHECKING([for a sufficiently-new libstdc++])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[
[#include <cstddef>]
[#include <new>]
[#include <exception>]
],
[
auto a = sizeof(std::max_align_t);
auto b = std::get_new_handler();
auto c = std::get_terminate();
auto d = std::get_unexpected();
]
)],
[AC_MSG_RESULT(yes)],
[AC_MSG_ERROR([missing new C++11 features, probably libstdc++ < 4.9])
])
AC_LANG_POP([C++])
])

5 comments on commit a367060

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jedmccaleb
at graydon@a367060

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging graydon/stellar-core/autoconf-get-picky-about-compilers = a367060 into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

graydon/stellar-core/autoconf-get-picky-about-compilers = a367060 merged ok, testing candidate = 4048c30

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4048c30

Please sign in to comment.