Description: Build C, C++ and Fortran sources with SSE2 on i386 On 32-bit Intel targets the default x87 floating point model keeps intermediate results in 80-bit extended precision. That breaks bit-exact comparisons between equivalent computations in the unit tests, and slows the Q65 LDPC decoders down until test_q65_decode_pipeline times out. Building the C, C++ and Fortran sources with SSE2 makes every operation round to 64-bit IEEE double precision, matching the 64-bit build behaviour. Detect 32-bit x86 by pointer size (CMAKE_SIZEOF_VOID_P) rather than CMAKE_SYSTEM_PROCESSOR, which reports the host kernel's architecture (e.g. "x86_64") when an i386 build runs in a chroot on an amd64 host. Author: Christoph Berg Last-Update: 2026-10-14 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,25 @@ project (wsjtx LANGUAGES C CXX Fortran ) +# +# On 32-bit Intel targets the default x87 floating point model keeps +# intermediate results in 80-bit extended precision. That breaks bit-exact +# comparisons between equivalent computations in the unit tests, and slows +# the Q65 LDPC decoders down until test_q65_decode_pipeline times out. +# Build the C, C++ and Fortran sources with SSE2, where every operation +# rounds to 64-bit IEEE double precision, matching the 64-bit build +# behaviour. +# Detect 32-bit x86 by pointer size rather than CMAKE_SYSTEM_PROCESSOR, +# which reports the host kernel's architecture (e.g. "x86_64") when an i386 +# build runs in a chroot on an amd64 host. +# +if (UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 4 + AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86_64|amd64|AMD64)$") + string (APPEND CMAKE_C_FLAGS " -msse2 -mfpmath=sse") + string (APPEND CMAKE_CXX_FLAGS " -msse2 -mfpmath=sse") + string (APPEND CMAKE_Fortran_FLAGS " -msse2 -mfpmath=sse") +endif (UNIX) + set (CMAKE_CXX_STANDARD 17) set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_CXX_EXTENSIONS ON)