Fix for closures with sunpro compiler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/ChangeLog b/ChangeLog
index 289d195..ff76645 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-10 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Put local.exp in the right place.
+ * configure: Rebuilt.
+
+ * src/x86/ffi.c: Update comment about regparm function attributes.
+ * src/x86/sysv.S (ffi_closure_SYSV): The SUNPRO compiler requires
+ that all function arguments be passed on the stack (no regparm
+ support).
+
2013-01-08 Anthony Green <green@moxielogic.com>
* configure.ac: Generate local.exp. This sets CC_FOR_TARGET
diff --git a/configure b/configure
index 5876eb7..4a12b96 100755
--- a/configure
+++ b/configure
@@ -13068,10 +13068,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -fexceptions"
- touch testsuite/local.exp
+ touch local.exp
else
cat > local.exp <<EOF
-set CC_FOR_TARGET $CC
+set CC_FOR_TARGET "$CC"
EOF
fi
diff --git a/configure.ac b/configure.ac
index 7ffb36c..13d5bc2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,10 +40,10 @@ AX_CC_MAXOPT
AX_CFLAGS_WARN_ALL
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -fexceptions"
- touch testsuite/local.exp
+ touch local.exp
else
cat > local.exp <<EOF
-set CC_FOR_TARGET $CC
+set CC_FOR_TARGET "$CC"
EOF
fi
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index 611e221..3f46693 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -424,7 +424,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
/** private members **/
/* The following __attribute__((regparm(1))) decorations will have no effect
- on MSVC - standard cdecl convention applies. */
+ on MSVC or SUNPRO_C -- standard conventions apply. */
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
void** args, ffi_cif* cif);
void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
diff --git a/src/x86/sysv.S b/src/x86/sysv.S
index 69e7e8d..71502bb 100644
--- a/src/x86/sysv.S
+++ b/src/x86/sysv.S
@@ -182,9 +182,19 @@ ffi_closure_SYSV:
leal -24(%ebp), %edx
movl %edx, -12(%ebp) /* resp */
leal 8(%ebp), %edx
+#ifdef __SUNPRO_C
+ /* The SUNPRO compiler doesn't support GCC's regparm function
+ attribute, so we have to pass all three arguments to
+ ffi_closure_SYSV_inner on the stack. */
+ movl %edx, 8(%esp) /* args = __builtin_dwarf_cfa () */
+ leal -12(%ebp), %edx
+ movl %edx, 4(%esp) /* &resp */
+ movl %eax, (%esp) /* closure */
+#else
movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
leal -12(%ebp), %edx
movl %edx, (%esp) /* &resp */
+#endif
#if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
call ffi_closure_SYSV_inner
#else