RE: Problems with libgmp

2000-11-15 Thread Simon Marlow

 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

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: Problems with libgmp

2000-11-15 Thread Michael Marte

Hello Simon,

 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.

Obviously, when linking, it did not use the one in the tree :-(
Conclusion: The Linux linker does not behave like other linkers or
there is a bug in some Makefile.

 BTW, you can't use GMP 3 with ghc-4.08.1 (the native code generator at
 least will break).

Ok, I'll to try to get a snapshot from the CVS repository.

Thanks,
Michael



___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Instant readFile

2000-11-15 Thread George Russell

The 
   readFile :: FilePath - IO String
action returns the contents of the associated file.  This is almost what
I want, but not quite, because readFile is lazy.  Hence if the string is
only partly read, the file is still open.  What I want instead is a function
which
   (a) opens the file;
   (b) slurps the complete contents compactly into an array;
   (c) closes the file;
   (d) makes the contents of the array available as a String.
So instead I wrote the following:

copyFileToString  :: FilePath - IO String
copyFileToString file =
   do
  (addr,len) - IOExts.slurpFile file
  CString.unpackCStringLenIO addr len

However on further consideration this also seems to me to be unsatisfactory, 
because although I don't understand this issue very well, I don't think
the (addr) address containing the complete file contents will ever get
deallocated, because there's no way the GC can know that this particular
Addr can be free'd.  (Is that correct?)  So please, how _should_ I write this
function?   For example, I could try and wrap the addr into a ForeignObj,
but then how would I ensure that when the String gets gc'd, the ForeignObj
does too?

It all is a bit of a mystery to me how you are supposed to use Addr like things
without space leaks.  A little more explanation in the documentation would not
perhaps be amiss . . .

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users