Skip to content

Commit 2573311

Browse files
committed
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.
1 parent 1d72b8b commit 2573311

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Makefile.system

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,26 @@ EXTRALIB += -defaultlib:advapi32
149149
SUFFIX = obj
150150
PSUFFIX = pobj
151151
LIBSUFFIX = lib
152+
ifeq ($(C_COMPILER), GCC)
153+
#Test for supporting MS_ABI
154+
GCCVERSIONGTEQ4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 4)
155+
GCCVERSIONGT4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \> 4)
156+
GCCMINORVERSIONGTEQ7 := $(shell expr `$(CC) -dumpversion | cut -f2 -d.` \>= 7)
157+
ifeq ($(GCCVERSIONGT4), 1)
158+
# GCC Majar version > 4
159+
# It is compatible with MSVC ABI.
160+
CCOMMON_OPT += -DMS_ABI
161+
endif
162+
163+
ifeq ($(GCCVERSIONGTEQ4), 1)
164+
ifeq ($(GCCMINORVERSIONGTEQ7), 1)
165+
# GCC Version >=4.7
166+
# It is compatible with MSVC ABI.
167+
CCOMMON_OPT += -DMS_ABI
168+
endif
169+
endif
170+
171+
endif
152172
endif
153173

154174
ifeq ($(OSNAME), Interix)

kernel/x86/zdot_sse2.S

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,16 @@
15411541
popl %ebx
15421542
popl %esi
15431543
popl %edi
1544-
/*remove the hidden return value address from the stack.*/
1544+
#if defined(OS_WINNT) || defined(OS_CYGWIN_NT) || defined(OS_INTERIX)
1545+
#ifdef MS_ABI
1546+
/* For MingW GCC >= 4.7. It is compatible with MSVC ABI. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36834 */
1547+
ret
1548+
#else
1549+
/* remove the hidden return value address from the stack. For MingW GCC < 4.7 */
15451550
ret $0x4
1551+
#endif
1552+
#else
1553+
/*remove the hidden return value address from the stack on Linux.*/
1554+
ret $0x4
1555+
#endif
15461556
EPILOGUE

0 commit comments

Comments
 (0)