binfmt
binfmt copied to clipboard
Compiling a rust app with cargo on arm64 will returns `exit code: 137`
This problem only occurs on the arm64 platform, everything works fine under amd64.
Log output: https://github.com/pexcn/docker-images/actions/runs/3391825550/jobs/5637357880 Relate issue: https://github.com/tonistiigi/binfmt/issues/109#issuecomment-1356116504
- https://github.com/pexcn/docker-images/blob/1c19d6c4556c1e73f3ece408f0fb4533b9228d45/net/shadowsocks-rust/Dockerfile#L8-L23C20
FROM rust:alpine AS builder-ss
RUN apk update \
&& apk add --no-cache --virtual .build-deps musl-dev git
ARG SS_VERSION=v1.15.0-alpha.9
RUN git clone https://github.com/shadowsocks/shadowsocks-rust.git --branch $SS_VERSION \
&& cd shadowsocks-rust \
&& case "$(apk --print-arch)" in \
aarch64) build_features="local-redir local-tun aead-cipher-2022-extra armv8 neon";; \
*) build_features="local-redir local-tun aead-cipher-2022-extra";; \
esac \
&& cargo build --release --features "$build_features" \
&& install target/release/ssservice target/release/ssserver target/release/sslocal target/release/ssmanager target/release/ssurl /usr/local/bin/ \
&& cd - \
&& rm -r /shadowsocks-rust
> [linux/arm64 builder-ss 3/4] RUN git clone https://github.com/shadowsocks/shadowsocks-rust.git --branch v1.15.0-alpha.9 && cd shadowsocks-rust && case "$(apk --print-arch)" in aarch64) build_features="local-redir local-tun aead-cipher-2022-extra armv8 neon";; *) build_features="local-redir local-tun aead-cipher-2022-extra";; esac && cargo build --release --features "$build_features" && install target/release/ssservice target/release/ssserver target/release/sslocal target/release/ssmanager target/release/ssurl /usr/local/bin/ && cd - && rm -r /shadowsocks-rust:
#31 17.49 git switch -c <new-branch-name>
#31 17.49
#31 17.49 Or undo this operation with:
#31 17.49
#31 17.49 git switch -
#31 17.49
#31 17.49 Turn off this advice by setting config variable advice.detachedHead to false
#31 17.49
#31 30.27 Updating crates.io index
#31 331.9 Killed
Not directly linked to this issue but have you tried using cross-compilation to avoid emulation? See https://github.com/crazy-max/rust-docker-cross/blob/2f6d5f93dedbf1b9c8d65a172df47796281841da/Dockerfile#L43
More info: https://github.com/tonistiigi/xx/#rust
Not directly linked to this issue but have you tried using cross-compilation to avoid emulation?
No😅, but I was compile this dockerfile on Raspberry Pi 4B via docker build -t shadowsocks-rust .
, it build successfully.
The following two steps helped me:
- Switch back to
tonistiigi/binfmt:qemu-v6.2.0
for the QEMU action; - Add
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
into your Dockerfile. It forces Rust to use external Git instead of the internal libgit wrapper because it sucks memory.
It works as a combo. By itself, those two didn’t yield results.
I tried compiling again yesterday, unbelievable it works: https://github.com/pexcn/docker-images/actions/runs/3741460531 Maybe it's a issue with github actions itself?
About 3 weeks ago, this error appeared again. It seems to be related to this PR?
Before this PR: https://github.com/pexcn/docker-images/actions/runs/4231301961/jobs/7349655537 After this PR: https://github.com/pexcn/docker-images/actions/runs/4243164744/jobs/7375560279
It only seems to affect rust builds.