diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -335,6 +335,17 @@ "LLVM_LINK_LLVM_DYLIB=OFF") endif() +set(CLANG_DEFAULT_FFP_CONTRACT "on" CACHE STRING + "Default fused FP contract (\"fast\", \"on\", \"off\", \"fast-honor-pragmas\")") +if (NOT(CLANG_DEFAULT_FFP_CONTRACT STREQUAL "fast" OR + CLANG_DEFAULT_FFP_CONTRACT STREQUAL "on" OR + CLANG_DEFAULT_FFP_CONTRACT STREQUAL "off" OR + CLANG_DEFAULT_FFP_CONTRACT STREQUAL "fast-honor-pragmas")) + message(WARNING "Resetting default fused FP contract") + set(CLANG_DEFAULT_RTLIB "on" CACHE STRING + "Default fused FP contract (\"fast\", \"on\", \"off\", \"fast-honor-pragmas\", empty for platform default)" FORCE) +endif() + # The libdir suffix must exactly match whatever LLVM's configuration used. set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}") diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -37,6 +37,7 @@ set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "") endif() set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") +set(CLANG_DEFAULT_FFP_CONTRACT off CACHE STRING "") set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake --- a/clang/cmake/caches/Fuchsia.cmake +++ b/clang/cmake/caches/Fuchsia.cmake @@ -28,6 +28,7 @@ set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "") endif() set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") +set(CLANG_DEFAULT_FFP_CONTRACT off CACHE STRING "") set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default OpenMP runtime used by -fopenmp. */ #define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}" +/* Default fused FP contract */ +#define CLANG_DEFAULT_FFP_CONTRACT "${CLANG_DEFAULT_FFP_CONTRACT}" + /* Default architecture for OpenMP offloading to Nvidia GPUs. */ #define CLANG_OPENMP_NVPTX_DEFAULT_ARCH "${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}" diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -27,6 +27,7 @@ #include "clang/Basic/LangOptions.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Version.h" +#include "clang/Config/config.h" #include "clang/Driver/Distro.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/InputInfo.h" @@ -2641,7 +2642,7 @@ llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath; llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math; - StringRef FPContract = "on"; + StringRef FPContract = CLANG_DEFAULT_FFP_CONTRACT; bool StrictFPModel = false;