summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorJosef Ahmad <josef.ahmad@mongodb.com>2022-09-15 06:14:58 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-15 07:26:17 +0000
commitd8901a2835d3f464d394631d85dc7aa9493fc095 (patch)
tree5d1caaa99f13a8903d28584874879c77689d2a68 /SConstruct
parenta5ecbf2c6416309673afdbe3ff2f4280f4d03d43 (diff)
downloadmongo-d8901a2835d3f464d394631d85dc7aa9493fc095.tar.gz
SERVER-69611 Set the -ffp-contract=off compiler option by default
Diffstat (limited to 'SConstruct')
-rwxr-xr-xSConstruct9
1 files changed, 9 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index ec37dea4ea4..77c2400c609 100755
--- a/SConstruct
+++ b/SConstruct
@@ -2478,6 +2478,15 @@ for suboption in get_option('experimental-runtime-hardening'):
elif suboption.startswith('+'):
selected_experimental_runtime_hardenings.add(suboption[1:])
+# Disable floating-point contractions such as forming of fused multiply-add operations.
+if env.ToolchainIs('clang', 'gcc'):
+ env.Append(CCFLAGS=["-ffp-contract=off"])
+else:
+ # msvc defaults to /fp:precise. Visual Studio 2022 does not emit floating-point contractions
+ # with /fp:precise, but previous versions can. Disable contractions altogether by using
+ # /fp:strict.
+ env.Append(CCFLAGS=["/fp:strict"])
+
if env.TargetOSIs('linux'):
env.Append(LIBS=["m"])
if not env.TargetOSIs('android'):