Skip to content
Snippets Groups Projects
Commit 62f800ad authored by Steffen Müthing's avatar Steffen Müthing
Browse files

Add a workaround to fix compilation with clang 6

clang 6 hangs indefinitely when trying to compile gitter_mgb.cc or gitter_pll_mgb.cc with an
optimization level of -O2 or higher. This patch adds some CMake logic that detects the problematic
case and forces the optimization level for those two files down to -O1 if necessary, but avoids
bumping it up in case of a debug build.
parent 316c4f0e
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,23 @@ if(ZLIB_FOUND)
INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}")
endif()
# workaround for clang 6, which runs into an infinite loop on gitter_mgb.cc and gitter_pll_mgb.cc
# when optimization level is -O2 or higher
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 6.0.0)
string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type_upper)
set(_flags "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_build_type_upper}}")
string(REGEX MATCH " -O(2|3|fast) " _opt_level ${_flags})
if (NOT _opt_level STREQUAL "")
message(STATUS "detected clang 6 and optimized build: overriding optimization level for gitter_mgb.cc and gitter_pll_mgb.cc")
set_source_files_properties(
../dune/alugrid/impl/serial/gitter_mgb.cc
../dune/alugrid/impl/parallel/gitter_pll_mgb.cc
PROPERTIES
COMPILE_FLAGS -O1
)
endif()
endif()
####################################################################
#### general warning: avoid such and similar commands here
#### as they will not influence anything after the library
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment