As many of you know, OS X 10.9 (Mavericks) made clang the default compiler
which broke Mesos. We had a couple of options:

  (1) Install and use gcc instead.
  (2) Get Mesos to build with clang.

Unfortunately, (1) wasn't sufficient because there were issues with linking
clang built libraries with gcc ones, especially for our Python bindings.
Doing (2) was also a non-starter because libprocess (the concurrency
library Mesos uses) had hard dependencies on gcc (or more precisely on
libstdc++). Our intuition was that the best way to eliminate those
dependencies was to refactor the libprocess code to use C++11, and then
build Mesos using clang with C++11.

To that end I've pushed a branch at
https://github.com/benh/mesos/tree/c++11-and-clang that has 14 commits
enabling first C++11 in Mesos (and libprocess, and stout) and then C++11
with clang. I've thus far tested this on OS X 10.7 with gcc 4.2.1 (no
C++11), gcc 4.8 (with C++11), and clang 3.3 (with C++11, in fact, we force
clang to build with C++11). I'd love to get others trying it out! Note that
we don't expect to support earlier versions of gcc or clang for C++11.

You can compile with clang via:

  CC=/path/to/clang-3.3 CXX=/path/to/clang++-3.3 ../configure && make check

And via gcc 4.8 for C++11:

  CC=/path/to/gcc-4.8 CXX=/path/to/g++-4.8 ../configure --with-cxx11 &&
make check

At this point in time on OS X if you use a non-LLVM wrapped gcc (i.e., the
non-default gcc) you can't build Python unless you've built you're own
Python using the same compiler you're using for Mesos (since some compiler
options might not be valid for non-LLVM wrapped compilers). You can disable
Python via --disable-python (which is necessary for me using gcc 4.8
because I didn't build Python with gcc 4.8).

The changes necessary did involve upgrading the embedded third party
ZooKeeper dependency as well as adding a patch to the embedded glog
dependency. In the long run, the goal is to eliminate the embedded
dependencies all together. In the short-term, however, we wanted to unblock
people using Mesos on OS X for development and testing. The updates should
not have any negative impact on building Mesos without the embedded
libraries (if anything, this should help since some distributions required
Mesos to build against ZooKeeper 3.4.5) and until we have a glog
distribution that works with clang/C++11 we'll likely need to compromise
and keep the glog library and patch embedded but only for building on OS X.

As laid out in https://issues.apache.org/jira/browse/MESOS-750 we'll be
moving to "phase 3" after this code gets committed where we'll continue to
support both C++03 and C++11 compilers for at least another release (or
two) of Mesos.

Looking forward to feedback. Happy New Year!

Ben.

Reply via email to