Index: configure =================================================================== --- configure (revision 24280) +++ configure (working copy) @@ -1504,6 +1504,28 @@ } fi +# Check whether compiler support -mstackrealign flag. +echocheck "cflag stackrealign" +cat > $TMPC << EOF +__attribute__((noinline)) static int foo3(int i1, int i2, int i3) { + return i3; +} +int main() { + return foo3(1,2,3)==3 ? 0 : 1; +} +EOF +_cflag_stackrealign= +if test "$cc_vendor" = "gnu" ; then + # Gcc above 4.2 and some earlier svn version support this flag for intel x86. + cc_check -O4 -mstackrealign && _cflag_stackrealign=-mstackrealign + if test -n "$_cflag_stackrealign" && ! tmp_run ; then + # Check the lost-third-parameter bug, try to fix it if we can. Referred in + # http://www.dribin.org/dave/blog/archives/2006/12/05/missing_third_param/ + cc_check -O4 $_cflag_stackrealign -fno-unit-at-a-time && tmp_run && _cflag_stackrealign="$_cflag_stackrealign -fno-unit-at-a-time" + fi +fi +test -n "$_cflag_stackrealign" && echores "$_cflag_stackrealign" || echores "no" + # --- # now that we know what compiler should be used for compilation, try to find @@ -7498,6 +7520,7 @@ EXTRAXX_INC = $_inc_extra $_inc_extraxx OPTFLAGS = $CFLAGS \$(EXTRA_INC) CXXFLAGS = $CXXFLAGS \$(EXTRAXX_INC) +CFLAG_STACKREALIGN = $_cflag_stackrealign INSTALLSTRIP = $_install_strip CHARSET = $_charset HELP_FILE = $_mp_help Index: loader/Makefile =================================================================== --- loader/Makefile (revision 24280) +++ loader/Makefile (working copy) @@ -11,6 +11,8 @@ # QTX emulation is not supported in Darwin ifneq ($(TARGET_OS),Darwin) SRCS_COMMON += wrapper.S +else +win32.o: CFLAGS += $(CFLAG_STACKREALIGN) endif endif