Skip to content
Snippets Groups Projects
Commit 0d09c4b0 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

Consider build-type when checking for bad optimization options

For single build-type generators such as unix make files check
CMAKE_CXX_FLAGS_<CONFIG> in addition CMAKE_CXX_FLAGS.  This is equivalent to
just CMAKE_CXX_FLAGS if not build-type is selected.  For multi-configuration
generators, check each configuration, and skip the test is any of them is bad.

I'd like to skip it only for the bad configs, but that would require generator
expression support in dune_add_test(CMAKE_GUARD ...).
parent a43a972d
No related branches found
No related tags found
1 merge request!119Narrow compiler/options for skipping testcornerstoragerefwrap
Pipeline #15363 passed
......@@ -8,24 +8,49 @@ dune_add_test(SOURCES test-axisalignedcubegeometry.cc
# https://gitlab.dune-project.org/core/dune-geometry/issues/19,
# a.k.a. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87288
set(ISSUE19_UNAFFECTED_GXX ON)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND
(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.2) AND
(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.3))
separate_arguments(opts UNIX_COMMAND "${CMAKE_CXX_FLAGS}")
set(issue19_affected_configs)
function(check_compiler_issue19 config)
string(TOUPPER "${config}" CONFIG)
separate_arguments(opts UNIX_COMMAND "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CONFIG}}")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} ${opts} -Q --help=optimizers
OUTPUT_VARIABLE opt_settings
ERROR_VARIABLE ignored # silence cc1 complaint about c++ options...
)
if(opt_settings MATCHES "-ftree-loop-vectorize[ \t]+\\[enabled\\]")
set(ISSUE19_UNAFFECTED_GXX OFF PARENT_SCOPE)
list(APPEND issue19_affected_configs "${config}")
set(issue19_affected_configs "${issue19_affected_configs}" PARENT_SCOPE)
endif()
endfunction(check_compiler_issue19)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND
(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.2) AND
(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.3))
if(CMAKE_BUILD_TYPE)
check_compiler_issue19("${CMAKE_BUILD_TYPE}")
elseif(CMAKE_CONFIGURATION_TYPES)
# multi-configuration generator, check each configuration and if any is
# bad skip test for all of them. dune_add_test does not really allow to
# make the guard configuration-dependent.
foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES)
check_compiler_issue19("${conf}")
endforeach(conf)
else()
check_compiler_issue19("")
endif()
if(NOT ISSUE19_UNAFFECTED_GXX)
if(issue19_affected_configs)
string(REPLACE ";" ", " issue19_affected_configs "${issue19_affected_configs}")
set(issue19_affected_configs
" (Affected configurations: ${issue19_affected_configs})")
endif()
message(WARNING "You are using gcc 8.2 with optimization options "
"including -ftree-loop-vectorize (possibly implicated by -O3). This is "
"known to miscompile, see "
"https://gitlab.dune-project.org/core/dune-geometry/issues/19 and "
"https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87288")
"https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87288${issue19_affected_configs}")
message(WARNING "Skipping test-cornerstoragerefwrap due to known-bad "
"compiler optimization combination")
set(ISSUE19_UNAFFECTED_GXX OFF)
"compiler/optimization combination")
endif()
endif()
dune_add_test(SOURCES test-cornerstoragerefwrap.cc
......
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