构建 haskell aarch64 编译环境

本文介绍如何在服务器(Ubuntu 18.04)上构建 haskell aarch64 编译环境。

Aarch64 运行环境

安装 qemu-user-static

apt install qemu-user-static

下载 alpine aarch64 基础文件系统并解压

wget http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/aarch64/alpine-minirootfs-3.9.0-aarch64.tar.gz
mkdir rootfs
cd rootfs 
tar xvf ../alpine-minirootfs-3.9.0-aarch64.tar.gz

挂在文件系统

mount -t devtmpfs devtmpfs dev
mount -t devpts devpts dev/pts
mount -t sysfs sysfs sys
mount -t tmpfs tmpfs tmp
mount -t proc proc proc

更改源

vim etc/apk/repositories

使用 USTC 的源

http://mirrors.ustc.edu.cn/alpine/v3.9/main
http://mirrors.ustc.edu.cn/alpine/v3.9/community
http://mirrors.ustc.edu.cn/alpine/edge/main
http://mirrors.ustc.edu.cn/alpine/edge/community

复制 DNS 配置

cp /etc/resolv.conf etc

复制 qemu-aarch64-static

cp /usr/bin/qemu-aarch64-static usr/bin

进入 aarch64 系统

chroot . /bin/sh

haskell 编译环境

安装依赖包

apk update
apk add make libc-dev pcre-dev libc6-compat numactl-dev ncurses5-libs gmp-dev llvm zlib-dev gcc perl g++
ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5

安装 ghc

cd
wget https://downloads.haskell.org/~ghc/latest/ghc-8.6.2-aarch64-deb8-linux.tar.xz
tar xvf ghc-8.6.2-aarch64-deb8-linux.tar.xz
cd ghc-8.6.2
./configure
make install

安装 stack

wget -qO- https://get.haskellstack.org/ | sh

编译应用

安装 git

apk add git

编译 func

cd
git clone https://github.com/Lupino/func.git
cd func 
sed 's/^resolver.*/resolver: nightly-2018-12-17/' stack.yaml -i
cat >> stack.yaml <<EOF
package-indices:
  - name: USTC
    download-prefix: https://mirrors.ustc.edu.cn/hackage/package/
    http: https://mirrors.ustc.edu.cn/hackage/01-index.tar.gz
system-ghc: true
local-bin-path: bin
arch: aarch64
EOF

stack install

结束

恭喜你已经可以服务器上编译 haskell aarch 64 的应用,也可以用同样的方法编译 arm 的应用。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,726评论 0 3
  • Haskell 作为一个冷门语言,并没有一个简单好用傻瓜式的 IDE。所以笔者记录了自己搭建环境的过程,希望对大家...
    0x11901阅读 4,257评论 0 5
  • 这份文档旨在帮助开发者理解 QEMU 构建系统的架构。正如使用 GNU autotools 的项目一样,QEMU ...
    hanpfei阅读 1,929评论 0 0
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,145评论 1 32
  • 世间,有一种感情,可叫人飞蛾扑火,可叫人缠绵一生,可叫人肝肠寸断,可叫人生死相许。 伟大的诗人泰戈尔曾有诗言:世界...
    老栾乱弹阅读 1,582评论 0 5