Error compiling GHC/Num.lhs

Hello, I'm trying to build GHC from darcs. Unfortunately compilation fails with the following error: ... cpphs: #error Please define LEFTMOST_BIT to be 2^(SIZEOF_HSWORD*8-1) in GHC/Num.lhs at line 27 col 1 make[1]: *** [doc.library.base] Error 1 make[1]: Leaving directory `/home/bas/development/haskell/ghc/libraries' make: *** [stage1] Error 2 ... The following is the part where the error occurs in libraries/base/GHC/Num.lhs : ... #include "MachDeps.h" #if SIZEOF_HSWORD == 4 #define LEFTMOST_BIT 2147483648 #define DIGITS 9 #define BASE 1000000000 #elif SIZEOF_HSWORD == 8 #define LEFTMOST_BIT 9223372036854775808 #define DIGITS 18 #define BASE 1000000000000000000 #else #error Please define LEFTMOST_BIT to be 2^(SIZEOF_HSWORD*8-1) -- DIGITS should be the largest integer such that 10^DIGITS < LEFTMOST_BIT -- BASE should be 10^DIGITS. Note that ^ is not available yet. #endif ... Note that in build.mk I set BuildFlavour = quick and I also tried building it with the following options added: SRC_HC_OPTS += -optc-march=athlon64 -opta-march=athlon64 SRC_CC_OPTS += -march=athlon64 What can be the problem? Thanks, Bas van Dijk Some info on my system (please ask for more if you need it): $ uname -a Linux bassbox 2.6.20-gentoo-r6 #1 PREEMPT Thu Apr 19 10:53:57 CEST 2007 i686 AMD Athlon(tm) 64 Processor 3200+ AuthenticAMD GNU/Linux $ gcc --version gcc (GCC) 4.1.1 (Gentoo 4.1.1-r3)

Hi Bas, On Sun, Apr 29, 2007 at 11:54:35AM +0000, Bas van Dijk wrote:
I'm trying to build GHC from darcs. Unfortunately compilation fails with the following error:
... cpphs: #error Please define LEFTMOST_BIT to be 2^(SIZEOF_HSWORD*8-1) in GHC/Num.lhs at line 27 col 1 make[1]: *** [doc.library.base] Error 1 make[1]: Leaving directory `/home/bas/development/haskell/ghc/libraries' make: *** [stage1] Error 2 ...
The following is the part where the error occurs in libraries/base/GHC/Num.lhs : ... #include "MachDeps.h" #if SIZEOF_HSWORD == 4
This is a cpphs bug - IIRC it wasn't recursively expanding SIZEOF_HSWORD. Either install cpphs from darcs (I don't think there is a release with the fix yet) or uninstall it so that cpp is used instead. Thanks Ian

On 4/29/07, Ian Lynagh
Hi Bas,
On Sun, Apr 29, 2007 at 11:54:35AM +0000, Bas van Dijk wrote:
I'm trying to build GHC from darcs. Unfortunately compilation fails with the following error:
... cpphs: #error Please define LEFTMOST_BIT to be 2^(SIZEOF_HSWORD*8-1) in GHC/Num.lhs at line 27 col 1 make[1]: *** [doc.library.base] Error 1 make[1]: Leaving directory `/home/bas/development/haskell/ghc/libraries' make: *** [stage1] Error 2 ...
The following is the part where the error occurs in libraries/base/GHC/Num.lhs : ... #include "MachDeps.h" #if SIZEOF_HSWORD == 4
This is a cpphs bug - IIRC it wasn't recursively expanding SIZEOF_HSWORD. Either install cpphs from darcs (I don't think there is a release with the fix yet) or uninstall it so that cpp is used instead.
Thanks Ian
After uninstalling cpphs the error no longer occurs, thanks! However the build now crashes when running Haddock on Cabal: ... ifBuildable/ifBuildable Cabal setup/Setup haddock Preprocessing library Cabal-1.1.7... Running Haddock for Cabal-1.1.7... Warning: cannot use package base-2.1: ghc-pkg failed dist/build/tmp/Distribution/PreProcess.hs:"Distribution/PreProcess.hs": 115:1: parse error in doc string: [TokSpecial '/',TokString "build",TokSpecial '"'] make[1]: *** [doc.library.Cabal] Error 1 make[1]: Leaving directory `/home/bas/development/haskell/ghc/libraries' make: *** [stage1] Error 2 The respected code from libraries/Cabal/Distribution/PreProcess.hs (line 115 and onwards a bit): data PreProcessor = PreProcessor { -- Is the output of the pre-processor platform independent? eg happy output -- is portable haskell but c2hs's output is platform dependent. -- This matters since only platform independent generated code can be -- inlcuded into a source tarball. platformIndependent :: Bool, -- TODO: deal with pre-processors that have implementaion dependent output -- eg alex and happy have --ghc flags. However we can't really inlcude -- ghc-specific code into supposedly portable source tarballs. runPreProcessor :: (FilePath, FilePath) -- Location of the source file relative to a base dir -> (FilePath, FilePath) -- Output file name, relative to an output base dir -> Int -- verbosity -> IO () -- Should exit if the preprocessor fails } Do I maybe need a newer Haddock for this? Currently I have version 0.8. Installing darcs version right now... Thanks, Bas van Dijk

Bas van Dijk wrote:
However the build now crashes when running Haddock on Cabal: ... ifBuildable/ifBuildable Cabal setup/Setup haddock Preprocessing library Cabal-1.1.7... Running Haddock for Cabal-1.1.7... Warning: cannot use package base-2.1: ghc-pkg failed dist/build/tmp/Distribution/PreProcess.hs:"Distribution/PreProcess.hs": 115:1: parse error in doc string: [TokSpecial '/',TokString "build",TokSpecial '"'] make[1]: *** [doc.library.Cabal] Error 1 make[1]: Leaving directory `/home/bas/development/haskell/ghc/libraries' make: *** [stage1] Error 2
Thanks, I think I've fixed this one now. Cheers, Simon

On 5/2/07, Simon Marlow
Thanks, I think I've fixed this one now.
You did indeed, thanks!
Now I get another error when compiling main/GHC.hs:
../compiler/stage1/ghc-inplace -H64m -Onot -fasm -optc-march=athlon64
-opta-march=athlon64 -istage2/utils -istage2/basicTypes
-istage2/types -istage2/hsSyn -istage2/prelude -istage2/rename
-istage2/typecheck -istage2/deSugar -istage2/coreSyn
-istage2/specialise -istage2/simplCore -istage2/stranal
-istage2/stgSyn -istage2/simplStg -istage2/codeGen -istage2/main
-istage2/profiling -istage2/parser -istage2/cprAnalysis
-istage2/ndpFlatten -istage2/iface -istage2/cmm -istage2/nativeGen
-istage2/ghci -Istage2 -DGHCI -package template-haskell
-DGHCI_TABLES_NEXT_TO_CODE -threaded -package readline -DUSE_READLINE
-cpp -fglasgow-exts -fno-generics -Rghc-timing -I. -Iparser -package
unix -package Cabal -ignore-package lang -recomp -Rghc-timing -Onot
-fasm -H16M '-#include "cutils.h"' -package-name ghc-6.7.20070502
-fgenerics -c main/GHC.hs -o stage2/main/GHC.o -ohi
stage2/main/GHC.hi
main/GHC.hs:2223:50:
Couldn't match expected type `InteractiveContext'
against inferred type `[Name]'
In the sixth argument of `ResumeHandle', namely `names'
In the expression:
ResumeHandle
breakMVar statusMVar final_names final_ic resume_ic names
In the definition of `res':
res = ResumeHandle
breakMVar statusMVar final_names final_ic resume_ic names
main/GHC.hs:2230:54:
Couldn't match expected type `InteractiveContext'
against inferred type `[Name]'
In the `hsc_IC' field of a record
In the second argument of `writeIORef', namely
`hsc_env {hsc_IC = final_ic}'
In the expression: writeIORef ref (hsc_env {hsc_IC = final_ic})
main/GHC.hs:2270:26:
Constructor `ResumeHandle' should have 7 arguments, but has been given 6
In the pattern:
ResumeHandle breakMVar
statusMVar
final_names
final_ic
resume_ic
names
In the definition of `resume':
resume (Session ref)
(res@(ResumeHandle breakMVar
statusMVar
final_names
final_ic
resume_ic
names))
= do hsc_env <- readIORef ...
writeIORef ... (...)
....
<

Bas van Dijk wrote:
On 5/2/07, Simon Marlow
wrote: Thanks, I think I've fixed this one now.
You did indeed, thanks!
Now I get another error when compiling main/GHC.hs:
../compiler/stage1/ghc-inplace -H64m -Onot -fasm -optc-march=athlon64 -opta-march=athlon64 -istage2/utils -istage2/basicTypes -istage2/types -istage2/hsSyn -istage2/prelude -istage2/rename -istage2/typecheck -istage2/deSugar -istage2/coreSyn -istage2/specialise -istage2/simplCore -istage2/stranal -istage2/stgSyn -istage2/simplStg -istage2/codeGen -istage2/main -istage2/profiling -istage2/parser -istage2/cprAnalysis -istage2/ndpFlatten -istage2/iface -istage2/cmm -istage2/nativeGen -istage2/ghci -Istage2 -DGHCI -package template-haskell -DGHCI_TABLES_NEXT_TO_CODE -threaded -package readline -DUSE_READLINE -cpp -fglasgow-exts -fno-generics -Rghc-timing -I. -Iparser -package unix -package Cabal -ignore-package lang -recomp -Rghc-timing -Onot -fasm -H16M '-#include "cutils.h"' -package-name ghc-6.7.20070502 -fgenerics -c main/GHC.hs -o stage2/main/GHC.o -ohi stage2/main/GHC.hi
main/GHC.hs:2223:50: Couldn't match expected type `InteractiveContext' against inferred type `[Name]' In the sixth argument of `ResumeHandle', namely `names' In the expression: ResumeHandle breakMVar statusMVar final_names final_ic resume_ic names In the definition of `res': res = ResumeHandle breakMVar statusMVar final_names final_ic resume_ic names
I believe this one is now fixed, sorry about that. Cheers, Simon

On 5/2/07, Simon Marlow
I believe this one is now fixed, sorry about that.
No problem. I'm now able to successfully make GHC. Thanks about that! However 'make install' fails: $ make install ... ifBuildable/ifBuildable base setup/Setup install copy directory 'dist/doc/html/base' to '/home/bas/share/ghc/doc/html/base'. ... copy dist/build/HSbase-2.1.o to /home/bas/lib/base-2.1/ghc-6.7.20070502/HSbase-2.1.o Registering base-2.1... Reading package info from ".installed-pkg-config" ... done. ghc-pkg: /home/bas/lib/base-2.1/ghc-6.7.20070502/include doesn't exist or isn't a directory (use --force to override) make[1]: *** [install.library.base] Error 1 make: *** [install] Error 1 The directory: /home/bas/lib/base-2.1/ghc-6.7.20070502/include indeed does not exists. What can be the problem? regards, Bas van Dijk

[Note: Sorry if this is a duplicate. I originally sent the patches inline in the mail, but the resulting mail grew rather big and is "awaiting moderators approval" now. (moderators: no need to approve it)] Bas van Dijk wrote:
On 5/2/07, Simon Marlow
wrote: I believe this one is now fixed, sorry about that.
No problem. I'm now able to successfully make GHC. Thanks about that!
However 'make install' fails:
$ make install ... ifBuildable/ifBuildable base setup/Setup install copy directory 'dist/doc/html/base' to '/home/bas/share/ghc/doc/html/base'. ... copy dist/build/HSbase-2.1.o to /home/bas/lib/base-2.1/ghc-6.7.20070502/HSbase-2.1.o
Registering base-2.1... Reading package info from ".installed-pkg-config" ... done. ghc-pkg: /home/bas/lib/base-2.1/ghc-6.7.20070502/include doesn't exist [...]
I'm sorry, that's my fault. I have two patches that should fix this: One for libraries/Cabal, http://int-e.home.tlink.de/haskell/Cabal-fix-installIncludeFiles.patch and another for libraries/base: http://int-e.home.tlink.de/haskell/base-install-includes.patch The semantics for the includes: and install-includes: fields in cabal files has changed; the patch against base adds an install-includes field to the base.cabal file that uses the new semantics. I was going to send this patch in now anyway. I'm afraid I missed the interaction of the install directory and the package registration, and obviously I didn't test this properly. So I revert the behaviour back to always creating the include directory. Bertram

On 5/2/07, Bertram Felgenhauer
... I have two patches that should fix this: ...
Thanks, I applied base-install-includes.patch. (Cabal-fix-installIncludeFiles.patch was already applied according to darcs.) However, in order to apply the patches I did a new checkout of GHC without the --partial. This seemed to have pulled a few new patches that break my build again. I fixed the first error (I darcs send the patch): ./compiler/coreSyn/CoreUtils.lhs 262 -mkAltExpr DEFAULT = panic "mkAltExpr" +mkAltExpr DEFAULT _ _ = panic "mkAltExpr" This leaves the second error when building base: Building base-2.1... GHC/Exts.hs:29:1: Not in scope: type constructor or class `IsString' If I import Data.String in GHC/Exts.hs I get the following error: Building base-2.1... ghc-6.7.20070502: panic! (the 'impossible' happened) (GHC version 6.7.20070502 for i386-unknown-linux): mkWWcpr: not a product base:Data.Typeable.TypeRep{tc r3eN} What can be the problem? regards, Bas van Dijk

the base library is in a bit of a sad state.
I think I have fixed it. Try pulling (both compiler and libraries) and try again
S
| -----Original Message-----
| From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org] On
| Behalf Of Bas van Dijk
| Sent: 03 May 2007 11:32
| To: Bertram Felgenhauer
| Cc: glasgow-haskell-users@haskell.org
| Subject: Re: Error compiling GHC/Num.lhs
|
| On 5/2/07, Bertram Felgenhauer
participants (5)
-
Bas van Dijk
-
Bertram Felgenhauer
-
Ian Lynagh
-
Simon Marlow
-
Simon Peyton-Jones