graal icon indicating copy to clipboard operation
graal copied to clipboard

Support for Apple M1 (`darwin-aarch64`)

Open fniephaus opened this issue 5 years ago • 116 comments
trafficstars

Updated on 2022/03/22:

Apple M1 support for @GraalVM Native Image, libgraal, JavaScript, and Espresso has landed! 🎉🚀 M1 support for Ruby has also landed now.

You can now grab a GraalVM dev build for darwin-aarch64 at: https://github.com/graalvm/graalvm-ce-dev-builds/releases/latest

Please help testing and report bugs!


Original Issue

Describe the solution you'd like. Apple is transitioning to their own chips. GraalVM is already available for Linux+aarch64, we'll need macOS+aarch64/arm64 at some point too.

Describe who do you think will benefit the most. Any future macOS user.

Describe alternatives you've considered. I can confirm that GraalVM CE 20.1.0 for macOS+amd64 runs with Rosetta 2 on a Developer Transition Kit (DTK).

Additional context. Apple documentation on Apple Silicon. You can apply for a DTK here.

Express whether you'd like to help contributing this feature I'm happy to help test GraalVM on a DTK. I've tried (but failed) to compile a LabsJDK for macOS+arm64 as a starting point.

fniephaus avatar Jul 10 '20 13:07 fniephaus

The first step for this is to build a JVMCI JDK on darwin-arm64.

@dougxc told me the plan is to do this as soon as support is added for the darwin-arm64 platform in the JDK: https://bugs.openjdk.java.net/browse/JDK-8253795 / https://github.com/openjdk/jdk/pull/2200

eregon avatar Jan 13 '21 15:01 eregon

Note that macOS 11 isn't part of the issue any more Graal works fine on that.

chrisseaton avatar Apr 09 '21 10:04 chrisseaton

Internal issue: GR-27422

eregon avatar Apr 12 '21 10:04 eregon

FWIW https://github.com/openjdk/jdk/pull/2200 got merged, but that's for JDK 17, planned to be released on 2021/09/14 (https://openjdk.java.net/projects/jdk/17/). GraalVM releases are of course based on a JDK release. It might be backported to older JDKs, but that doesn't seem clear yet. cc @deepj

eregon avatar Apr 12 '21 13:04 eregon

is it possible to build an image from graalvm arm64 for MacBook m1 in order to build native images. Note that I tried to do this to build a native image for Quarkus framework but it didn't work. I used this graalvm https://github.com/graalvm/container/tree/master/community in order to build my image, but eventually after running sam cli to test the lambda function I got this error msg="Init failed" InvokeID= error="fork/exec /var/task/bootstrap: no such file or directory"

mutasemhidmi avatar Apr 15 '21 06:04 mutasemhidmi

I don't think that's possible. You can run native images built for macOS/AMD64 on Apple Silicon via Rosetta 2.

fniephaus avatar Apr 15 '21 07:04 fniephaus

@fniephaus I tried but the build got stuck, and I got a warning that I am using amd64 and not arm64. All the information is here https://github.com/quarkusio/quarkus/issues/16225

mutasemhidmi avatar Apr 15 '21 07:04 mutasemhidmi

Are you sure you used an amd64 GraalVM for macOS to generate the native image? Can you try building it on an Intel-based Mac? Then, copy over the native image and give it a go. If that doesn't work, you may be out of luck as an early adopter of an M1 Mac. I don't think native image support for Apple Silicon has a high priority for the GraalVM team at this point and will probably take weeks if not months to implement.

fniephaus avatar Apr 15 '21 07:04 fniephaus

@fniephaus I think my case is a little different because eventually, I want to build an image that works on Linux(arm64/aarch64) since I want to deploy it on AWS Lambda. Note that I have docker desktop already downloaded, so I want to use this image to build my quarkus application Lambda function. I hope I expressed myself clearly.

mutasemhidmi avatar Apr 15 '21 07:04 mutasemhidmi

Ah ok, so essentially, you want to build native image for Linux/aarch64 on your M1-powered Mac. You should just be able to do this with a Linux/aarch64 Docker container on your M1. Then just copy over the native image.

fniephaus avatar Apr 15 '21 08:04 fniephaus

Is there any concrete plan to support Apple ARM's chip in GraalVM in near future since the support landed in OpenJDK (https://bugs.openjdk.java.net/browse/JDK-8253795)?

deepj avatar May 05 '21 12:05 deepj

Is there any concrete plan to support Apple ARM's chip in GraalVM in near future since the support landed in OpenJDK (https://bugs.openjdk.java.net/browse/JDK-8253795)?

Please see this comment above: https://github.com/oracle/graal/issues/2666#issuecomment-817834239

dougxc avatar May 05 '21 12:05 dougxc

To restate it a bit differently, I think we need to wait the OpenJDK 17 release (2021/09/14, https://github.com/oracle/graal/issues/2666#issuecomment-817834239) to build a JDK with darwin-aarch64 support. Unless darwin-aarch64 support gets backported earlier than that on JDK 8 or 11 (I have no idea).

eregon avatar May 05 '21 12:05 eregon

I tried to build GraalVM on M1, after hard-coded some architecture checks in mx, the first main issue is the absence of some dependency libraries on darwin arm64, and this can't be resolved easily by externals. Is there any plan that Graal team will add those dependencies (before the full support)?

e.g. the first error:

WARNING: No platform-specific definition is available for library ASYNC_PROFILER_1.8.3 for your architecture (arm64)
library ASYNC_PROFILER_1.8.3:
Library without "path" attribute must have a non-empty "urls" list attribute or "maven" attribute

oraluben avatar Jul 15 '21 11:07 oraluben

OpenJDK 17 has been released for a while, with full support for macos/arm64. Any updates on GraalVM?

kammoh avatar Oct 04 '21 02:10 kammoh

Now JDK 17 is released and has darwin-aarch64 support. The next issue is that Apple only provides mac minis with 16GB ram, and that's basically not enough to do proper CI. And without proper CI it's not really feasible to do development and testing for this architecture.

eregon avatar Oct 04 '21 10:10 eregon

Is this required in order to build a native image to deploy on AWS Lambda?

mutasemhidmi avatar Oct 06 '21 19:10 mutasemhidmi

@mutasemhidmi This is about darwin-aarch64, i.e., aarch64 on macOS. linux-aarch64 is already supported: https://www.graalvm.org/downloads/

eregon avatar Oct 06 '21 19:10 eregon

Yeah but I mean to build it on a mac M1 in order to deploy it on Lambda. The same way it's done now in Windows laptops.

mutasemhidmi avatar Oct 06 '21 20:10 mutasemhidmi

As we get sufficient hardware in our CI system to test and develop on darwin-aarch64, this will become a priority. Any help from the GraalVM community before then would of course be very welcome.

dougxc avatar Oct 07 '21 09:10 dougxc

Just wanted to suggest prioritizing it as Apple has started selling Macbook Pros with their silicon.

edit: I was not aware the 2020 13" M1 was also a Pro 😅 still, the new 14"/16" machines are stronger (up to 64gb RAM etc.)

kubukoz avatar Oct 27 '21 21:10 kubukoz

Hope to see arm-based GraalVM on mac..

gtn1024 avatar Nov 09 '21 10:11 gtn1024

Recently started building on Apple silicon and will get help if arm64 is supported. Please advise if any traction. All new Macs are now with Apple silicon.

doogle-oss avatar Nov 24 '21 03:11 doogle-oss

Is there a timeline for this?

mutasemhidmi avatar Nov 24 '21 17:11 mutasemhidmi

Nothing that we can firmly commit to but I would expect something in the first quarter of 2022.

dougxc avatar Nov 24 '21 21:11 dougxc

Is there anything users with apple silicon chips can do to help here? I.e. can we help out with the testing or whatever is required?

mbjarland avatar Nov 29 '21 21:11 mbjarland

Is there anything users with apple silicon chips can do to help here? I.e. can we help out with the testing or whatever is required?

Yes!

The steps to try are:

  • Clone https://github.com/graalvm/labs-openjdk-17 and build it using the steps in the README.md.
  • Set JAVA_HOME to the result of that build and then run mx --env ce build in the vm/ directory of the graal repo.

dougxc avatar Nov 29 '21 22:11 dougxc

@dougxc First issue from the labs-openjdk-17 README's build instructions:

configure: error: unrecognized options: --enable-aot
configure exiting with result code 1

I removed that arg and am proceeding with the rest of the directions.

cap10morgan avatar Nov 29 '21 22:11 cap10morgan

I had to add --java-home arg to the mx command, but then it failed like this:

$ mx --env ce --java-home $JAVA_HOME build
WARNING: The component inclusion list ('--components' or '$COMPONENTS') includes an unknown component: 'svml'
WARNING: The component inclusion list ('--components' or '$COMPONENTS') includes an unknown component: 'svml'
Downloading LLVM_ORG_SRC from ['https://lafo.ssw.uni-linz.ac.at/pub/llvm-org/llvm-src-llvmorg-12.0.1-3-g6e0a5672bc-bgf11ed69a5a.tar.gz']
 134340969 bytes (100%)
WARNING: No platform-specific definition is available for project com.oracle.truffle.llvm.tests.va.native for your architecture (aarch64)
WARNING: No platform-specific definition is available for library VISUALVM_PLATFORM_SPECIFIC for your architecture (aarch64)
library VISUALVM_PLATFORM_SPECIFIC:
Library without "path" attribute must have a non-empty "urls" list attribute or "maven" attribute

cap10morgan avatar Nov 30 '21 01:11 cap10morgan

It's probably best to try smaller steps.

First try building the compiler and running its unit tests:

cd compiler/
mx build
mx unittest

Then try building libgraal and running its gate:

cd vm/
mx --env libgraal build
mx --env libgraal gate -t "LibGraal"

dougxc avatar Nov 30 '21 08:11 dougxc