Possible issue on windows build (mingw)

Torbjorn Granlund tg at gmplib.org
Thu Apr 5 21:53:18 CEST 2012

Vlad Gabriel <clampi at yahoo.com> writes:

  I can confirm that replacing
      sub    $8, %rsp
      add    $8, %rsp
      sub    $40, %rsp
      add    $40, %rsp

(I assume a "works" can be assumed here, judging from the continuation of
your message...)

  However, I can not understand why. Dwelving into Win64 ABI is not the
  most friendly stuff. One opinion, is that the caller always has to
  reserve space on stack to callee to home-registers. That is required by
  the calling convention. The space is used by the callee to store the 1st
  four parameters onto stack. It does not matter that the callee has 0 or
  less than 4 parameters, caller must allocate space on stack for callee
  to "home" the param registers. However, the callee are your own asm
  functions, that do not store the parameters on stack, so I am confused
  as why it works like that.
This was indeed the reason for why I suggested the change.

I did read the M$ docs, except for the unwind stuff.  I was baffled
about the poor quality of such absolutely critical documentation; they
do not pin down things but leave many things open to several reasonable
conflicting interpretations.

  The ABI specifies how to write a frame function so it can be unwinded
  (by the OS). This impose great restriction on prologue, epilogue and
  stack manipulation. It also make heavy use of assembler directives that
  magically generates the required info to unwind the function. Good thing
  is that latest GNU binutils do support the directives, bad news is that
  they are not documented in their help. However,

Alas, I think I will not undertake this task.

(I can right away admit that error handling and error recovery is
perhaps GMP's weakest point.  Adding some zany unwind descriptors for
windoze is not the top item on the list of things to improve in this

Thanks for your bug report and your follow-through until things were
fixed.  GMP support would be a breeze if everyone did it like that!


More information about the gmp-bugs mailing list