From 2573311308a43d0b1058c4be23173def5a9d4571 Mon Sep 17 00:00:00 2001 From: Zhang Xianyi Date: Mon, 24 Sep 2012 20:34:33 +0800 Subject: [PATCH] refs #140. Fixed zdot incompatibility ABI issue with GCC 4.7 on Win 32. GCC 4.7 uses MSVC ABI on Win 32. This means the caller pops the hidden pointer for returning aggregate structures larger than 8 bytes. --- Makefile.system | 20 ++++++++++++++++++++ kernel/x86/zdot_sse2.S | 12 +++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Makefile.system b/Makefile.system index 4c498ba1ae..5ff174300e 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 efebe637b7..61e1bfc27f 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