编译环境
- OS: Kylin Linux Advanced Server V10 (Tercel)
- CPU 架构: loongarch64
- 平台: 龙芯
- go 版本: go version go1.19 linux/loong64
- 编译的 Docker 版本: v19.03.15
安装 golang 环境
下载 golang
1
wget http://ftp.loongnix.cn/toolchain/golang/go-1.19/go1.19.linux-loong64.tar.gz
安装 golang
1
2
3
4
5
6
7
8tar xf go1.19.linux-loong64.tar.gz -C /usr/local/
cat > /etc/profile.d/golang.sh <<EOF
#!/bin/bash
GO_HOME=/usr/local/go
PATH=\$PATH:\$GO_HOME/bin
EOF重新加载环境变量,检查 go 版本
1
2
3$ source /etc/profile.d/golang.sh
$ go version
go version go1.19 linux/loong64
编译 Docker
下载 docker 源码
1
git clone -b v19.03.15 https://github.com/moby/moby.git
安装依赖
1
2
3
4
5
6yum install -y btrfs-progs-devel \
libcap-devel \
libnet-devel \
libnl3-devel \
boost-devel \
boost-thread \备注: 先 checkout 到指定的版本后再进行修改,然后 install 脚本中奖 checkout 动作注释掉
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35# github.com/containerd/containerd/vendor/golang.org/x/sys/unix
git checkout -q ea765aba0d05254012b0b9e595e995c09186427f
/bin/cp -r ~/go/pkg/mod/ vendor/golang.org/x/sys/unix
# github.com/opencontainers/runc/vendor/golang.org/x/sys/unix
git checkout -q dc9208a3303feef5b3839f4323d9beb36df0a9dd
/bin/cp -r ~/go/pkg/mod/golang.org/x/sys@v0.1.0/unix vendor/golang.org/x/sys/
# github.com/opencontainers/runc/libcontainer
修改 `libcontainer/system/syscall_linux_64.go` 文件,第二行注释后面追加 `loong64`
# github.com/docker/cli/vendor/golang.org/x/sys/unix
cd docker-ce && git checkout -q v19.03.15
/bin/cp -r ~/go/pkg/mod/golang.org/x/sys@v0.1.0/unix components/cli/vendor/golang.org/x/sys/
# github.com/containerd/containerd/vendor/go.etcd.io/bbolt
创建 vendor/go.etcd.io/bbolt/bolt_loong64.go 文件, 文件内容如下
// +build loong64
package bbolt
// maxMapSize represents the largest mmap size supported by Bolt.
const maxMapSize = 0xFFFFFFFFFFFF // 256TB
// maxAllocSize is the size used when creating array pointers.
const maxAllocSize = 0x7FFFFFFF
# github.com/bugsnag/panicwrap
#42 3.372 /tmp/tmp.t42cimMtiC/src/github.com/docker/distribution/Godeps/_workspace/src/github.com/bugsnag/panicwrap/dup2.go:10:17: undefined: syscall.Dup2
修改 github/distribution/Godeps/_workspace/src/github.com/bugsnag/panicwrap/ 目录下的 dup2.go 以及 dup3.go 文件
# github.com/go-swagger/go-swagger/vendor/golang.org/x/sys/unix
git checkout -q 5793aa66d4b4112c2602c716516e24710e4adbb5
/bin/cp -r ~/go/pkg/mod/golang.org/x/sys@v0.1.0/unix vendor/golang.org/x/sys/