Skip to content

Building on Arm M4 Pro uses x86_64 toolchain binaries within docker (slow builds) #1741

@vlovich

Description

@vlovich

Checklist

Describe your issue

I'm trying to compile for raspberry pi on MacOS (via colima). This may be the same as #1716 but I'm not sure.

I had a problem where the docker image wouldn't run

Details ``` % cross build [+] Building 3.3s (2/2) FINISHED docker:colima => [internal] load build definition from Dockerfile.aarch64-unknown-linux-gnu-custom 0.0s => => transferring dockerfile: 248B 0.0s => ERROR [internal] load metadata for ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 3.2s ------ > [internal] load metadata for ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5: ------ Dockerfile.aarch64-unknown-linux-gnu-custom:2 -------------------- 1 | 2 | >>> FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 3 | ARG CROSS_DEB_ARCH= 4 | ARG CROSS_CMD -------------------- ERROR: failed to build: failed to solve: ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5: failed to resolve source metadata for ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5: no match for platform in manifest: not found Error: 0: could not run container 1: when building custom image 2: when pre-building 3: `docker build --label 'org.cross-rs.for-cross-target=aarch64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=/Users/me/projects/my-workspace' --tag cross-custom-device:aarch64-unknown-linux-gnu-ac370-pre-build --build-arg 'CROSS_CMD=apt-get update apt-get --assume-yes install capnproto' --build-arg 'CROSS_DEB_ARCH=arm64' --file /Users/me/projects/my-workspace/my-crate/target/aarch64-unknown-linux-gnu/Dockerfile.aarch64-unknown-linux-gnu-custom /Users/me/my-workspace/sky-ai/my-crate` failed with exit status: 1 ```
until I used the main branch as recommended in that issue.

However, when I reinstalled from main, while the build is running, it's still building very slowly because it's using the x86-64 rust toolchain which requires emulation:

docker exec -it f47a9ae7688d bash
I have no name!@f47a9ae7688d:/Users/me/projects/my-workspace/my-crate$ ps aux | grep cargo 
502            1  0.0  0.3 147132  7720 pts/0    Ssl+ 22:09   0:00 /usr/bin/qemu-x86_64 /usr/bin/sh sh -c PATH="$PATH":"/Users/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" cargo build --target aarch64-unknown-linux-gnu
502            8  0.7  6.9 534800 139784 pts/0   Sl+  22:09   0:01 /usr/bin/qemu-x86_64 /Users/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo cargo build --target aarch64-unknown-linux-gnu
502          261  0.0  5.7 534800 115660 pts/0   Sl+  22:10   0:00 /usr/bin/qemu-x86_64 /Users/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo cargo build --target aarch64-unknown-linux-gnu
502         1030 71.0  9.6 629824 192684 pts/0   Sl+  22:12   0:00 /usr/bin/qemu-x86_64 /Users/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc rustc --crate-name errno --edition=2018 /Users/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/errno-0.3.14/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=250 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --warn=unexpected_cfgs --check-cfg cfg(target_os, values("cygwin")) --cfg feature="default" --cfg feature="std" --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values("default", "std")) -C metadata=5d57d3d22ae1413d -C extra-filename=-6d579b2674dba8ef --out-dir /target/aarch64-unknown-linux-gnu/debug/deps --target aarch64-unknown-linux-gnu -C linker=aarch64-linux-gnu-gcc -L dependency=/target/aarch64-unknown-linux-gnu/debug/deps -L dependency=/target/debug/deps --extern libc=/target/aarch64-unknown-linux-gnu/debug/deps/liblibc-e2d118a350217de9.rmeta --cap-lints allow
502         1038  0.0  0.4 147932  8236 pts/1    Sl+  22:12   0:00 /usr/bin/qemu-x86_64 /usr/bin/grep grep cargo
I have no name!@f47a9ae7688d:/Users/me/projects/my-workspace/my-crate$ file  /Users/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
/Users/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped

Here's my Cross.toml

[build]
default-target = "aarch64-unknown-linux-gnu"

I couldn't find an issue matching this exactly.

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

aarch64-unknown-linux-gnu

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

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5 (426e811 2026-01-03)

Example

No response

Additional information / notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions