diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2021-01-14 19:32:21 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2021-01-14 19:32:21 +0300 |
commit | 406d74769597e318117ad5b3837e7283d9fd2aa5 (patch) | |
tree | b35b05ac925f7c25723cf919c0356f4df6c03a38 | |
parent | 9131c697ddda0ad640167d9f52e97bb697e187d0 (diff) |
Fix automated tests when building with GCC and march=native
When building with more aggressive optimization flags, GCC will add FMA
(Fused Multiply Add) instructions that will slightly alter the floating
point operation results.
This causes some automated tests to fail in blender.
In clang and the intel compiler ffp-contract is set to off per default
it seems from my research. (They do not have the exact same setting,
but the default seems to match the off behavior)
Reviewed By: Brecht
Differential Revision: http://developer.blender.org/D9047
-rw-r--r-- | build_files/cmake/platform/platform_unix.cmake | 8 | ||||
-rw-r--r-- | intern/cycles/CMakeLists.txt | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index b304e89d74f..abacd0500e5 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -610,7 +610,13 @@ endif() # GNU Compiler if(CMAKE_COMPILER_IS_GNUCC) - set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") + # ffp-contract=off: + # Automatically turned on when building with "-march=native". This is + # explicitly turned off here as it will make floating point math give a bit + # different results. This will lead to automated test failures. So disable + # this until we support it. Seems to default to off in clang and the intel + # compiler. + set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -ffp-contract=off") # `maybe-uninitialized` is unreliable in release builds, but fine in debug builds. set(GCC_EXTRA_FLAGS_RELEASE "-Wno-maybe-uninitialized") diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index b1bb1d3654d..8167576a177 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -379,6 +379,9 @@ endif() # Subdirectories if(WITH_CYCLES_BLENDER) + # Not needed to make cycles automated tests pass with -march=native. + # However Blender itself needs this flag. + remove_cc_flag("-ffp-contract=off") add_definitions(-DWITH_BLENDER_GUARDEDALLOC) add_subdirectory(blender) endif() |