= Troubleshooting the GHC build = Here we keep track of failures that can occur when building GHC, with solutions. We don't expect anyone to read this page from beginning to end. The only way you get here is by searching, so remember when adding a new entry the most important thing to do is to '''include the error message verbatim''', so searches will find it. If a build failure is caused by a bug in GHC or the build system, please link to the ticket number so we can tell when it's safe to remove the entry and keep this page from getting too crufty. == Segmentation fault and "strange closure type" panics == If the build fails with a `segmentation fault (core dumped)` or a `strange closure type` panic from GHC, but the error goes away or occurs in a different place when you restart the build, then the problem is most likely with your hardware. Please run a [http://www.memtest.org/ memtest] before going any further. == Permission denied errors on Windows that go away when the build is restarted == A common cause of "permission denied" or "Access denied" errors during a build on Windows is having a realtime virus scanner. If you have a virus scanner turned on, try excluding the GHC build directory from realtime scanning if your virus scanner supports it, or otherwise disable the scanner while building GHC. See [wiki:Building/Preparation/Windows]. == Make has restarted itself 3 times; is there a makefile bug? == If you see this when building: {{{ ghc.mk:96: *** Make has restarted itself 3 times; is there a makefile bug?. Stop. }}} then it could mean you have introduced a build system bug, causing an infinite loop. This can also happen (although we don't know precisely why) if you modify something in a built tree, and then re-run `make`. In this case the error is just overly conservative, and restarting is the right workaround. It can also happen if you are building the sources on FreeBSD in a really fast environment, e.g. on a multi-core Xeon with multiple parallel threads ({{{make -j}}}) or a memory-backed file system ({{{mfs}}}, {{{tmpfs}}}) (see #7592). It is because precision of file timestamps is not fine-grained enough by default (due to the common VFS layer). You can change this granularity by adjusting the value of the {{{vfs.timestamp_precision}}} sysctl(3) variable (`sudo sysctl -w vfs.timestamp_precision=1`). If you encounter this without touching any files after typing 'make', then it's probably a bug in the build system. The `make -d` output will be useful in tracking it down, but depending on when it happens there might be a lot of it! == libraries/ghc-prim/GHC/PrimopWrappers.hs:48:18: Not in scope: `GHC.Prim.gcdInt#' == If you get this message when the build system runs Haddock {{{ libraries/ghc-prim/GHC/PrimopWrappers.hs:48:18: Not in scope: `GHC.Prim.gcdInt#' }}} it's probably because you have a file `PrimopWrappers.hs` in the source-code directory `libraries/ghc-prim/GHC/`. It's a derived file, and is now generated into `libraries/ghc-prim/dist-install/build/GHC/`. Just remove the offending files (probably `PrimopWrappers.hs` and `Prim.hs`) from the source directory and try again. == tar: unable to record current working directory: No such file or directory == On MSYS I got this, during the construction of a binary distribution: {{{ ... cd bindistprep && "/usr/bin/tar" cf - ghc-6.13.20091020 | bzip2 -c > ../bindistprep/ghc-6.13.20091020-i386-unknown-mingw32.tar.bz2 /usr/bin/tar: unable to record current working directory: No such file or directory }}} It turns out that, at least on my Windows XP machine, the `tar` in the MSYS bundle for 1.0.10 (namely `tar` version 1.19.90) simply fails when creating a tar archive for a directory. For example: {{{ sh-3.1$ tar cf foo.tar mk tar: unable to record current working directory: No such file or directory sh-3.1$ tar --version tar (GNU tar) 1.19.90 }}} I fixed this by downloading an up-to-date `tar`, from [http://sourceforge.net/projects/mingw/files/]. I put this `tar.exe` in `c:/msys/1.0/bin`, overwriting the old `tar.exe`. This works: {{{ sh-3.1$ tar cf foo.tar mk tar: unable to record current working directory: No such file or directory sh-3.1$ tar --version tar (GNU tar) 1.22 }}} Simon and/or Ian plan to investigate; is MSYS 1.0.10 really so broken? == wget: missing URL == On MSYS I got this: {{{ bash$ ./sync-all get ....snip... == Syncing tarballs == running wget http://darcs.haskell.org/ghc-tarballs/binutils-2.19.1-mingw32- bin.tar.gz -O mingw/binutils-2.19.1-mingw32-bin.tar.gz wget: missing URL Usage: wget [OPTION]... [URL]... }}} This happened to me with an old version of the shell (say "sh --version"). I think perhaps the path-mangling is different. With the MSYS recommended [wiki:Building/Preparation/Windows here], all is well. The shell there is version 3.1.0(1). == configure: error: C++ preprocessor "/lib/cpp" fails sanity check == On Windows, if you see this error when building GHC: {{{ checking how to run the C++ preprocessor... /lib/cpp configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details. make[1]: *** [libffi/stamp.ffi.configure] Error 1 }}} then you probably have the Microsoft C compiler in your `PATH`, and this has confused the `configure` script for `libffi`. Try editing your `PATH` so that it no longer points to the MS compilers and tools. == haddock: internal Haddock or GHC error: Data.Binary.getWord8: end of file == If you see this {{{ Documentation created: stage2/doc/html/ghc/index.html cd libraries && sh gen_contents_index --inplace haddock: internal Haddock or GHC error: Data.Binary.getWord8: end of file make[1]: *** [libraries/index.html] Error 1 make: *** [all] Error 2 }}} it's probably because you have an old library in your tree with incomprehensible `.haddock` files. Try {{{ rm libraries/*/*/doc/*/*/*.haddock }}} === ar: Bad file number === '''Fixed in 6.12.1'''. See #3201. Workaround: add `SplitObjs=NO` to `mk/build.mk`. === chr: bad argument === Occasionally you see this: {{{ Compile failed (status 256) errors were: ghc-stage2.exe: panic! (the 'impossible' happened) (GHC version 6.11.20090722 for i386-unknown-mingw32): Prelude.chr: bad argument: 50331648 }}} This is almost certainly because you have stale interface files (`Foo.hi`) lying around, and GHC's binary interface-file format has changed. Try `make distclean` and rebuild. If you still get it, use `find` to find `*.hi` and remove them. === All binaries crash (Windows only) === On Windows you may see this {{{ "inplace/bin/hsc2hs.exe" --cc=gcc --ld=gcc --cflag=-g --cflag=-O2 --cflag=-D__GLASGOW_HASKELL__=611 '--cflag=-O' '--cflag=-g' '--cflag=-O2' '--cflag=-Ilibraries/hpc/.' '--cflag=-isystemc:/ghc/ghc-6.10.3\directory-1.0.0.3\include' '--cflag=-isystemc:/ghc/ghc-6.10.3\old-time-1.0.0.2\include' '--cflag=-isystemc:/ghc/ghc-6.10.3\Win32-2.2.0.0\include' '--cflag=-isystemc:/ghc/ghc-6.10.3\bytestring-0.9.1.4\include' '--cflag=-isystemc:/ghc/ghc-6.10.3\base-4.1.0.0\include' '--cflag=-isystemc:/ghc/ghc-6.10.3/include' '--cflag=-isystemPAPI_INCLUDE_DIR' '--lflag=-Lc:/ghc/ghc-6.10.3\directory-1.0.0.3' '--lflag=-Lc:/ghc/ghc-6.10.3\old-time-1.0.0.2' '--lflag=-Lc:/ghc/ghc-6.10.3\old-locale-1.0.0.1' '--lflag=-Lc:/ghc/ghc-6.10.3\filepath-1.1.0.2' '--lflag=-Lc:/ghc/ghc-6.10.3\containers-0.2.0.1' '--lflag=-Lc:/ghc/ghc-6.10.3\array-0.2.0.0' '--lflag=-Lc:/ghc/ghc-6.10.3\syb-0.1.0.1' '--lflag=-Lc:/ghc/ghc-6.10.3\Win32-2.2.0.0' '--lflag=-Lc:/ghc/ghc-6.10.3\bytestring-0.9.1.4' '--lflag=-Lc:/ghc/ghc-6.10.3\base-4.1.0.0' '--lflag=-Lc:/ghc/ghc-6.10.3\integer-0.1.0.1' '--lflag=-Lc:/ghc/ghc-6.10.3\ghc-prim-0.1.0.0' '--lflag=-Lc:/ghc/ghc-6.10.3' '--lflag=-Lc:/ghc/ghc-6.10.3/gcc-lib' '--lflag=-luser32' '--lflag=-lgdi32' '--lflag=-lwinmm' '--lflag=-lkernel32' '--lflag=-ladvapi32' '--lflag=-lwsock32' '--lflag=-lmsvcrt' '--lflag=-lkernel32' '--lflag=-luser32' '--lflag=-lshell32' '--lflag=-lm' '--lflag=-lffi' '--lflag=-lgmp' '--lflag=-lwsock32' libraries/hpc/./Trace/Hpc/Reflect.hsc -o libraries/hpc/dist-boot/build/Trace/Hpc/Reflect.hs running libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.exe failed command was: libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.exe >libraries/hpc/dist-boot/build/Trace/Hpc/Reflect.hs make[1]: *** [libraries/hpc/dist-boot/build/Trace/Hpc/Reflect.hs] Error 1 make: *** [all] Error 2 }}} A dialog pops up: “Reflect_hsc_make.exe has stopped working”, with the buttons “Debug” and “Close program”. This signals an obscure problem whose source is still unknown: if GHC links in certain Windows libraries, `kernel32` and `msvcrt`, the resulting program crashes. See [http://www.haskell.org/pipermail/glasgow-haskell-bugs/2009-April/018643.html Sigbjorn's email]. We wish we knew why! We've worked around this in GHC 6.10.4 (and later) so that the problem shouldn't arise if you use that to build GHC with. But if you have an earlier GHC on your machine you can still work around it as follows. These two commands will fix up the base and Win32 packages respectively to remove the offending libraries from `extra-libraries` and add a suitable `extra-ghci-libraries`: {{{ ghc-pkg describe 'base-4*' | sed 's/msvcrt//;s/kernel32//;s/^extra-ghci-libraries:/extra-ghci-libraries: wsock32 user32 shell32 kernel32 msvcrt/' | ghc-pkg update - ghc-pkg describe Win32 | sed 's/kernel32//' | ghc-pkg update - }}} === Using autoconf by mistake === If you used {{{autoconf}}} instead of {{{perl boot}}}, you'll get an error when you run {{{./configure}}}: {{{ ...lots of stuff... creating mk/config.h mk/config.h is unchanged configuring in ghc running /bin/sh ./configure --cache-file=.././config.cache --srcdir=. ./configure: ./configure: No such file or directory configure: error: ./configure failed for ghc }}} === Cannot create configure === {{{autoreconf}}} (which gets run by {{{perl boot}}}) seems to create the file {{{configure}}} read-only. So if you need to run {{{perl boot}}} again (which I sometimes do for safety's sake), you get {{{ /usr/bin/autoconf: cannot create configure: permission denied }}} Solution: delete {{{configure}}} first. === Argument list too long === You may find this towards the end of compiling the base library: {{{ c:\ghc\ghc-6.6.1\bin\ar.exe: creating libHSbase.a xargs: c:/ghc/ghc-6.6.1/bin/ar: Argument list too long make[2]: *** [libHSbase.a] Error 126 make[2]: *** Deleting file `libHSbase.a' Failed making all in base: 1 make[1]: *** [all] Error 1 make[1]: Leaving directory `/cygdrive/c/GHC6.6.1/ghc-6.6.1/libraries' make: *** [stage1] Error 2 }}} Sadly the argument list has a limited length in Windows. This may be fixable somehow (Windows expertise welcomed here), but what we do is to set {{{ SplitObjs = NO }}} in `build.mk`. That stops the splitting-up of object files, and dramatically reduces the number of object files involved. Link times are also improved. (Binary size increases though.) Also, you can arrange for the (huge) list of files to be processed iteratively, rather all at once, and that would probably be a principal solution. `xargs` feeds the file names to the appropriate command (e.g. `ar`). In `$(GHC_TOP)/mk/target.mk` find the place where it is called and add this switch {{{ xargs -n NNN }}} where NNN is the number of arguments processed at a time. It should be small enough to be less than the limit and large enough for the whole thing not to be too slow. Note, that it's not good to edit `target.mk` in general. === Space in TMPDIR === One difficulty that comes up from time to time is running out of space in {{{TMPDIR}}}. (It is impossible for the configuration stuff to compensate for the vagaries of different sysadmin approaches to temp space.) The quickest way around it is {{{setenv TMPDIR /usr/tmp}}} or even {{{setenv TMPDIR .}}} (or the equivalent incantation with your shell of choice). The best way around it is to say {{{ export TMPDIR=