Export to GitHub

hmpfr - GHCWithRenamedGMP.wiki


Introduction

This page documents how to modify ghc source code so that it can be safely linked with libraries that depend on gmp. The modifications consist in renaming (almost) all symbols defined in a copy of the gmp library included in integer-gmp.

Tested with: * ghc 7.2.1, 7.2.2, 7.4.1, 7.4.2, 7.6.1 on i386 Ubuntu 12.04

Details

  • untar the ghc source code tree
  • make sure ghc does not use an external gmp
    • I hacked this step by temporarily renaming /usr/include/gmp.h
      • I have not yet delved deep enough into the ghc build system to find a better way (suggestions welcome)
  • copy the files symbols and rename.sh to libraries/integer-gmp
  • make rename.sh executable
  • add one line to libraries/integer-gmp/gmp/ghc.mk so that it reads: ... libraries/integer-gmp/gmp/libgmp.a libraries/integer-gmp/gmp/gmp.h: $(RM) -rf libraries/integer-gmp/gmp/$(GMP_DIR) libraries/integer-gmp/gmp/gmpbuild libraries/integer-gmp/gmp/objs cat $(GMP_TARBALL) | $(BZIP2_CMD) -d | { cd libraries/integer-gmp/gmp && $(TAR_CMD) -xf - ; } mv libraries/integer-gmp/gmp/$(GMP_DIR) libraries/integer-gmp/gmp/gmpbuild $(SH) libraries/integer-gmp/rename.sh libraries/integer-gmp/symbols libraries/integer-gmp/gmp/gmpbuild

    (The last line should be added.)

  • configure and make ghc as usual