[MLton] Problem with MinGW

Matthew Fluet fluet@cs.cornell.edu
Thu, 8 Jun 2006 23:08:05 -0400 (EDT)


>> I thought the "reserveEsp" hack for Cygwin was for signal handling,
>> since Cygwin doesn't provide sigaltstack.
>
> Me too.  Although I was confused by the contradiction between code
> defining reserveEsp and its accompanying comment.
>
>         val reserveEsp =
>            (* There is no sigaltstack on cygwin, we need to reserve %esp to
>             * hold the C stack pointer.  We need to do this even in programs
>             * that don't handle signals, since signals get used under the hood
>             * in Cygwin.
>             *)
>            handlesSignals andalso let open Control in !targetOS = Cygwin end
>
> Given the comment, I would have expected an "orelse" instead of an
> "andalso".  Your recollection jibes with the code.

Looking at the revision log for x86-codegen.fun, I see that the code 
changed from

"let open Control in !targetOS = Cygwin end"

to

"handlesSignals andalso let open Control in !targetOS = Cygwin end"

in December '03 (at r2565), which corresponds to the time of the thread 
noted below.  In that thread, you noted that Cygwin seemed not to be using 
signals under the hood, so the comment seems to be out of date.

> In any case, this problem sounds eerily like the thread titled
>
>  "Cygwin, file open, and reserveEsp"
>
> mentioned in December '03
>
>  http://mlton.org/pipermail/mlton/2003-December/thread.html
>
>> But, it's another good guess where the native and C codegens differ.
>
> Yeah, some weirdness about the MinGW C calling convention/invariants
> feels like the right place.