Problems with libgmp

Simon Marlow simonmar@microsoft.com
Wed, 15 Nov 2000 01:50:04 -0800


> I am maintaining the Haskell stuff at informatik.uni-muenchen.de.
> (I took over the job from Sven Panne.)
> 
> As a first exercise, I try to compile ghc-4.08.1 from scratch.
> But I always run into trouble with the libgmp stuff.
> IMHO, my problems are caused by several factors:
> 
> 1. We use Suse Linux 7.0 (that provides libgmp-3.0.x).
> 2. The ghc-4.08-1 distribution includes libgmp-2.x.x.
> 3. libgmp-3.0.x uses prefixed names (__gnump...). Prefixed names
> are generated only if the header file is included.
> 4. The configure script does not recognize that libgmp is
> installed (because it does not include the header file.)
> 5. When linking, the linker cannot resolve symbols prefixed by mpz_
> (because the 2.x.x header file was used in compilation but the
> linker uses the shared library provided by Suse Linux.)
> 5. Even if informed about the local installation of libgmp 
> (by manually
> changing config.cache), the 2.x.x header file will be used (again 
> resulting in unresolved bindings when linking).
> 
> The same problems occur when bootstrapping from .hc files.
> 
> What to do? Should I hack the Makefiles? Should I replace the libgmp
> distribution included in the ghc distribution by some new 3.x.x
> distribution?

I'll try to clarify the situation, since it's a bit confusing.

  - GHC tries to detect GMP 2 on the host system during the
    configuration process.  If it detects it, the build will
    go on to use the installed version.

  - If GMP 2 was *not* found, then we fall back to the copy of
    GMP in the source tree, which is build statically.

  - the RPMs have a dependency on the gmp2 packages.

  - GMP 3 is only source compatible with GMP 2, as you discovered.
    Furthermore, using the GMP 2 headers with the GMP 3 library
    aint gonna work. (if your system is set up like this, then
    it's broken, just like ours :-)

  - GHC versions post-4.08.X use GMP 3.

So, I can't quite work out what went wrong in your case.  If the build
didn't detect GMP 2, then it should have just used the one in the tree.
BTW, you can't use GMP 3 with ghc-4.08.1 (the native code generator at
least will break).

Hope this helps :)

Cheers,
	Simon