Set -ffloat-store when building with gcc for i386.

This helps the old and crappy x87 FPU to produce correct values. And
finally implement compiler detection in the Makefile.
This commit is contained in:
Yamagi Burmeister 2017-09-21 18:15:12 +02:00
parent ce2c3292c6
commit e5c39eeb7f
2 changed files with 41 additions and 0 deletions

View file

@ -144,6 +144,21 @@ list(APPEND yquake2LinkerFlags ${CMAKE_DL_LIBS})
include_directories(${yquake2IncludeDirectories} ${CMAKE_SOURCE_DIR}/src/client/refresh/gl3/glad/include) include_directories(${yquake2IncludeDirectories} ${CMAKE_SOURCE_DIR}/src/client/refresh/gl3/glad/include)
link_directories(${yquake2LinkerDirectories}) link_directories(${yquake2LinkerDirectories})
# If we're building with gcc for i386 let's define -ffloat-store.
# This helps the old and crappy x87 FPU to produce correct values.
# Would be nice if Clang had something comparable.
if ("${ARCH}" STREQUAL "i386")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffloat-store")
endif()
endif()
# Force SSE math on x86_64. All sane compilers should do this
# anyway, just to protect us from broken Linux distros.
if ("${ARCH}" STREQUAL "x86_64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpmath=sse")
endif()
set(Backends-Generic-Source set(Backends-Generic-Source
${BACKENDS_SRC_DIR}/generic/misc.c ${BACKENDS_SRC_DIR}/generic/misc.c
${BACKENDS_SRC_DIR}/generic/qal.c ${BACKENDS_SRC_DIR}/generic/qal.c

View file

@ -124,6 +124,15 @@ else
YQ2_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/') YQ2_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
endif endif
# Detect the compiler
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
COMPILER := clang
else ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"), 1)
COMPILER := gcc
else
COMPILER := unknown
endif
# Disable CDA for SDL2 # Disable CDA for SDL2
ifeq ($(WITH_SDL2),yes) ifeq ($(WITH_SDL2),yes)
ifeq ($(WITH_CDA),yes) ifeq ($(WITH_CDA),yes)
@ -178,6 +187,23 @@ endif
# ---------- # ----------
# If we're building with gcc for i386 let's define -ffloat-store.
# This helps the old and crappy x87 FPU to produce correct values.
# Would be nice if Clang had something comparable.
ifeq ($(YQ2_ARCH), i386)
ifeq ($(COMPILER), gcc)
CFLAGS += -ffloat-store
endif
endif
# Force SSE math on x86_64. All sane compilers should do this
# anyway, just to protect us from broken Linux distros.
ifeq ($(YQ2_ARCH), x86_64)
CFLAGS += -mfpmath=sse
endif
# ----------
# Systemwide installation # Systemwide installation
ifeq ($(WITH_SYSTEMWIDE),yes) ifeq ($(WITH_SYSTEMWIDE),yes)
CFLAGS += -DSYSTEMWIDE CFLAGS += -DSYSTEMWIDE