From 805a5e4736bdd0f3156fc4120e4866e30f09d964 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Mon, 7 Feb 2022 19:28:54 +0200 Subject: [PATCH] Turn off -ffp-contract on Unix (#64847) --- eng/native/configurecompiler.cmake | 4 ++++ src/mono/CMakeLists.txt | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index b67594cb60fb2..4324e23ed1fa2 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -390,6 +390,10 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-unused-but-set-variable) + # Turn off floating point expression contraction because it is considered a value changing + # optimization in the IEEE 754 specification and is therefore considered unsafe. + add_compile_options(-ffp-contract=off) + if (CMAKE_C_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-unknown-warning-option) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 348b5e9960bab..d9d118066d975 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -485,6 +485,11 @@ if(GCC) # We require C99 with some GNU extensions, e.g. `linux` macro set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") endif() + + # Turn off floating point expression contraction because it is considered a value changing + # optimization in the IEEE 754 specification and is therefore considered unsafe. + add_compile_options(-ffp-contract=off) + # The runtime code does not respect ANSI C strict aliasing rules append("-fno-strict-aliasing" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) # We rely on signed overflow to behave