Linux: Fear and Loathing in GCC 4.4.0...

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1222 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-05-19 13:25:09 +00:00
parent 134f02babb
commit 9eda5dc951
2 changed files with 78 additions and 20 deletions

View File

@ -98,6 +98,29 @@ default: \
#else #else
// GCC 4.4.0 is a bit nutty, as compilers go. it gets a define to itself.
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
/* Test for GCC > 4.4.0; Should be adjusted when new versions come out */
#if GCC_VERSION >= 40400
#define THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
#define __nooptimization __attribute__((optimize("O0"))
#endif
/*
This theoretically unoptimizes. Not having much luck so far.
#ifdef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
#pragma GCC optimize ("O0")
#endif
#ifdef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
#pragma GCC reset_options
#endif
*/
// fixme - is this needed for recent versions of GCC? Or can we just use the first two macros // fixme - is this needed for recent versions of GCC? Or can we just use the first two macros
// instead for both definitions (implementations) and declarations (includes)? -- air // instead for both definitions (implementations) and declarations (includes)? -- air
#define PCSX2_ALIGNED(alig,x) x __attribute((aligned(alig))) #define PCSX2_ALIGNED(alig,x) x __attribute((aligned(alig)))
@ -116,6 +139,10 @@ default: \
#define __noinline __attribute__((noinline)) #define __noinline __attribute__((noinline))
#endif #endif
#ifndef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
#define __nooptimization
#endif
typedef struct { typedef struct {
int size; int size;
s8 *data; s8 *data;

View File

@ -117,27 +117,46 @@ fi
WARNING_FLAGS+=" -Wno-format -Wno-unused-parameter -Wno-unused-value " WARNING_FLAGS+=" -Wno-format -Wno-unused-parameter -Wno-unused-value "
NORMAL_FLAGS+=" -msse -msse2 ${WARNING_FLAGS} " NORMAL_FLAGS+=" -msse -msse2 ${WARNING_FLAGS} "
if test "x$unsupportedspeedfreak" == "xyes"
then
dnl Don't even try to get support for this.
NORMAL_FLAGS+=" -pipe -O3 -march=native -funroll-loops -ffast-math "
else
if test "x$optimization" == "xyes"
then
NORMAL_FLAGS+=" -pipe -O2 "
else
NORMAL_FLAGS+=" -O0 "
fi
fi
if test "x$unsupportedspeedfreak" == "xno"
then
dnl These optimizations seem to cause issues with GCC 4.3.3, so we'll turn them off. dnl These optimizations seem to cause issues with GCC 4.3.3, so we'll turn them off.
dnl I really need to run some tests and see if they are still needed. dnl I really need to run some tests and see if they are still needed.
if test "$gccvernum" -ge "433"; then if test "$gccvernum" -ge "433"; then
NORMAL_FLAGS+=" -fno-guess-branch-probability -fno-dse -fno-tree-dse " NORMAL_FLAGS+=" -fno-guess-branch-probability -fno-dse -fno-tree-dse "
fi fi
fi
dnl Anything higher then -O0 seem to cause issues with GCC 4.4.0.
if test "x$optimization" == "xyes"
then
dnl Oddly, turning on all the optimizations up to -O2 one by one doesn't cause issues in GCC 4.4.0.
if test "$gccvernum" -ge "440"; then
NORMAL_FLAGS+=" -O0 "
dnl -O1, flag by flag, minus the 3 taken out on gcc 4.3.3
NORMAL_FLAGS+=" -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename "
NORMAL_FLAGS+=" -ftree-dce -ftree-dominator-opts "
NORMAL_FLAGS+=" -ftree-fre "
NORMAL_FLAGS+=" -ftree-sra "
NORMAL_FLAGS+=" -ftree-ter "
NORMAL_FLAGS+=" -fauto-inc-dec -fcprop-registers -fdce -fdefer-pop "
NORMAL_FLAGS+=" -fif-conversion2 -fif-conversion "
NORMAL_FLAGS+=" -finline-small-functions -fipa-pure-const -fipa-reference -fmerge-constants "
NORMAL_FLAGS+=" -fsplit-wide-types -funit-at-a-time -fno-omit-frame-pointer"
dnl And now for -O2. Comment out one that breaks compilation when turned on individually.
NORMAL_FLAGS+=" -fthread-jumps -falign-functions -falign-jumps -falign-loops -falign-labels "
NORMAL_FLAGS+=" -fcaller-saves -fcrossjumping -fcse-follow-jumps -fcse-skip-blocks "
NORMAL_FLAGS+=" -fdelete-null-pointer-checks -fexpensive-optimizations -fgcse -fgcse-lm "
NORMAL_FLAGS+=" -findirect-inlining -foptimize-sibling-calls -fpeephole2 -fregmove "
NORMAL_FLAGS+=" -freorder-blocks -freorder-functions -frerun-cse-after-loop "
NORMAL_FLAGS+=" -fsched-interblock "
NORMAL_FLAGS+=" -fsched-spec "
dnl NORMAL_FLAGS+=" -fschedule-insns "
NORMAL_FLAGS+=" -fschedule-insns2 "
NORMAL_FLAGS+=" -fstrict-aliasing -fstrict-overflow "
NORMAL_FLAGS+=" -ftree-switch-conversion -ftree-pre -ftree-vrp "
else
NORMAL_FLAGS+=" -pipe -O2 "
fi
else
NORMAL_FLAGS+=" -O0 "
fi
CFLAGS+=" ${NORMAL_FLAGS} -Xlinker -zmuldefs -m32 " CFLAGS+=" ${NORMAL_FLAGS} -Xlinker -zmuldefs -m32 "
CXXFLAGS+=" ${NORMAL_FLAGS} -fpermissive -Xlinker -zmuldefs -m32 " CXXFLAGS+=" ${NORMAL_FLAGS} -fpermissive -Xlinker -zmuldefs -m32 "
@ -187,3 +206,15 @@ echo " Custom cflags? $customcflags"
echo " Compiler warnings? $warnings" echo " Compiler warnings? $warnings"
echo " Compiler optimizations? $optimization" echo " Compiler optimizations? $optimization"
if test "$gccvernum" -ge "440"; then
echo
echo "*Congratulations*! You are running GCC 4.4.0! Thanks to this wonderful fact, you get"
echo "millions of command line switches, probably seriously slowing down your compilation time."
echo
echo "GCC 4.4.0 causes pcsx2 to crash at *any* optimization above 0, yet mysteriously"
echo "works properly if you add in the flags for all the optimizations yourself, which I have done."
echo "Enjoy!"
echo
fi