So I want to upgrade "GHC 7.8.4-45" that comes prepackaged with Fedora 22 (courtesy of the Fedora Haskell SIG) to GHC 7.10.2 (the latest).
How to do that easily?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Start-off info source is at haskell.org
One can install by:
We shall build the Glasgow Haskell Compiler
ghc using the Haskell-Platform installer.
We will have to use the precompiled, latest
Cabal package tool instead of the system
Cabal. Unfortunately it comes in 32-bit only.
You may want to uninstall an existing
Cabal (we will set the
PATH to the new
Cabal later, so this is not strictly necessary)
# as root dnf erase cabal-install cabal-install-static ghc-Cabal-devel
On 64-bit system, we need 32-bit versions of libraries for the new
# as root dnf install glibc.i686 zlib.i686 gmp-devel.i686 gmp.i686
ghc, we need 64-bit
# as root dnf install gmp-devel.x86_64
Check that both 32-bit and 64-bit are installed using:
rpm --query gmp-devel > gmp-devel-6.0.0-9.fc22.i686 > gmp-devel-6.0.0-9.fc22.x86_64
ghc for CentOS, which we will download later, will be looking for
libgmp.3 at some point, so we need a symlink:
# as root cd /usr/lib64 ln -s libgmp.so.10.2.0 libgmp.so.3
There will be complaints about missing Z libraries and 3D libraries. So:
# as root dnf install zlib-devel dnf install freeglut freeglut-devel
# as root dnf install ncurses-devel libffi-devel
"libffi" (foreign function interface) seems interesting.
Anyway, you need
make (GNU make):
# as root dnf install make
We will build as the user
builder, not as
# as root useradd builder
ghcwhich comes as Fedora 22 package
We need the
ghc that comes with Fedora 22 to kickstart compilation. According to the
ghc has to be > 7.4 (Fedora has
# as root dnf install ghc
This pulls in 55 packages, including
libffi-devel if it wasn't there yet.
You also need:
# as root dnf install ghc-split
Or you will get the error:
> cabal: At least the following dependencies are missing: > hastache >=0.6.0, shake >=0.14, split -any, text -any
As mentioned. you have to install the precompiled
Cabal to replace the older one which comes with Fedora 22.
Cabal 188.8.131.52 which comes with Fedora will eventually give an error:
> ghc: ghc no longer supports single-file style package databases > (dist/package.conf.inplace) use 'ghc-pkg init' to create the > database with the correct format.
su - builder
Get the new
Cabal from the cabal download page, but as said above it currently comes only in 32-bit.
# as builder cd wget https://www.haskell.org/cabal/release/cabal-install-184.108.40.206/cabal-220.127.116.11-i386-unknown-linux.tar.gz # 3.84 MiB; just contains the "cabal" binary tar xzf cabal-18.104.22.168-i386-unknown-linux.tar.gz mkdir cabalbin mv cabal cabalbin/
We need a prepackaged "bindist" (precompiled
ghc) for compilation, which is passed as argument to the Haskell
The latest one can be found here - take the "CentOS" one.
# as builder cd wget http://downloads.haskell.org/~ghc/7.10.2/ghc-7.10.2-x86_64-unknown-linux-centos66.tar.bz2
No need to uncompress or untar the 131.82 MiB tarball.
Checking the README:
If you are building for a Posix like system (Linux, or BSD), then you can add the command line option --prefix to specify where, on the target system the tree of built things will be placed. It defaults to "/usr/local/haskell". The build will include another directory under that named "ghc-x.y.z-arch" and everything will be installed under there.
... so we don't tune anything because
/usr/local/haskell sounds exactly like what we want.
Adding -j [n] to the build invocation will enable building on multiple cores at once.
It tried this but it doesn't seem to work...
Platform from github into a ".sav" directory. This is needed because compilation may fail, and in that case you just want to blow away what was done and start over:
# as builder cd git clone https://github.com/haskell/haskell-platform mv haskell-platform haskell-platform.sav
Fix the PATH of user
builder! At some point, the latest, compiled
ghc has to be used instead of the one with comes with the system!
builder, edit your
~/.bash_profile and add:
As set up earlier
$HOME/cabalbin contains a fresh
Cabal and at some time
$HOME/haskell-platform/build/ghc-bindist/local/bin/ will contain the latest
Logout/Login to use the new PATH.
Now start building using
# as builder cd /bin/rm -rf haskell-platform cp -a haskell-platform.sav haskell-platform cd haskell-platform ./platform.sh ../ghc-7.10.2-x86_64-unknown-linux-centos66.tar.bz2
This build should actually succeed but may take about 20 minutes on a not-slow machine. Then you see:
> To install this build: > 1) copy build/product/haskell-platform-7.10.2-a-unknown-posix-x86_64.tar.gz to the target machine > 2) untar it (creates files in the working directory) > 3) as root, run the script ./install-haskell-platform.sh > Build completed in 22:54m > # tar (for build/product/hp-usr-local.tar.gz) > # cp (for build/product/haskell-platform-7.10.2-a-unknown-posix-x86_64.tar.gz) > # tar (for build/product/haskell-platform-7.10.2-a-unknown-posix-x86_64.tar.gz)
Proceed as described above
# as root cp ~builder/haskell-platform/build/product/haskell-platform-7.10.2-a-unknown-posix-x86_64.tar.gz ~ cd tar xzf haskell-platform-7.10.2-a-unknown-posix-x86_64.tar.gz ./install-haskell-platform.sh
> Unpacking ./hp-usr-local.tar.gz to /... > Running /usr/local/haskell/ghc-7.10.2-x86_64/bin/activate-hs ... > > Haskell set to: > GHC /usr/local/haskell/ghc-7.10.2-x86_64 > Haddocks file:///usr/local/haskell/ghc-7.10.2-x86_64/doc/frames.html > Other doc file:///usr/local/haskell/ghc-7.10.2-x86_64/share/doc/ghc/html/index.html > > Symlinks for command line tools (ghc, cabal, etc..) added to: > /usr/local/bin
Symlinks will have been installed to
> activate-hs -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/activate-hs > alex -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/alex > cabal -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/cabal > ghc -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/ghc > ghc-7.10.2 -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/ghc-7.10.2 > ghci -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/ghci > ghci-7.10.2 -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/ghci-7.10.2 > ghc-pkg -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/ghc-pkg > ghc-pkg-7.10.2 -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/ghc-pkg-7.10.2 > haddock -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/haddock > haddock-ghc-7.10.2 -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/haddock-ghc-7.10.2 > happy -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/happy > hp2ps -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/hp2ps > hpc -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/hpc > hsc2hs -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/hsc2hs > HsColour -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/HsColour > runghc -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/runghc > runghc-7.10.2 -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/runghc-7.10.2 > runhaskell -> /usr/local/haskell/ghc-7.10.2-x86_64/bin/runhaskell
In principle, we can get rid of the existing packages of
ghc (the command below only works if you give
-y to the
rpm --query --all | grep -e '^ghc-' | xargs dnf erase
It is a good idea to run the test suite.
Indeed, I am hitting some errors currently...
These will go into GHC Trac home
See "running tests" at haskell.org for generic instructions.
To run tests, one has to install the test suite source from this page "on top of" the source tree created by the build:
# as builder cd # the '..' below is not a typo! cd ./haskell-platform/build/ghc-bindist/ghc-7.10.2/.. wget http://downloads.haskell.org/~ghc/7.10.2/ghc-7.10.2-testsuite.tar.bz2 bunzip2 ghc-7.10.2-testsuite.tar.bz2 tar xf ghc-7.10.2-testsuite.tar
You may want to install additional cabal packages to run certain tests. Some may already have been installed. Run:
# as builder ## To install hmatrix you will probably have to perform, as root: ## dnf install blas-devel lapack-devel # Linear systems, matrix decompositions, and other numerical computations cabal install hmatrix # Monad classes using functional dependencies cabal install mtl # This package provides a library for parallel programming. cabal install parallel # Parsec is designed as an industrial-strength parser library. cabal install parsec # various primitive memory-related operations cabal install primitive # library for random testing of program properties. cabal install QuickCheck # provides a basic random number generation library cabal install random # one module layer over regex-posix to replace Text.Regex cabal install regex-compat # the generics system described in the "Scrap Your Boilerplate" papers cabal install syb # A UTF8 layer for Strings cabal install utf8-string # An efficient implementation of Int-indexed arrays cabal install vector
cabal info $PACKAGE to get package info. The package configuration goes to
~/.ghc/x86_64-linux-7.10.2/package.conf.d/, the package contents go to
Then start tests. We will capture the output to
# as builder cd cd ./haskell-platform/build/ghc-bindist/ghc-7.10.2 make test 2>&1 | tee ~/test_output.txt
After some time, you get output:
> Unexpected results from: > TEST="T9203 T9961 parsing001 T9675 T6048" > > OVERALL SUMMARY for test run started at Mon Oct 26 17:52:52 2015 CET > 0:33:17 spent to go through > 4142 total tests, which gave rise to > 15728 test cases, of which > 11883 were skipped > > 45 had missing libraries > 3754 expected passes > 41 expected failures > > 0 caused framework failures > 0 unexpected passes > 0 unexpected failures > 5 unexpected stat failures > > Unexpected stat failures: > perf/compiler T6048 [stat not good enough] (optasm) > perf/compiler T9675 [stat not good enough] (optasm) > perf/compiler T9961 [stat not good enough] (normal) > perf/compiler parsing001 [stat too good] (normal) > perf/should_run T9203 [stat too good] (normal)