diff --git a/Makefile.system b/Makefile.system index 4c498ba1a..5ff174300 100644 --- a/Makefile.system +++ b/Makefile.system @@ -149,6 +149,26 @@ EXTRALIB += -defaultlib:advapi32 SUFFIX = obj PSUFFIX = pobj LIBSUFFIX = lib +ifeq ($(C_COMPILER), GCC) +#Test for supporting MS_ABI +GCCVERSIONGTEQ4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 4) +GCCVERSIONGT4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \> 4) +GCCMINORVERSIONGTEQ7 := $(shell expr `$(CC) -dumpversion | cut -f2 -d.` \>= 7) +ifeq ($(GCCVERSIONGT4), 1) +# GCC Majar version > 4 +# It is compatible with MSVC ABI. +CCOMMON_OPT += -DMS_ABI +endif + +ifeq ($(GCCVERSIONGTEQ4), 1) +ifeq ($(GCCMINORVERSIONGTEQ7), 1) +# GCC Version >=4.7 +# It is compatible with MSVC ABI. +CCOMMON_OPT += -DMS_ABI +endif +endif + +endif endif ifeq ($(OSNAME), Interix) diff --git a/kernel/x86/zdot_sse2.S b/kernel/x86/zdot_sse2.S index efebe637b..61e1bfc27 100644 --- a/kernel/x86/zdot_sse2.S +++ b/kernel/x86/zdot_sse2.S @@ -1541,6 +1541,16 @@ popl %ebx popl %esi popl %edi -/*remove the hidden return value address from the stack.*/ +#if defined(OS_WINNT) || defined(OS_CYGWIN_NT) || defined(OS_INTERIX) +#ifdef MS_ABI +/* For MingW GCC >= 4.7. It is compatible with MSVC ABI. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36834 */ + ret +#else +/* remove the hidden return value address from the stack. For MingW GCC < 4.7 */ ret $0x4 +#endif +#else +/*remove the hidden return value address from the stack on Linux.*/ + ret $0x4 +#endif EPILOGUE