[PPL-devel] GMP memory allocation problem in SWI-Prolog 5.6.38 and following versions

Pedro Baltazar Vasconcelos pbv at dcc.fc.up.pt
Tue Oct 2 11:39:18 CEST 2007


On Tue, 02 Oct 2007 07:42:28 +0200
Roberto Bagnara <bagnara at cs.unipr.it> wrote:

> 
> Starting from version 5.6.38 of SWI-Prolog, applications using SWI-Prolog and
> GMP started failing.  The problem is due to the fact that SWI-Prolog overrides
> the memory allocation functions used by GMP by calling mp_set_memory_functions().

Hello,

I have experienced the same issue a couple of years ago with Andy King's  experimental PPL bindings for the Glasgow Haskell compiler (GHC). 
The problem was (and still is, I think) the reason why there is no "official" Haskell/GHC binding in the PPL distribution. 
I also contacted Simon Marlow on the GHC development side and he acknowledged the problem but didnt't have a solution for it in the near horizon (in the longer run, they might stop using GMP inside the Haskell runtime system).

Since I desperately needed to use the PPL with my Haskell programs I did a quick and dirty hack that worked (under Linux at least): 
1) create a duplicate libmygmp with renamed symbols (with a prefix);
2) create a special libmyppl that uses libmygmp instead of libgmp; 
3) link my Haskell code with libmyppl.

I used objcopy on the library binaries rather than modify the sources. But for some reason I could only get this to work with the static libraries. Anyway, I can pass you a short script that does the library renaming if you are interested.


Best regards,

Pedro Vasconcelos



More information about the PPL-devel mailing list