Skip to content

Commit

Permalink
CMake: enable -ffp-exceptions-behavior=strict when compiling with clang
Browse files Browse the repository at this point in the history
We have to ensure that we emit floating-point instructions in debug mode
that preserve the occurence of floating-point exceptions and don't
introduce new ones. gcc plays nicely in this regard by enabling
`-mfp-exceptions`, at least for the level of optimization we have in
debug mode. clang however is more aggressive and assumes that it can
optimize code disregarding precise floating-point exception semantics.

We thus set `-ffp-exceptions-behavior=strict` in debug mode to ensure
that our testsuite doesn't run into false positive floating-point
exceptions. See dealii#15496
  • Loading branch information
tamiko committed Jun 27, 2023
1 parent 8d68b31 commit e6678aa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmake/setup_compiler_flags_gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug")

list(APPEND DEAL_II_DEFINITIONS_DEBUG "DEBUG")

#
# We have to ensure that we emit floating-point instructions in debug
# mode that preserve the occurence of floating-point exceptions and don't
# introduce new ones. gcc plays nicely in this regard by enabling
# `-mfp-exceptions`, at least for the level of optimization we have in
# debug mode. clang however is more aggressive and assumes that it can
# optimize code disregarding precise floating-point exception semantics.
#
# We thus set `-ffp-exceptions-behavior=strict` in debug mode to ensure
# that our testsuite doesn't run into false positive floating-point
# exceptions. See
#
# https://github.com/dealii/dealii/issues/15496
#
enable_if_supported(DEAL_II_CXX_FLAGS_DEBUG "-ffp-exception-behavior=strict")

#
# In recent versions, gcc often eliminates too much debug information
# using '-Og' to be useful.
Expand Down

0 comments on commit e6678aa

Please sign in to comment.