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

Several docker images don't support m1 Mac builds #1224

Closed
4 of 11 tasks
TheFriendlyCoder opened this issue Mar 18, 2023 · 3 comments
Closed
4 of 11 tasks

Several docker images don't support m1 Mac builds #1224

TheFriendlyCoder opened this issue Mar 18, 2023 · 3 comments

Comments

@TheFriendlyCoder
Copy link

Checklist

Describe your issue

If you follow the getting started steps outlined in the docs on an m1 based Mac, you get the following error:

cross run --target aarch64-unknown-linux-gnu
info: downloading component 'rust-src'
info: installing component 'rust-src'
Unable to find image 'ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5' locally
0.2.5: Pulling from cross-rs/aarch64-unknown-linux-gnu
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
See 'docker run --help'.

I believe the root cause is that some of the Docker images used for the cross compilation do not have native aarch64 architecture support. I'm not sure how many of the supported targets are currently broken as I have not exhaustively checked the entire list, but at least the following images appear to be affected:

  • aarch64-unknown-linux-gnu
  • x86_64-pc-windows-gnu

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

aarch64-unknown-linux-gnu, x86_64-pc-windows-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

0.2.5

Example

$ cargo init --bin hello
$ cd hello
$ cross run --target aarch64-unknown-linux-gnu

Additional information / notes

No response

@TheFriendlyCoder
Copy link
Author

NOTE: I did find a workaround to the problem for the time being, which I will describe here in case anyone else hits this problem in the meantime.

Using Docker for Mac, on an m1 / aarch64 CPU, you can manually download a Docker image for an architecture that is supported by both cross and Docker/Rosetta, such as x86_64, which should run properly in emulation mode. For the example provided in my description above, you can do this by running the following Docker command from a terminal:

$ docker pull ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 --platform linux/x86_64

This will force Docker to download an x86_64 CPU architecture image and store it in the local Docker cache, so that subsequent calls to use that same Docker image (ie: by cross) will use the cached version of the image instead of trying to download a new one from Docker/Github.

@TheFriendlyCoder
Copy link
Author

As part of this task, it would be nice if the table of targets included a column that showed the CPU architecture(s) of the host platforms supported by each of the base images, to make it easier to find this information at a glance.

@Emilgardis
Copy link
Member

Emilgardis commented Mar 18, 2023

this is a duplicate of #1214

solution for now is to do CROSS_CONTAINER_OPTS="--platform linux/amd64", ensuring that --platform is passed on first pull. There's a explanation also of why this happened in that issue

As part of this task, it would be nice if the table of targets included a column that showed the CPU architecture(s) of the host platforms supported by each of the base images, to make it easier to find this information at a glance.

The only supported platform is linux/amd64 for now. See #751

@Emilgardis Emilgardis closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants