summaryrefslogtreecommitdiff
path: root/debian/patches/0016-sse2-i386.patch
blob: 2723119432d4dae411050110566ce24942d6c2cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 <myon@debian.org>
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)