Page MenuHomePhabricator

Boost uses wrong compiler when building with clang on Ubuntu 12.04
Closed, ResolvedPublic

Description

If building MITK with boost and clang on Ubuntu 12.04 the boost build uses the default system gcc and not clang compiler specified in the superbuild.
Full error log at: http://cdash.mitk.org/buildSummary.php?buildid=562818

Error:
gcc.compile.c++ bin.v2/libs/system/build/gcc-4.6/release/address-model-64/threading-multi/error_code.o
cc1plus: error: unrecognized command line option ‘-std=c++11’

"g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -fPIC -m64  -std=c++11  -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -I"." -c -o "bin.v2/libs/system/build/gcc-4.6/release/address-model-64/threading-multi/error_code.o" "libs/system/src/error_code.cpp"

Event Timeline

The problem still remains when installing the gcc proposed in bug: 18855

The compiler can be set via the toolset option: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html

It that doesn't work alone, we might need to set the standard library according to this stackoverflow thread: http://stackoverflow.com/questions/8486077/how-to-compile-link-boost-with-clang-libc

It seems to be fixed by using appropriate (different) values for --with-toolset and --toolset options for building the build engine and boost itself. The build engine only knows gcc for example. For building boost a version can be specified. In Boost.cmake add something like:

if(UNIX)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  set(_boost_toolset "gcc")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  set(_boost_toolset "clang")
else()
  message(FATAL_ERROR "Compiler '${CMAKE_CXX_COMPILER_ID}' not supported. Use GNU or Clang instead.")
endif()
string(REGEX MATCH "^[0-9]+\\.[0-9]+" _compiler_version "${CMAKE_CXX_COMPILER_VERSION}")
set(_boost_toolset_with_version "${_boost_toolset}-${_compiler_version}")

endif()

And then use it for the build_cmd, e.g.:

--toolset=${_boost_toolset_with_version}

User kislinsk has pushed new remote branch:

bug-18885-BoostToolset

[f1213e]: Merge branch 'bug-18885-BoostToolset'

Merged commits:

2015-04-09 02:25:26 Stefan Kislinskiy [69f94c]
Use versioned toolset for building Boost.

User kislinsk has pushed new remote branch:

bug-18885-FixAppleClang

[2c19c9]: Merge branch 'bug-18885-FixAppleClang'

Merged commits:

2015-04-09 13:05:28 Stefan Kislinskiy [8dd97c]
COMP: Handle Apple separately.

User kislinsk has pushed new remote branch:

bug-18885-FixWrongVarName

[01a2f9]: Merge branch 'bug-18885-FixWrongVarName'

Merged commits:

2015-04-09 14:17:00 Stefan Kislinskiy [6f015b]
COMP: Fixed wrong variable name.

User kislinsk has pushed new remote branch:

bug-18885-FixITKExternalProjectScript

[ba0c6c]: Merge branch 'bug-18885-FixITKExternalProjectScript'

Merged commits:

2015-04-09 14:50:13 Stefan Kislinskiy [72a471]
COMP: VCL constexpr patch is also needed for GCC 4.7.