mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2025-04-01 10:11:49 +00:00
[PATCH] Work around compiler bug
After upgrading my MinGW installation, TyrQuake started to crash in a very strange way. Eventually, tracked it down to gcc's unit-at-a-time optimisation. This patch disables unit-at-a-time for gcc earlier than 4.0. (Current MinGW is 3.4.5). Version checking script shamelessly stolen from Linux. Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
parent
c75d07476a
commit
8c0b373bbf
30
Makefile
30
Makefile
@ -40,12 +40,6 @@ export
|
||||
nq-linux-sw-objs nq-linux-gl-objs qw-linux-sw-objs qw-linux-gl-objs \
|
||||
qwsv-linux-objs
|
||||
|
||||
# ============================================================================
|
||||
# Helper functions
|
||||
# ============================================================================
|
||||
|
||||
check_gcc = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
|
||||
|
||||
# ============================================================================
|
||||
|
||||
# FIXME - how to detect build env reliably...?
|
||||
@ -55,6 +49,18 @@ else
|
||||
TOPDIR := $(shell pwd)
|
||||
endif
|
||||
|
||||
# ============================================================================
|
||||
# Helper functions
|
||||
# ============================================================================
|
||||
|
||||
cc-version = $(shell sh $(TOPDIR)/scripts/gcc-version \
|
||||
$(if $(1), $(1), $(CC)))
|
||||
|
||||
cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
|
||||
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
|
||||
|
||||
GCC_VERSION := $(call cc-version)
|
||||
|
||||
# ----------------------------
|
||||
# The two project directories
|
||||
# ----------------------------
|
||||
@ -237,12 +243,14 @@ ifdef DEBUG
|
||||
CFLAGS += -g
|
||||
STRIP_CMD = @echo "** Debug build - not stripping"
|
||||
else
|
||||
# Note that "-fomit-frame-pointer" seems to screw some things up
|
||||
# (at least on MinGW)
|
||||
CFLAGS += -O2
|
||||
CFLAGS += $(call check_gcc,-fweb,)
|
||||
CFLAGS += $(call check_gcc,-frename-registers,)
|
||||
CFLAGS += $(call check_gcc,-mtune=i686,-mcpu=i686)
|
||||
# -funit-at-a-time is buggy for MinGW GCC > 3.2
|
||||
# I'm assuming it's fixed for MinGW GCC >= 4.0 when that comes about
|
||||
CFLAGS += $(shell if [ $(GCC_VERSION) -lt 0400 ] ;\
|
||||
then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
|
||||
CFLAGS += $(call cc-option,-fweb,)
|
||||
CFLAGS += $(call cc-option,-frename-registers,)
|
||||
CFLAGS += $(call cc-option,-mtune=i686,-mcpu=i686)
|
||||
STRIP_CMD = strip
|
||||
endif
|
||||
|
||||
|
13
scripts/gcc-version
Normal file
13
scripts/gcc-version
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# gcc-version gcc-command
|
||||
#
|
||||
# Prints the gcc version of `gcc-command' in a canonical 4-digit form
|
||||
# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
|
||||
#
|
||||
|
||||
compiler="$*"
|
||||
|
||||
MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
|
||||
MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
|
||||
printf "%02d%02d\\n" $MAJOR $MINOR
|
Loading…
x
Reference in New Issue
Block a user