patch applied (packages/integer-gmp): Patch GMP to always use the GHC allocation functions

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sat Sep 19 16:51:49 EDT 2009


On Sat, 2009-09-19 at 22:08 +0200, Matthias Kilian wrote:
> On Mon, Jun 22, 2009 at 01:35:28PM -0700, Ian Lynagh wrote:
> > Sun Jun 21 11:29:57 PDT 2009  Ian Lynagh <igloo at earth.li>
> >   * Patch GMP to always use the GHC allocation functions
> >   This works around a crash (only on OS X for some reason?) where the GHCi
> >   GMP uses the systems memory allocator. We should fix this properly, by
> >   making ghci run constructor functions.
> > 
> >     M ./cbits/alloc.c -6 +6
> >     M ./gmp/ghc.mk -1 +1
> >     A ./gmp/tarball/gmp-4.2.4-nodoc-patched.tar.bz2
> >     R ./gmp/tarball/gmp-4.2.4-nodoc.tar.bz2
> >     A ./gmp/tarball/patch
> 
> Can't this been done using mp_set_memory_functions() instead of
> patching memory.c?

Yes, that's what the constructor does, but GHCi is not running the
constructor, because its linker does not know about them.

However, it still does not make any sense because GHCi itself is linked
against GMP (because GHCi depends on base which depends on integer-gmp)
so it already calls mp_set_memory_functions(), so it should work even if
GHCi does not call the constructor when loading its copy of the
integer-gmp. The only way I can imagine it going wrong is if somehow
they are using two different instances of GMP, eg one statically linked
and one dynamically.

Duncan



More information about the Cvs-libraries mailing list