Page MenuHome

blender2.8 branch needs C++11 to compile
Needs RevisionPublic

Authored by Chaitanya (cyrax) on Dec 2 2016, 6:24 AM.

Details

Summary

Branch blender2.8 was failing to compile because on Linux Mint/Ubuntu 14.04 the gcc version is 4.8. gcc 6.0 makes C++11 the default profile whereas 4.8 does not.
This fix helps force C++11 profile to be loaded. However this would lead to a conflict as Blender/master requires 4.2 as minimum.
This is my first commit, so please let me know if there is anything I need to add.

Diff Detail

Repository
rB Blender

Event Timeline

Chaitanya (cyrax) retitled this revision from to blender2.8 branch needs C++11 to compile.Dec 2 2016, 6:24 AM
Chaitanya (cyrax) updated this object.
Chaitanya (cyrax) set the repository for this revision to rB Blender.
Chaitanya (cyrax) updated this revision to Diff 7928.

I'm running the latest Fedora with gcc 6.something so can not verify. But yes the goal is to require C++11 for Blender 2.8. My recent change to this file got it working on Mac/clang.

@Sergey Sharybin (sergey) does this look good?

Sergey Sharybin (sergey) requested changes to this revision.

@Mike Erwin (merwin), can't think what exact change made C++11 mandatory in blender2.8 branch. But in any case the change does not look correct to me: _cxx11_init is already ON, meaning default value of WITH_CXX11 is ON. This could mean that either someone explicitly set WITH_CXX11 to OFF or that CMake got confused when switching branches.

In the first case we can't really do anything, that was a developer's choise (who knows if he forgot this flag from other branch or wanted to make blender2.8 compilable without C++11 by hacking it). In the second case not sure either we should force anything. Switching branches could confuse hell of a CMake and best way to deal with that would be either manually enabling WITH_CXX11 for master branch (as in, use cmake -DWITH_CXX11 ... for all branches) or to use separate compilation folder.

When/if we will switch to C++11 mandatory then we'll need to remove all related options instead of hardcoding them to ON.

As for me it'll be fine to ALWAYS use C++11 in blender2.8. @Bastien Montagne (mont29), @Martijn Berger (juicyfruit) might have some opinion here as well.

This revision now requires changes to proceed.Dec 2 2016, 9:33 AM
Martijn Berger (juicyfruit) requested changes to this revision.

I think we need to do more work. We do not allow all c++11 features and we do not support the same minimal compiler versions as master we do for master.

I am thinking a minimal of

  • gcc 4.5
  • clang 3.3
  • msvc 2013
  • xcode 6 / mac OS 10.9

We should also maybe clarify what parts of c++ / c++11 and what parts of c11 we do not allow even if all compilers support it.

Didn't we already decide 2 or 3 times to enable C++11 for blender2.8? This conversation is getting into policy decisions. Let's open up a task for C++11 migration — not rewriting old code, just enabling compiler support for new code. Or is there already a task for this?

I have no experience with C11's new features; C99 is just fine. But C++11 has major benefits that we can't use until & compiler support is enabled in the build system.

I might be late to the chat but _cxx11_init doesn't really enable C++11 support. Hence set(_cxx11_init ON) does not have its intended effect.

But that's besides the point since this has turned into a much larger conversation about enabling compiler support.

@Mike Erwin (merwin) - Would you suggest that I close this revision and will this conversation happen at a different spot? If that's the case what do we do about the blender2.8 branch currently not compiling? I agree with you about the merits of using C++11. It is fairly standard and stable now.

In the meanwhile I'll continue with immediate mode migration with this change on my local branch; one that will not be submitted.

_cxx11_init sets default value of WITH_CXX11 and under no circumstances we should force WITH_CXX11 to ON for as long as it's an option.

Did you try removing CMakeCache.txt and re-run cmake on blender2.8 branch? That should default WITH_CXX11 to ON. If it does not, the issue is somewhere else.