gmp3 with 4.08.x

Michael Weber michael.weber@post.rwth-aachen.de
Wed, 25 Apr 2001 00:11:53 +0200


On Tue, Apr 24, 2001 at 15:55:59 +0000, Marcin 'Qrczak' Kowalczyk wrote:
> Tue, 24 Apr 2001 17:34:20 +0200, Michael Weber <michael.weber@post.rwth-aachen.de> pisze:
> 
> > Using it with -Onot doesn't expose an error (as you explained), and
> > using it with -O is not possible.  It automatically reverts to
> > compiling via C:
> 
> Use -O -fasm

Option order matters?!?!  That's evil!

> (I think that lots of code would break this way. Not all primops are
> implemented in the NCG.)

Well, if I take it as a bug, that "-O -fasm-x86" /= "-fasm-x86 -O",
then ghc4 does work with libgmp3.  

If not, well, here's a workaround:

[695]% /usr/lib/ghc-4.08.1/bin/ghc -O -fasm-x86 foo.hs
foo.o: In function `c2E7_ret':
foo.o(.text+0xb5): undefined reference to `mpz_get_si'
collect2: ld returned 1 exit status

[696]% cat foo.hs
module Main(main) where

main = do
  let bigInt = 100000000009999999999900000000 :: Integer
  print $ (fromIntegral bigInt :: Int)

[697]% /usr/lib/ghc-4.08.1/bin/ghc -O -S -fasm-x86 foo.hs
[698]% mv foo.s foo.S
[699]% gcc -o foo.o -c -I. -imacros /usr/include/gmp.h -I/usr/lib/ghc-4.08.1/includes foo.S
[700]% /usr/lib/ghc-4.08.1/bin/ghc -O -fasm-x86 foo.o
[701]% ./a.out
603070208
[702]% nm foo.o | grep mpz
         U __gmpz_get_si
[703]	 

The trick is using the -imacros option and .S


Cheers,
Michael
-- 
 /~\ ASCII ribbon | "i have decided to release the first 24GB of my genetic
 \ / campaign     |  code under the Artistic License. since this is DFSG
  X  against      |  compatible, could it go in main?"
 / \ HTML mail    |      -- debian-devel <20000417013615.E1735@megabite.net>