patch applied (packages/integer-gmp): Patch GMP to always use
the GHC allocation functions
Simon Marlow
marlowsd at gmail.com
Mon Sep 21 05:13:56 EDT 2009
On 19/09/2009 21:51, Duncan Coutts wrote:
> 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.
I expect that's what happens, but I can't see *how* it happens. Looking
at configure.ac and integer-gmp.buildinfo.in, it appears that
extra-libraries is empty when GMP is not found. So in that case, how do
we end up linking libgmp.a? And how does it get loaded by GHCi?
Cheers,
Simon
More information about the Cvs-libraries
mailing list