]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: enable -ffp-exceptions-behavior=strict when compiling with clang 15509/head
authorMatthias Maier <tamiko@43-1.org>
Tue, 27 Jun 2023 20:46:20 +0000 (15:46 -0500)
committerMatthias Maier <tamiko@43-1.org>
Tue, 27 Jun 2023 20:54:43 +0000 (15:54 -0500)
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
`-ftrapping-math` per default, 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

cmake/setup_compiler_flags_gnu.cmake

index 080f6063592b3b843dd2107d23d52fc76029c1b8..aeed104ec6015b593c46ce5e4c299d6bcc550846 100644 (file)
@@ -197,6 +197,23 @@ 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
+  # `-ftrapping-math` per default, 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.

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.