GHC porting to FreeBSD-amd64 progress report

In my effort to produce a working FreeBSD-amd64 compiler I made some progress. Now I have a working stage1/ghc-inplace (which is a 32bit executable producing 64bit code). But the compilation of rts fails in file Apply.cmm with the following message: == gmake all -r; in /.amd_mnt/vestein/host/usr/home/wb/ghc-6.8.1/rts ------------------------------------------------------------------------ ../compiler/ghc-inplace -H16m -O -optc-O2 -package-name rts -static -I../gmp/gmpbuild -I. -#include HCIncludes.h -dcmm-lint -c Apply.cmm -o Apply.o In file included from Apply.cmm:13:0: /.amd_mnt/vestein/host/usr/home/wb/ghc-6.8.1/includes/Cmm.h:333:2: error: #error mp_limb_t != StgWord: assumptions in PrimOps.cmm are now false gmake[1]: *** [Apply.o] Error 1 gmake: *** [stage1] Error 1 This is, of course, because the derived constants SIZEOF_mp_limb_t is wrong. Is there a way to get to a working system from this intermediate stage? I tried to replace the real 32bit ghc in /usr/local/bin/ghc with a ghc-inplace, but this didn't work. Probably I only need to get the correct derived constants in the header files and remake the files depending on them. -- Dipl.-Math. Wilhelm Bernhard Kloke Institut fuer Arbeitsphysiologie an der Universitaet Dortmund Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-257 PGP: http://vestein.arb-phys.uni-dortmund.de/~wb/mypublic.key

W.B. Kloke wrote:
In my effort to produce a working FreeBSD-amd64 compiler I made some progress. Now I have a working stage1/ghc-inplace (which is a 32bit executable producing 64bit code). But the compilation of rts fails in file Apply.cmm with the following message:
== gmake all -r; in /.amd_mnt/vestein/host/usr/home/wb/ghc-6.8.1/rts ------------------------------------------------------------------------ ../compiler/ghc-inplace -H16m -O -optc-O2 -package-name rts -static -I../gmp/gmpbuild -I. -#include HCIncludes.h -dcmm-lint -c Apply.cmm -o Apply.o
In file included from Apply.cmm:13:0:
/.amd_mnt/vestein/host/usr/home/wb/ghc-6.8.1/includes/Cmm.h:333:2: error: #error mp_limb_t != StgWord: assumptions in PrimOps.cmm are now false gmake[1]: *** [Apply.o] Error 1 gmake: *** [stage1] Error 1
This is, of course, because the derived constants SIZEOF_mp_limb_t is wrong. Is there a way to get to a working system from this intermediate stage?
Are you following the porting instructions in http://hackage.haskell.org/trac/ghc/wiki/Building/Porting? I would expect SIZEOF_mp_limb_t to be correct, as it is generated by mkDerivedConstants. Perhaps you compiled mkDerivedConstants as a 32-bit executable? Cheers, Simon

Simon Marlow
Perhaps you compiled mkDerivedConstants as a 32-bit executable?
Yes. I was not attentive enough. But now I have got a working compiler on FreeBSD-amd64-7.0. If anybody is interested, I shall prepare a package of the installed binaries. The compiler is good enough to compile itself now. Though there are problems remaining. One the programs I tested the computation of Meertens numbers from Bird/Wadler's book. This program segfaults on amd64, but not on i386. Here it is: module Main(main,primes,sieve,meertens) where -- a Meertens number is one whose decimal representation conincides with -- its Gödel number -- The 1st is 81312000 = 2^8*3*5^3*7*11^2 main :: IO() main = do putStr ( show ( meertens 8 ) ) -- putStr ( show ( meertens 9 ) ) primes= sieve [2..] sieve (p : nos) = p: sieve(remove (multsof p) nos ) where multsof p n = n `rem` p == 0 remove p = filter (not.p) powers p = iterate (p*) 1 meertens k = [n| (n,g) <- candidates (0,1),n == g ] where candidates = concat . map ( search pps ) . tail . labels ps ps : pps = map powers ( take k primes ) search [] x = [x] search (ps : pps) x = concat ( map ( search pps ) (labels ps x )) labels ps (n,g) = zip ( map (m+) ds)(chop(map(g*)ps)) where m = 10 * n chop = takeWhile(< 10000000000) ds = [0..9] -- Dipl.-Math. Wilhelm Bernhard Kloke Institut fuer Arbeitsphysiologie an der Universitaet Dortmund Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-257 PGP: http://vestein.arb-phys.uni-dortmund.de/~wb/mypublic.key

Wilhelm B. Kloke wrote:
Simon Marlow
schrieb: Perhaps you compiled mkDerivedConstants as a 32-bit executable?
Yes. I was not attentive enough.
But now I have got a working compiler on FreeBSD-amd64-7.0. If anybody is interested, I shall prepare a package of the installed binaries.
If you can build a binary distribution, we'll happily upload it to haskell.org and make it available for download. Just 'make binary-dist' should produce a suitable distribution. However, you might want to wait for 6.8.2 in the next few days, as we fixed several important bugs.
The compiler is good enough to compile itself now. Though there are problems remaining. One the programs I tested the computation of Meertens numbers from Bird/Wadler's book. This program segfaults on amd64, but not on i386.
You'll probably find that the testsuite shows up this (and maybe other) bugs. Start with a full testsuite run, is my advice. Cheers, Simon

Simon Marlow
Wilhelm B. Kloke wrote:
However, you might want to wait for 6.8.2 in the next few days, as we fixed several important bugs.
I have found a couple of small bugs regarding FreeBSD. Changing the configure process would be helpful. FreeBSD-amd64 is identified as x86_64-unknown-freebsd, but the entry in configure uses amd64-*-freebsd*r; this should be made consistent. The FreeBSD cc needs -L/usr/local/lib and -I/usr/local/lib to find the native gmp (and possibly others, too) library. I tried to find out a way to use the FreeBSD-i386 ghc, which runs fine on FreeBSD-amd64, for bootstrap. The problem in this case is to substitute the 32bit assembler and linker instead of the 64bit versions. In case of the assembler the script as32 was usable like this one: #!/bin/sh /usr/bin/cc -Xassembler -32 $* But I failed to figure out the right ld32 script. -- Dipl.-Math. Wilhelm Bernhard Kloke Institut fuer Arbeitsphysiologie an der Universitaet Dortmund Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-257 PGP: http://vestein.arb-phys.uni-dortmund.de/~wb/mypublic.key
participants (3)
-
Simon Marlow
-
wb@arb-phys.uni-dortmund.de
-
Wilhelm B. Kloke