cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.81k stars 381 forks source link

cargo not found on alpine armv8 / aarch64 #1256

Open Emilgardis opened 1 year ago

Emilgardis commented 1 year ago

Checklist

Describe your issue

using alpine:edge for platform linux/armv8 doesn't seem to mount cargo properly

What target(s) are you cross-compiling for?

aarch64-unknown-linux-musl

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.5 (892fdfa 2023-05-02)

Example

[target."aarch64-unknown-linux-musl"]
image.name = "alpine:edge"
image.toolchain = ["aarch64-unknown-linux-musl"]

gives

cross build --target aarch64-unknown-linux-musl -v           
+ cargo metadata --format-version 1 --filter-platform aarch64-unknown-linux-musl
+ rustc --print sysroot
+ /usr/local/bin/docker
+ /usr/local/bin/docker version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
[cross] warning: using newer rustc `1.69.0 (84c898d65 2023-04-16)` for the target. Current active rustc on the host is `rustc 1.67.0 (fc594f156 2023-01-24)`.
 > Update with `rustup update`
+ rustup toolchain list
+ rustup target list --toolchain stable-aarch64-unknown-linux-musl
+ rustup component list --toolchain stable-aarch64-unknown-linux-musl
+ /usr/local/bin/docker buildx build --platform linux/arm --progress auto --label 'org.cross-rs.for-cross-target=aarch64-unknown-linux-musl' --label 'org.cross-rs.runs-with=aarch64-unknown-linux-musl' --label 'org.cross-rs.workspace_root=/Users/emil/workspace/dev_space/test' --tag localhost/cross-rs/cross-custom-test:aarch64-unknown-linux-musl-6e004-pre-build --build-arg 'CROSS_CMD=apk add --no-cache gcc musl-dev pkgconfig openssl-dev libc-dev git' --build-arg 'CROSS_DEB_ARCH=musl-linux-arm64' --file /Users/emil/workspace/dev_space/test/target/aarch64-unknown-linux-musl/Dockerfile.aarch64-unknown-linux-musl-custom --output 'type=docker' /Users/emil/workspace/dev_space/test
[+] Building 0.7s (6/6) FINISHED                                                                                                                          
 => [internal] load build definition from Dockerfile.aarch64-unknown-linux-musl-custom                                                               0.0s
 => => transferring dockerfile: 212B                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                    0.0s
 => => transferring context: 34B                                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/alpine:edge                                                                                       0.6s
 => [1/2] FROM docker.io/library/alpine:edge@sha256:2d01a16bab53a8405876cec4c27235d47455a7b72b75334c614f2fb0968b3f90                                 0.0s
 => CACHED [2/2] RUN eval "apk add --no-cache gcc musl-dev pkgconfig openssl-dev libc-dev git"                                                       0.0s
 => exporting to image                                                                                                                               0.0s
 => => exporting layers                                                                                                                              0.0s
 => => writing image sha256:5b0488b3dfa13bb5805a5937bcdaac3eb6414064ea6bf68250a30776c0c2528d                                                         0.0s
 => => naming to localhost/cross-rs/cross-custom-test:aarch64-unknown-linux-musl-6e004-pre-build                                                 0.0s
+ /usr/local/bin/docker run --userns host --platform linux/arm -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/Users/emil/.xargo' -e 'CARGO_HOME=/Users/emil/.cargo' -e 'CROSS_RUST_SYSROOT=/Users/emil/.rustup/toolchains/stable-aarch64-unknown-linux-musl' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=emil' -e 'CROSS_RUSTC_MAJOR_VERSION=1' -e 'CROSS_RUSTC_MINOR_VERSION=69' -e 'CROSS_RUSTC_PATCH_VERSION=0' --name cross-stable-aarch64-unknown-linux-musl-6191b-84c898d65-aarch64-unknown-linux-musl-6e004-1683796712577 --rm --user 501:20 -v /Users/emil/.xargo:/Users/emil/.xargo:z -v /Users/emil/.cargo:/Users/emil/.cargo:z -v /Users/emil/.cargo/bin -v /Users/emil/workspace/dev_space/test:/Users/emil/workspace/dev_space/test:z -v /Users/emil/.rustup/toolchains/stable-aarch64-unknown-linux-musl:/Users/emil/.rustup/toolchains/stable-aarch64-unknown-linux-musl:z,ro -v /Users/emil/workspace/dev_space/test/target:/target:z -w /Users/emil/workspace/dev_space/test -t localhost/cross-rs/cross-custom-test:aarch64-unknown-linux-musl-6e004-pre-build sh -c 'PATH="$PATH":"/Users/emil/.rustup/toolchains/stable-aarch64-unknown-linux-musl/bin" cargo build --target aarch64-unknown-linux-musl -v'
sh: cargo: not found
+ rustup component list --toolchain stable-aarch64-unknown-linux-musl

Additional information / notes

running $RUSTUP/toolchains/<toolchain>/bin/cargo doesn't work either, so probably not a path issue

/Users/emil/workspace/dev_space/test $ /Users/emil/.rustup/toolchains/stable-aarch64-unknown-linux-musl/bin/cargo 
sh: /Users/emil/.rustup/toolchains/stable-aarch64-unknown-linux-musl/bin/cargo: not found
SamTV12345 commented 1 year ago

Same with the musl Dockerfiles in docker directory.

After performing:

cargo build-docker-image aarch64-unknown-linux-musl --platform aarch64-unknown-linux-gnu --repository <your-repository>
cargo build-docker-image armv7-unknown-linux-musleabihf --platform aarch64-unknown-linux-gnu --repository <your-repository>
cargo build-docker-image x86_64-unknown-linux-musl --platform aarch64-unknown-linux-gnu --repository <your-repository>

I get the message: