From c64c45ef1e42bbbae45d78b4f832163e461f141d Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Wed, 10 Jun 2026 05:00:43 +0200 Subject: build: allow FP reassociation/contraction, keep finite-math off --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4db4490..728dfa4 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,11 @@ CC = gcc -# Keep IEEE math semantics by default. Some GCC/OpenBLAS Linux builds produced -# NaN embeddings with -ffast-math. -CFLAGS_BASE = -Wall -Wextra -O3 -march=native +# Allow FP reassociation and contraction so reduction loops vectorize, but do +# not assume finite math or approximate libm calls: full -ffast-math produced +# NaN embeddings on GCC/OpenBLAS Linux builds (-ffinite-math-only and +# -fapprox-func are the unsafe parts and stay off). +CFLAGS_BASE = -Wall -Wextra -O3 -march=native \ + -fno-math-errno -ffp-contract=fast -fno-trapping-math \ + -fno-signed-zeros -fassociative-math -freciprocal-math LDFLAGS = -lm -lpthread CJSON_CFLAGS ?= $(shell sh -c 'pkg-config --cflags libcjson 2>/dev/null') CJSON_LDFLAGS ?= $(shell sh -c 'pkg-config --libs libcjson 2>/dev/null') -- cgit v1.3.1