Skip to content

Commit 3ce95bb

Browse files
authored
Set -ffp-contract=off flag for clang on LoongArch (jrouwe#1595)
This fixes some failing unit tests
1 parent e8c2ecf commit 3ce95bb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Build/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,14 @@ else()
233233
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise")
234234

235235
# On clang 14 and later we can turn off float contraction through a pragma, older versions and deterministic versions need it off always, see Core.h
236-
if (CMAKE_CXX_COMPILER_VERSION LESS 14 OR CROSS_PLATFORM_DETERMINISTIC)
236+
# clang on LoongArch does not support such pragma, also turn off contraction for it.
237+
if (CMAKE_CXX_COMPILER_VERSION LESS 14 OR CROSS_PLATFORM_DETERMINISTIC OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "loongarch")
237238
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off")
238239

239240
# emcc complains with: warning: overriding '-ffp-model=precise' option with '-ffp-contract=off' [-Woverriding-option],
241+
# clang > 19 also report this as an error,
240242
# but this is exactly what we want.
241-
if (EMSCRIPTEN)
243+
if (EMSCRIPTEN OR CMAKE_CXX_COMPILER_VERSION GREATER 19)
242244
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overriding-option")
243245
endif()
244246
endif()

0 commit comments

Comments
 (0)