Closed
Description
Originally reported on Google Code with ID 488
Linking shared libraries with -ffast-math is dangerous. It causes the SSE mxcsr flags
to be set on library *load*, which can cause various issues for programs the unsuspectingly
load such a library. See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55522
https://bugzilla.redhat.com/show_bug.cgi?id=1127544
for some discussion, examples.
Unfortunately, CMAKE_C_FLAGS are also used during link, so the current:
# Do not use ffast-math for all build, it would produce incorrect results,
only set for release:
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
triggers this.
According to http://public.kitware.com/pipermail/cmake/2015-April/060479.html the preferred
solution would be something like:
target_compile_options(openjpeg PRIVATE
$<$<CONFIG:Release>:-ffast-math>)
The attached patches appears to achieve this (for 1.5.1 and trunk).
Another wrinkle on this is that -DCMAKE_BUILD_TYPE=RelWithDebInfo or MinSizeRel will
also cause -ffast-math not to be used at all. Not sure if that is an issue or not.
Reported by orion@cora.nwra.com
on 2015-04-28 21:43:08
- _Attachment: [openjpeg-fast-math.patch](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-488/comment-0/openjpeg-fast-math.patch)_ - _Attachment: [openjpeg2-fast-math.patch](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-488/comment-0/openjpeg2-fast-math.patch)_