Comments (8)
Travis で、QEMU を利用して ARM のアーキテクチャの上でテストをしている模様
Linux カーネルには、binfmt_misc
という仕組みがあり、実行バイナリの先頭のバイト列に一致するパターンがあった場合、指定のインタープリタを実行することができる。
Linuxのbinfmt_miscを使ってGoスクリプトを直接実行できるようにする
Docker の multiarch/qemu-user-static:register
イメージを実行することで、ホストマシンの binfmt_misc
に複数のアーキテクチャのバイナリを QEMU
で実行するように修正する。
docker run --rm --privileged multiarch/qemu-user-static:register --reset
これを Travis 上で実行し、ARM の Docker イメージを実行することで ARM アーキテクチャで実行することが可能になる。
Go 言語の ARM 版 Docker イメージは https://hub.docker.com/r/arm64v8/golang/ である。
- https://github.com/multiarch/qemu-user-static
- nix-rust/nix#97
- https://www.tomaz.me/2013/12/02/running-travis-ci-tests-on-arm.html
- https://blog.hypriot.com/post/setup-simple-ci-pipeline-for-arm-images/
- travis-ci/travis-ci#3376
- travis-ci/travis-ci#8869
from bitset.
以下のエラーが発生して Arm 版の Dockerイメージ arm64v8/golang
が実行できない。
docker: no matching manifest for linux/amd64 in the manifest list entries.
docker-library/official-images#3835
この問題に該当する
manifest が適合せずにイメージのプルに失敗している。
from bitset.
Go 言語は qemu の arm に対応していない。
https://www.reddit.com/r/golang/comments/6j08ux/what_the_best_arm_emulator_for_testing_go_binary/
golang/go#13024 (comment)
Yeah, I think we lost the ability to run Go binaries with
qemu-arm long time ago. tcg fatal error also seems to
suggest that it's a qemu bug. (the arm port used to be
developed with qemu-arm, but then as the port is able
to run on real hardwares, we no longer test on qemu-arm.)
from bitset.
以下の手順で arm64
上で Go のテストを実行したが、Little Endian であった。
sudo docker run --rm -it multiarch/debian-debootstrap:arm64-jessie bash
wget --no-check-certificate https://dl.google.com/go/go1.11.2.linux-arm64.tar.gz
tar -xvf go1.11.2.linux-arm64.tar.gz
mv go /usr/local
export GOROOT=/usr/local/go
export GOPATH=/root/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
cd /root
apt-get install -y git
git clone https://github.com/kawasin73/bitset.git
from bitset.
Travis で s390x を動かすことができている。 travis-ci/travis-ci#8869 (comment)
この上で Golang を動かすことを考える。
公式の Golang の s390x 向けのアーカイブ をダウンロード・解凍して go version
を実行するも以下のエラーが発生
$ sudo docker run --rm -it multiarch/debian-debootstrap:s390x-jessie bash
root@3e8ef6ffcd82:~# go test
Illegal instruction (core dumped)
macOS 上でテストコードをコンパイルして、テストバイナリを Docker 上で実行するも同じくエラーが発生した。
# on macOS
GOOS=linux GOARCH=s390x go test -c
sudo docker run --rm -v $(pwd):/root -it multiarch/debian-debootstrap:s390x-jessie bash
# on Docker container
$ ./bitset.test -test.v
Illegal instruction (core dumped)
from bitset.
Go 言語が対応するアーキテクチャのうち Big Endian は以下の通り。
https://github.com/golang/go/wiki/MinimumRequirements#architectures
from bitset.
できた
GOOS=linux GOARCH=ppc64 go test -c -o bitset.test
docker run --rm -v $(pwd):/root multiarch/fedora:25-ppc64 /root/bitset.test -test.v
macOS + vagrant + Ubuntu 環境の Docker では動いた。
しかし、travis では動かなかった。以下のエラーが発生する。
https://travis-ci.com/kawasin73/bitset/jobs/157899588
0.42s$ docker run --rm -v $(pwd):/root multiarch/fedora:25-ppc64 /root/bitset.test -test.v
standard_init_linux.go:185: exec user process caused "no such file or directory"
The command "docker run --rm -v $(pwd):/root multiarch/fedora:25-ppc64 /root/bitset.test -test.v" exited with 1.
from bitset.
multiarch/qemu-user-static リポジトリで公開されている qemu-ppc64-static
をダウンロードして ppc64 のアーキテクチャをエミュレートしてテストを行うことにした。
テストコードのバイナリ(go test -c
で出力できる)を linux/ppc64
のバイナリにクロスコンパイルして実行している。
wget https://github.com/multiarch/qemu-user-static/releases/download/v3.0.0/qemu-ppc64-static
chmod 755 qemu-ppc64-static
GOOS=linux GOARCH=ppc64 go test -c -o bitset.test
./qemu-ppc64-static ./bitset.test -test.v
from bitset.
Related Issues (13)
- v0.1.0 HOT 1
- v0.3.0
- gometalinter:unsafe を使うと警告がでる
- TravisCI の QEMU 利用のリファクタリング HOT 2
- バイトスライスの GC 抑制 HOT 1
- インターフェイスと関数ポインター HOT 2
- バイトオーダーの検出 HOT 1
- バイトオーダーのスワップ HOT 1
- バイト列の自動拡張 HOT 4
- []byte から []uint64 への変換 HOT 1
- v0.2.0 HOT 1
- バイト列の変換とあまりの部分の処理 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitset.