文档和链接

文档和链接

因此我想升级 Fedora 22 预装的“GHC 7.8.4-45”(由Fedora Haskell 特别兴趣小组)升级至 GHC 7.10.2(最新版本)。

如何轻松做到这一点?

答案1

文档和链接

起始信息来源是haskell.org

可以通过以下方式安装:

此外:

所以...

我们将ghc使用Haskell 平台安裝程式。

修复一些库

我们必须使用预编译的最新Cabal封装工具 而不是系统Cabal。不幸的是,它只有 32 位版本。

您可能想要卸载现有的Cabal(我们稍后会将其设置PATH为新的Cabal,因此这不是绝对必要的)

# as root
dnf erase cabal-install cabal-install-static ghc-Cabal-devel

在 64 位系统上,我们需要 32 位版本的库来实现新的功能Cabal

# as root
dnf install glibc.i686 zlib.i686 gmp-devel.i686 gmp.i686

为了编译ghc,我们需要 64 位gmp-devel

# as root
dnf install gmp-devel.x86_64

使用以下命令检查 32 位和 64 位是否均已安装:

rpm --query gmp-devel
> gmp-devel-6.0.0-9.fc22.i686
> gmp-devel-6.0.0-9.fc22.x86_64

我们稍后会下载 CentOS 的预编译版本,它会在某个时候ghc进行查找,因此我们需要一个符号链接:libgmp.3

# as root
cd /usr/lib64
ln -s libgmp.so.10.2.0 libgmp.so.3

安装其他软件包

将会有人抱怨缺少 Z 库和 3D 库。所以:

# as root
dnf install zlib-devel
dnf install freeglut freeglut-devel

有可能:

# as root
dnf install ncurses-devel libffi-devel

“libffi”(外部函数接口)看起来很有趣。

无论如何,你需要make(GNU make):

# as root
dnf install make

添加将运行构建过程的特殊用户

我们将以用户的角度构建builder,而不是以以下的角度构建root

# as root
useradd builder

添加ghcFedora 22 软件包中的旧版本

我们需要ghcFedora 22 附带的 来启动编译。根据Platform 自述ghc必须> 7.4(Fedora 有ghc7.8.4)。

# as root
dnf install ghc

这将引入 55 个包,包括libffi-devel尚未存在的包。

您还需要:

# as root
dnf install ghc-split

否则你会得到错误:

> cabal: At least the following dependencies are missing:
> hastache >=0.6.0, shake >=0.14, split -any, text -any

添加新的预编译Cabal

如上所述,您必须安装预编译版本Cabal来替换 Fedora 22 附带的旧版本。

确实使用CabalFedora自带的1.18.1.0最终会报错:

> 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.

成为用户builder

su - builder

获取最新Cabal信息Cabal 下载页面,但如上所述,目前仅有 32 位版本。

# 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

我们需要一个预先打包的“bindist”(预编译ghc)用于编译,它作为参数传递给 Haskell Platform

最新的可以找到这里- 选择“CentOS”。

# as builder
cd
wget http://downloads.haskell.org/~ghc/7.10.2/ghc-7.10.2-x86_64-unknown-linux-centos66.tar.bz2

无需解压缩或解压 131.82 MiB 的 tarball。

Platform

检查自述

如果您要为类似 Posix 的系统(Linux 或 BSD)构建,则可以添加命令行选项 --prefix 来指定在目标系统上将放置构建内容树的位置。默认为“/usr/local/haskell”。构建将包括名为“ghc-xyz-arch”的另一个目录,所有内容都将安装在那里。

...所以我们不调整任何东西因为/usr/local/haskell声音正是我们想要的。

并且:

在构建调用中添加 -j [n] 将允许同时在多个核心上构建。

已经尝试过了,但是好像没有效果...

得到Platform

从 github克隆Platform到“.sav”目录。这是必需的,因为编译可能会失败,在这种情况下,你只想放弃已完成的工作并重新开始:

# as builder
cd
git clone https://github.com/haskell/haskell-platform
mv haskell-platform haskell-platform.sav

修复用户的 PATH builder!在某些时候,必须使用最新的编译版本,ghc而不是系统自带的版本!

作为用户builder,编辑您的~/.bash_profile并添加:

PATH=$HOME/cabalbin/:$HOME/haskell-platform/build/ghc-bindist/local/bin/:$PATH:$HOME/.local/bin:$HOME/bin

由于先前设置$HOME/cabalbin包含新鲜的Cabal并且在某些时候$HOME/haskell-platform/build/ghc-bindist/local/bin/将包含最新的ghc

注销/登录以使用新的 PATH。

建造

现在开始使用

# 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

这次构建实际上应该会成功,但在运行速度不慢的机器上可能需要大约 20 分钟。然后你会看到:

> 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)

安装

按照上述步骤进行

# 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

符号链接将被安装到/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

原则上,我们可以摆脱现有的软件包ghc(下面的命令只有在您给出时才-y有效dnf erase

rpm --query --all | grep -e '^ghc-' | xargs dnf erase

运行测试套件

运行测试套件是一个好主意。

确实,我目前遇到了一些错误......

这些将进入GHC Trac 主页

看 ”运行测试“请访问 haskell.org 获取通用说明。

要运行测试,必须从以下位置安装测试套件源这一页在构建创建的源树“之上”:

# 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

您可能需要安装其他 cabal 软件包来运行某些测试。有些可能已经安装。运行:

# 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以获取包信息。包配置请转到~/.ghc/x86_64-linux-7.10.2/package.conf.d/,包内容请转到~/.cabal/lib/x86_64-linux-ghc-7.10.2/$PACKAGE

然后开始测试. 我们将捕获输出到~/test_output.txt

# as builder
cd
cd ./haskell-platform/build/ghc-bindist/ghc-7.10.2
make test 2>&1 | tee ~/test_output.txt

一段时间后,您将获得输出:

> 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)

相关内容