]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Improve x86 detection to fix compiler errors on other architectures xonotic-v0.8.6
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 30 Apr 2023 09:22:32 +0000 (19:22 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 30 Apr 2023 09:22:32 +0000 (19:22 +1000)
Also some related minor makefile cleanup.

Closes https://gitlab.com/xonotic/darkplaces/-/issues/382

See also: 1b6dd54f9fdf8b4caa2c2305cd1e2011444353ca

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
makefile
makefile.inc

index 1cc5271437cc6b4b6330d2f89308c410b3a33f1c..0f9d8e7020c83c823de0da2c056c328e049fa8fd 100644 (file)
--- a/makefile
+++ b/makefile
@@ -29,21 +29,27 @@ endif  # ifndef DP_MAKE_TARGET
 # If we're targeting an x86 CPU we want to enable DP_SSE (CFLAGS_SSE and SSE2)
 ifeq ($(DP_MAKE_TARGET), mingw)
        DP_SSE:=1
+else ifeq ($(OS),Windows_NT)
+       ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
+               DP_SSE:=1
+       else ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
+               DP_SSE:=1
+       else ifeq ($(PROCESSOR_ARCHITECTURE),x86)
+               DP_SSE:=1
+       else
+               DP_SSE:=0
+       endif
 else
        DP_MACHINE:=$(shell uname -m)
        ifeq ($(DP_MACHINE),x86_64)
                DP_SSE:=1
-       else
-       ifeq ($(DP_MACHINE),i686)
+       else ifeq ($(DP_MACHINE),i686)
                DP_SSE:=1
-       else
-       ifeq ($(DP_MACHINE),i386)
+       else ifeq ($(DP_MACHINE),i386)
                DP_SSE:=1
        else
                DP_SSE:=0
-       endif # ifeq ($(DP_MACHINE),i386)
-       endif # ifeq ($(DP_MACHINE),i686)
-       endif # ifeq ($(DP_MACHINE),x86_64)
+       endif
 endif
 
 # Makefile name
index df8fecc560a165df3bbdbb186a630d781db3a9c1..a2e814b55e17320120f7b2038a5953bca4297fa2 100644 (file)
@@ -18,14 +18,15 @@ CC?=gcc
 # 686 (Pentium Pro/II) optimizations
 #CPUOPTIMIZATIONS?=-march=i686
 # No specific CPU (386 compatible)
-#CPUOPTIMIZATIONS?=
-# Experimental
-#CPUOPTIMIZATIONS?=-fno-math-errno -fno-rounding-math -fno-signaling-nans -fassociative-math -freciprocal-math -fno-signed-zeros -fno-trapping-math
-# Normal
-CPUOPTIMIZATIONS?=-mno-avx
+CPUOPTIMIZATIONS?=
+# x86
+ifeq ($(DP_SSE),1)
+       CPUOPTIMIZATIONS+=-mno-avx
+endif
+# bones_was_here: added -mno-avx because when compiling for (at least) haswell or skylake with gcc or clang, with both -O2 and -O3, AVX auto-vectorisation causes subtle bugs in Xonotic QC physics, and changes the hash generated by the CI pipeline.  AVX2 seems to be OK.
+# Also moved -fno-math-errno -fno-trapping-math (etc) to OPTIM_RELEASE as they're not CPU-specific.
 # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag
 # Also, since gcc 5, -ffinite-math-only makes NaN and zero compare equal inside engine code but not inside QC, which causes error spam for seemingly valid QC code like if (x != 0) return 1 / x;
-# bones_was_here: added -mno-avx because when compiling for (at least) haswell or skylake with gcc or clang, with both -O2 and -O3, AVX auto-vectorisation causes subtle bugs in Xonotic QC physics, and changes the hash generated by the CI pipeline.  AVX2 seems to be OK.  Also moved -fno-math-errno -fno-trapping-math to OPTIM_RELEASE as they're not CPU-specific.
 
 SDL_CONFIG?=sdl2-config
 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`