How do I get jextract to build on a Macbook air M2 with latest OS

160 Views Asked by At

I want to. test the Panama project added APIs and the jextract generator for such on a macbook air M2. There don't seem to be any arm64 prebuilt binaries for jextract.

I have zulu jdk 20 installed, cmake, python3, xCode, xCode command line tools, and the latest gradle ( should be enough to run a gradlew which caches the version it wants )

I cloned jextract from

https://github.com/openjdk/jextract.git

JAVA_HOME is set to /Library/Java/JavaVirtualMachines/zulu-20.jdk/Contents/Home

followed the instructions in the README.md It specifies I should do:

sh ./gradlew -Pjdk20_home=<jdk20_home_dir> -Pllvm_home=<libclang_dir> clean verify

Which led to issuing this command to build it.

./gradlew -Pjdk20_home=/Library/Java/JavaVirtualMachines/zulu-20.jdk/Contents/Home -Pllvm_home=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/ clean verify

Building results in this error from javac from gradle:

> Task :compileJava FAILED
error: release version 20 not supported
Usage: javac <options> <source files>
use --help for a list of possible options

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed with exit code 2; see the compiler error output for details.

I have also tried the other llvm paths they suggest. And have also tried older zulu-17 JDK and each time deleted gradle caches, the build folder and re-extracted the source (git reset --hard) from git.

I have searched for a solution for this. I also have searched for a forum on Panama and.or jextract to help me find a solution or any information on building for an apple M1/M2 and have not found anything.

Thanks !

1

There are 1 best solutions below

1
Codo On BEST ANSWER

To run the jextract build, you must have both Java 17 and the target Java version (Java 20 in your case). The actual build is done with Java 17.

Set JAVA_HOME to point to Java 17:

export JAVA_HOME=`/usr/libexec/java_home -v 17`
java -version

Then run the build command:

sh ./gradlew -Pjdk20_home=/Users/user/Documents/zulu20.32.11_1-ca-jdk20.0.2-macosx_aarch64 -Pllvm_home=/Library/Developer/CommandLineTools/usr/ clean verify