On 2/6/20, Charles Stanhope <char...@stanho.pe> wrote:
> On 2/6/20, Andy Wingo <wi...@pobox.com> wrote:
>
>> Given that John said that compilation went fine with
>> GUILE_JIT_THRESHOLD=-1, I think perhaps this problem may have been fixed
>> in the past.  My suspicions are that this issue is an ABI issue with
>> lightening that could perhaps be reproduced by:
>>
>>   git co https://gitlab.com/wingo/lightening
>>   cd lightening
>>   make -C tests test-native
>>
>> Of course any additional confirmation is useful and welcome!
>
> I haven't been able to get guile to compile under Cygwin (just a
> compilation error I haven't had time to track down), but I was able to
> quickly try the above. I get:
>
> Testing: test-native-call_10
> call_10.c:9: assertion failed: e == 4
> /bin/sh: line 1:  7063 Aborted                 (core dumped) ./$test
> make: *** [Makefile:31: test-native] Error 134
>

Andy, I don't know if you'd want to continue this here or on
lightening's gitlab page, but I looked into this a little bit a few
minutes here and there this past weeek. The x86 "fast-call" calling
convention used on Windows x64[0] and shared by Cygwin[1] requires
that the caller reserve 32 bytes of memory on the stack for the callee
to spill the register parameters (even if the callee takes fewer than
four parameters). I think lightening is currently missing that for the
x64 case for Cygwin.

To test the idea, I made a small modification (patch attached) that is
*not* intended as a solution as it doesn't work for the general case,
but it does allow the tests to pass on Cygwin 64.

[0] 
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-2019
[1] https://cygwin.com/cygwin-ug-net/programming.html#gcc-64

--
Charles
diff --git a/lightening/x86.c b/lightening/x86.c
index 965191a..91b3a94 100644
--- a/lightening/x86.c
+++ b/lightening/x86.c
@@ -338,11 +338,13 @@ next_abi_arg(struct abi_arg_iterator *iter, jit_operand_t *arg)
   if (is_gpr_arg(abi) && iter->gpr_idx < abi_gpr_arg_count) {
     *arg = jit_operand_gpr (abi, abi_gpr_args[iter->gpr_idx++]);
 #ifdef __CYGWIN__
+    iter->stack_size += 8;
     iter->fpr_idx++;
 #endif
   } else if (is_fpr_arg(abi) && iter->fpr_idx < abi_fpr_arg_count) {
     *arg = jit_operand_fpr (abi, abi_fpr_args[iter->fpr_idx++]);
 #ifdef __CYGWIN__
+    iter->stack_size += 8;
     iter->gpr_idx++;
 #endif
   } else {

Reply via email to