You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/04/26 01:24:54 UTC

[2/2] mesos git commit: Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.

Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.

After this a whole bunch more of the C++11 checks can be removed, we
can unconditionally use -std=c++11, among other things with this
change.

Note that we don't explicitly check the clang version number since
extracting it is hard (OS X clang behaves differently than Linux
clang), and 'clang -dumpversion' always reports 4.2.1 for
compatibility with some random tools that used GCC.

Review: https://reviews.apache.org/r/33193


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0f5c78fa
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0f5c78fa
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0f5c78fa

Branch: refs/heads/master
Commit: 0f5c78fad3423181f7227027eb42d162811514e7
Parents: b4bbfd6
Author: Cody Maloney <co...@mesosphere.io>
Authored: Thu Apr 23 14:38:48 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sat Apr 25 16:21:46 2015 -0700

----------------------------------------------------------------------
 configure.ac | 80 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 50 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0f5c78fa/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 7f9e529..d987b35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -524,7 +524,7 @@ AC_LANG_PUSH([C++])
 AC_COMPILE_IFELSE(
 [AC_LANG_PROGRAM([], [[
 #ifndef __clang__
-       not clang
+#error Force the compiler to fail and set CLANG=no.
 #endif
 ]])],
 [CLANG=yes], [CLANG=no])
@@ -534,6 +534,12 @@ AC_MSG_RESULT([$CLANG])
 AC_SUBST([CLANG])
 
 if test "x$CLANG" = "xno"; then
+  # We ASSUME if it's not clang than it's GCC, but that might not be
+  # the case.
+  #
+  # TODO(benh): Have a check which determines if this is really GCC or
+  # something else so we can give people a nicer error message.
+  #
   # Check the version of gcc and add any flags as appropriate. Note
   # that '-dumpversion' works for clang as well but as of clang 3.3 it
   # reports version 4.2.1 (for gcc backwards compatibility).
@@ -541,17 +547,6 @@ if test "x$CLANG" = "xno"; then
   AC_MSG_NOTICE([GCC version: $GCC_VERSION])
   test $? = 0 || AC_MSG_ERROR([failed to determine version of gcc])
 
-  # Check for GCC version 4.4.
-  AX_COMPARE_VERSION([$GCC_VERSION], [eq2], [4.4],
-                     [is_gxx44=yes], [is_gxx44=no])
-  if test "x$is_gxx44" = "xyes"; then
-    AC_MSG_NOTICE([Setting up CXXFLAGS for g++-4.4])
-    # We fail to build some protobuf generated code with gcc 4.4
-    # without setting -fno-strict-aliasing.
-    CFLAGS="$CFLAGS -fno-strict-aliasing"
-    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
-  fi
-
   # Check for GCC version >= 4.8.
   AX_COMPARE_VERSION([$GCC_VERSION], [ge], [4.8],
                      [is_ge_gxx48=yes], [is_ge_gxx48=no])
@@ -563,22 +558,11 @@ if test "x$CLANG" = "xno"; then
     # TODO(brenden): Remove this when Boost has a resolution.
     CFLAGS="${CFLAGS} -Wno-unused-local-typedefs"
     CXXFLAGS="${CXXFLAGS} -Wno-unused-local-typedefs"
+  else
+    # GCC < 4.8 is not supported.
+    AC_MSG_ERROR([GCC 4.8 or higher is required for compiling Mesos])
   fi
-
-  # Check for GCC version == 4.7 and fail. Starting with 4.7 the '#if
-  # __cplusplus >= 201103L' will evaluate to true which means the
-  # C++11 code paths will be compiled but certain C++11 features that
-  # we use are not supported by 4.7. Since we're requiring C++11 going
-  # forward we can't support this compiler.
-  AX_COMPARE_VERSION([$GCC_VERSION], [eq2], [4.7],
-                     [is_gxx47=yes], [is_gxx47=no])
-  if test "x$is_gxx47" = "xyes"; then
-    AC_MSG_ERROR([Unable to build with g++-4.7 due to missing C++11 features])
-  fi
-
-# CLANG=yes
-else
-
+else # CLANG=yes
   # Check if -Wno-unused-local-typedef is needed by checking a sample
   # compilation which contains a local unused typedef.
   # This is needed because Boost 1.53.0 fails to compile with upstream
@@ -604,11 +588,47 @@ else
   fi
 fi
 
-
-# Ensure we can build the C++11 features we expect, and set the std
-# CXXFLAG as appropriate.
+# Ensure we can build the C++11 features we expect, and set the --std=
+# flag and CXXFLAG environment variable as appropriate.
 AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
 
+# Blacklist known incompatible C++ standard libraries to reduce chance
+# of users accidentally using them.
+#  - libstdc++ (Pre 4.8.0, version datestamp 20130322)
+#  - libc++ (Pre 3.5.0, version string 1101)
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE(
+[AC_LANG_SOURCE([[
+#include <vector>
+
+#ifdef __GLIBCXX__
+#if __GLIBCXX__ < 20130322
+#error Force the compiler to fail and set COMPATIBLE_CXX_STDLIB=no.
+#endif
+#elif _LIBCPP_VERSION < 1101
+#error Force the compiler to fail and set COMPATIBLE_CXX_STDLIB=no.
+#endif
+]])],
+[COMPATIBLE_CXX_STDLIB=yes], [COMPATIBLE_CXX_STDLIB=no])
+AC_LANG_POP([C++])
+
+if test "x$COMPATIBLE_CXX_STDLIB" = "xno"; then
+  AC_MSG_ERROR([known incompatible C++ Standard library in use
+-------------------------------------------------------------------
+libstdc++ from GCC 4.8.0+ or libc++ from LLVM/Clang 3.5+ is required.
+
+If a new enough GCC installed (4.8.0+) it should automatically find
+the right libstdc++. If clang is in use, it will automatically find
+the newest libstdc++ on the host.
+
+If you are trying to use a different compiler from (clang, gcc) or a
+alternate C++ Standard Library implementation, likely the flags being
+passed to the compiler (CXXFLAGS) are not currently correct / being
+picked up.
+-------------------------------------------------------------------
+])
+fi
+
 case "$host_os" in
   darwin* )
    # If we're using clang, we need to pass -stdlib=libc++ too.


Re: [2/2] mesos git commit: Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.

Posted by Cody Maloney <co...@mesosphere.io>.
Note that we will want to keep the library checks in addition. This should
ideally just update / replace all the "Check for what compiler it is",
which we use when setting the various needed additional compiler flags
(-Wno-unused-local-typedef{s} primarily).

On Mon, Apr 27, 2015 at 9:37 AM, James Peach <jo...@gmail.com> wrote:

>
> > On Apr 26, 2015, at 12:17 PM, Benjamin Hindman <be...@eecs.berkeley.edu>
> wrote:
> >
> > That would be great James! We took an MVP approach for now, but it would
> be
> > great if we could give even better error messages or warning messages for
> > compilers that we don't regularly test or work with.
>
> OK, I’ll take a crack at is in MESOS-2666
>
> >
> > On Sun, Apr 26, 2015 at 11:51 AM, James Peach <jo...@gmail.com> wrote:
> >
> >> On Apr 25, 2015, at 4:24 PM, benh@apache.org wrote:
> >>>
> >>> Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.
> >>>
> >>> After this a whole bunch more of the C++11 checks can be removed, we
> >>> can unconditionally use -std=c++11, among other things with this
> >>> change.
> >>>
> >>> Note that we don't explicitly check the clang version number since
> >>> extracting it is hard (OS X clang behaves differently than Linux
> >>> clang), and 'clang -dumpversion' always reports 4.2.1 for
> >>> compatibility with some random tools that used GCC.
> >>
> >> Would it make sense to use AX_COMPILER_VENDOR and AX_COMPILER_VERSION
> here?
> >>
> >>
> >> http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
> >>
> >> http://www.gnu.org/software/autoconf-archive/ax_compiler_version.html
> >>
> >> J
> >>
>
>

Re: [2/2] mesos git commit: Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.

Posted by James Peach <jo...@gmail.com>.
> On Apr 26, 2015, at 12:17 PM, Benjamin Hindman <be...@eecs.berkeley.edu> wrote:
> 
> That would be great James! We took an MVP approach for now, but it would be
> great if we could give even better error messages or warning messages for
> compilers that we don't regularly test or work with.

OK, I’ll take a crack at is in MESOS-2666

> 
> On Sun, Apr 26, 2015 at 11:51 AM, James Peach <jo...@gmail.com> wrote:
> 
>> On Apr 25, 2015, at 4:24 PM, benh@apache.org wrote:
>>> 
>>> Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.
>>> 
>>> After this a whole bunch more of the C++11 checks can be removed, we
>>> can unconditionally use -std=c++11, among other things with this
>>> change.
>>> 
>>> Note that we don't explicitly check the clang version number since
>>> extracting it is hard (OS X clang behaves differently than Linux
>>> clang), and 'clang -dumpversion' always reports 4.2.1 for
>>> compatibility with some random tools that used GCC.
>> 
>> Would it make sense to use AX_COMPILER_VENDOR and AX_COMPILER_VERSION here?
>> 
>> 
>> http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
>> 
>> http://www.gnu.org/software/autoconf-archive/ax_compiler_version.html
>> 
>> J
>> 


Re: [2/2] mesos git commit: Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.

Posted by Benjamin Hindman <be...@eecs.berkeley.edu>.
That would be great James! We took an MVP approach for now, but it would be
great if we could give even better error messages or warning messages for
compilers that we don't regularly test or work with.

On Sun, Apr 26, 2015 at 11:51 AM, James Peach <jo...@gmail.com> wrote:

> On Apr 25, 2015, at 4:24 PM, benh@apache.org wrote:
> >
> > Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.
> >
> > After this a whole bunch more of the C++11 checks can be removed, we
> > can unconditionally use -std=c++11, among other things with this
> > change.
> >
> > Note that we don't explicitly check the clang version number since
> > extracting it is hard (OS X clang behaves differently than Linux
> > clang), and 'clang -dumpversion' always reports 4.2.1 for
> > compatibility with some random tools that used GCC.
>
> Would it make sense to use AX_COMPILER_VENDOR and AX_COMPILER_VERSION here?
>
>
> http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
>
> http://www.gnu.org/software/autoconf-archive/ax_compiler_version.html
>
> J
>

Re: [2/2] mesos git commit: Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.

Posted by James Peach <jo...@gmail.com>.
On Apr 25, 2015, at 4:24 PM, benh@apache.org wrote:
> 
> Warn if g++ < 4.8 or a C++ standard library is too old for Mesos.
> 
> After this a whole bunch more of the C++11 checks can be removed, we
> can unconditionally use -std=c++11, among other things with this
> change.
> 
> Note that we don't explicitly check the clang version number since
> extracting it is hard (OS X clang behaves differently than Linux
> clang), and 'clang -dumpversion' always reports 4.2.1 for
> compatibility with some random tools that used GCC.

Would it make sense to use AX_COMPILER_VENDOR and AX_COMPILER_VERSION here?

	http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
	http://www.gnu.org/software/autoconf-archive/ax_compiler_version.html

J