1
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?
1
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?
1
Start-off info source is at haskell.org
One can install by:
dnf install haskell-platform
, which is not what we want as this just means installing the older version).Furthermore:
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 Cabal
:
# as root
dnf install glibc.i686 zlib.i686 gmp-devel.i686 gmp.i686
To compile ghc
, we need 64-bit gmp-devel
:
# 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
The precompiled 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
And maybe:
# 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 root
:
# as root
useradd builder
ghc
which comes as Fedora 22 packageWe need the ghc
that comes with Fedora 22 to kickstart compilation. According to the Platform
README, ghc
has to be > 7.4 (Fedora has ghc
7.8.4).
# 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
Cabal
As mentioned. you have to install the precompiled Cabal
to replace the older one which comes with Fedora 22.
Indeed using Cabal
1.18.1.0 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.
Become user builder
:
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-1.22.0.0/cabal-1.22.0.0-i386-unknown-linux.tar.gz
# 3.84 MiB; just contains the "cabal" binary
tar xzf cabal-1.22.0.0-i386-unknown-linux.tar.gz
mkdir cabalbin
mv cabal cabalbin/
ghc
We need a prepackaged "bindist" (precompiled ghc
) for compilation, which is passed as argument to the Haskell Platform
.
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.
Platform
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.
And also:
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
Clone 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!
As user builder
, edit your ~/.bash_profile
and add:
PATH=$HOME/cabalbin/:$HOME/haskell-platform/build/ghc-bindist/local/bin/:$PATH:$HOME/.local/bin:$HOME/bin
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 ghc
.
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
You see:
> 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 /usr/local/bin/
:
> 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 dnf erase
)
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
Run 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 ~/.cabal/lib/x86_64-linux-ghc-7.10.2/$PACKAGE
.
Then start tests. We will capture the output to ~/test_output.txt
:
# 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)
Accepting my own answer here. This question sure is meeting with indifference... – David Tonhofer – 2015-12-23T21:34:51.740
Fedora 24 is still on GHC 7.8.4 ... more precisely: "F24 is going to ship with haskell-platform-2014.2 (ghc-7.8.4) .... F25 is planned to ship with haskell-platform-7.10.3 (ghc-7.10.3)"
– David Tonhofer – 2016-07-29T10:18:02.203Advantageously, one can get newer versions via the Fedora Haskell SIG page. At the bottom are listed what is called "Haskell coprs" (
– David Tonhofer – 2016-07-29T10:59:43.257copr
seems to be the continuous build system, then?). There is a copr for 7.10.3 built by "petersen". The copr repository is enabled usingdnf copr enable petersen/ghc-7.10.3
, but how do I install this upgraded version?Here is how: 1) Enable "
dnf copr enable petersen/ghc-7.10.3
2) Recursively remove all the packages pulled in for fedora packagehaskell-platform
usingdnf
(instead ofrpm
, which doesn't provide that option): "dnf erase haskell-platform
" 3) Re-add packages that might come in handy later: "dnf install ncurses-c++-libs freeglut-devel
" etc. 4) Just run "dnf install ghc
".dnf
will pull the latest ghc from the repositorypetersen-ghc-7.10.3
and pull any dependencies from the fedora repo (as that one stays enabled), in my casencurses-devel
etc. 5) Win! – David Tonhofer – 2016-07-30T09:13:42.127Fedora 25 comes with GHC 7.10.3 – James Brock – 2017-01-09T06:40:34.753