Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling a rust app with cargo on arm64 will returns exit code: 137 #122

Open
pexcn opened this issue Dec 17, 2022 · 6 comments
Open

Compiling a rust app with cargo on arm64 will returns exit code: 137 #122

pexcn opened this issue Dec 17, 2022 · 6 comments

Comments

@pexcn
Copy link

pexcn commented Dec 17, 2022

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: #109 (comment)

@crazy-max
Copy link
Collaborator

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

@crazy-max
Copy link
Collaborator

crazy-max commented Dec 17, 2022

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

@pexcn
Copy link
Author

pexcn commented Dec 17, 2022

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.

@Aeron
Copy link

Aeron commented Dec 20, 2022

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.

@pexcn
Copy link
Author

pexcn commented Dec 21, 2022

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?

@pexcn
Copy link
Author

pexcn commented Mar 19, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants