make-help icon indicating copy to clipboard operation
make-help copied to clipboard

Apple Silicon support

Open muuvmuuv opened this issue 4 years ago • 7 comments
trafficstars

Using it on my M1 prints:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

muuvmuuv avatar Mar 30 '21 11:03 muuvmuuv

Hi!

I'm understand your problem, but for now I'm now sure how to fix it. Based on https://github.com/crystal-lang/crystal/issues/10066 and https://github.com/crystal-lang/crystal/issues/10237 Crystal has some kind of ARM support, but based on 1.0 release notes it is still not officially yet. I'm also do not see any ARM builds at Crystal Docker Hub. I'm also didn't have any experience with Docker multi-platform building, I'm not sure will it work on my Docker Desktop for Windows or not. And I do not have Mac on ARM to build on this platform directly.

You can try to clone the repo and build the image from Dockerfile by yourself. There is unofficial Crystal Docker images for ARM - you can try to pick any of them and paste into FROM clause in the Dockerfile. If it'll help you, please say.

I'll try to investigate how to use BuildX. If it'll be possible, I'll make multi-platform docker image based on this unofficial Crystal build.

Xanders avatar Mar 30 '21 12:03 Xanders

It isn't that critical, so we can just wait for the official support.

muuvmuuv avatar Mar 31 '21 09:03 muuvmuuv

Ok, great!

Xanders avatar Mar 31 '21 09:03 Xanders

I tried to build this tool with unofficial Crystal image provided above, but there is an error can't find file 'prelude' which I don't know how to fix for now. It looks like there is only compiler itself in the image, not stdlib, so it is not possible to do anything right now. I believe we should wait for official support. :(

Xanders avatar Apr 21 '21 12:04 Xanders

Thanks for informing me. Good then, we will wait for the official support, until then Rosetta 2 will take care of it ^^

muuvmuuv avatar Apr 21 '21 15:04 muuvmuuv

Gah. Just ran into this as well, but on Debian arm64, where there is no emulation layer for x86 😭 Not sure if I have a path through for this one.

Update: Worked out how to get emulation. So unblocked! Would still be lovely though to have native arm64 image.

markmandel avatar Sep 28 '22 19:09 markmandel

I was digging into this a little bit, since I'm doing a tonne of cross platform container and compilation work at the moment, but I'm not familiar with Crystal.

I realised two things:

(1) You don't need an ARM machine to cross compile crystal: https://crystal-lang.org/reference/1.5/syntax_and_semantics/cross-compilation.html

But what took me a moment to realise that you do need to link the generated files from cross compilation with cc after the fact!

(2) Which lead me to stumble on this article: https://blog.cervoi.se/build-crystal-docker-images-for-arm/

Which had some great guides on how to build various Crystal binaries on different platforms with Docker buildx and emulation.

This ended up being a bit more complicated than I expected, just because of my relative lack of experience with Crystal, so I'm going to drop this for now -- but figured I'd share my findings in case I return or anyone else wants to pick this up.

markmandel avatar Oct 05 '22 23:10 markmandel