From 26f8a175d8c082bc13c36bcf0ca805015ced0b20 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Tue, 27 Oct 2026 12:42:55 -0500 Subject: [PATCH] Default to SSE2 floating point math on x86 The x86 kit and the x64 kit's -m32 target pentium4, so SSE2 is always enabled, yet GCC still defaulted to -mfpmath=387 for 32-bit code. x87 math keeps 80-bit intermediates (FLT_EVAL_METHOD 2), so a value can change when spilled to memory, and results differ from x64's. Configure GCC --with-fpmath=sse, which makes SSE2 math the default whenever SSE2 is enabled: -march=i686 still gets x87. long double stays x87, and the 32-bit ABI still returns floats in st(0). --- Dockerfile | 4 ++-- README.md | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8932b11..4ca16edb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -239,7 +239,7 @@ RUN mkdir nsis \ FROM dl-cross AS variant-x64 ENV ARCH=x86_64-w64-mingw32 \ - GCC_ARCH_FLAG=--with-arch-32=pentium4 \ + GCC_ARCH_FLAG="--with-arch-32=pentium4 --with-fpmath=sse" \ GCC_MULTILIB=enable \ CRT_LIB32=enable \ CRT_LIB64=enable \ @@ -254,7 +254,7 @@ ENV ARCH=x86_64-w64-mingw32 \ FROM dl-cross AS variant-x86 ENV ARCH=i686-w64-mingw32 \ - GCC_ARCH_FLAG=--with-arch=pentium4 \ + GCC_ARCH_FLAG="--with-arch=pentium4 --with-fpmath=sse" \ GCC_MULTILIB=disable \ CRT_LIB32=enable \ CRT_LIB64=disable \ diff --git a/README.md b/README.md index ab3919c2..a767446a 100644 --- a/README.md +++ b/README.md @@ -85,10 +85,11 @@ toolchain targets Windows 7 by default. The x86 kit requires Windows XP or later and an SSE2-capable processor (e.g. at least Pentium 4); limited Unicode support. The toolchain targets -the same by default. Runtimes contain SSE2 instructions, so GCC `-march` -will not reliably target less capable processors when runtimes are linked -(exceptions: `-lmemory`, `-lchkstk`). CMake, Ninja, and CCache require at -least Windows 7. +the same by default, with floating point math in SSE2 rather than x87 +(`-mfpmath=sse`), as on x64. Runtimes contain SSE2 instructions, so GCC +`-march` will not reliably target less capable processors when runtimes +are linked (exceptions: `-lmemory`, `-lchkstk`). CMake, Ninja, and +CCache require at least Windows 7. ## Build cache