Add -ffp-contract=off for Clang 14 and later
Summary
Clang 14 changed its floating-point behavior. Now the default is -ffp-contract=on
even with -O0
Steps to reproduce
FMA is enabled by default for Clang 14 and later. This doesn't seem like an issue for x86 (because of different CPU instructions to do FMA), but for arm64 things like libsampling
can easily fail.
Example case
tutorials/incompressible/simpleFoam/backwardFacingStep2D
leads to infinite loop when running the sample
function.
What is the current bug behaviour?
A lot of tutorial cases using libsampling
will be trapped in infinite loop. Any code related to computational geometry may get unexpected results.
What is the expected correct behavior?
The floating-point calculation should strictly follow IEEE-754 to avoid any potential bug that is almost impossible to debug.
Relevant logs and/or images
https://releases.llvm.org/14.0.0/tools/clang/docs/ReleaseNotes.html#floating-point-support-in-clang
Environment information
- OpenFOAM version : Any
- Operating system : Any
- Hardware info : Most likely affecting arm64
- Compiler : Clang 14 and later
Possible fixes
I don't know if it's possible to add flags in wmake rules based on compiler version. I would propose add -ffp-contract=off
explicitly to the general Clang wmake rule as it doesn't change anything before Clang 13. For Arm
and Fujitsu
, it should be added automatically.