Open hraberg opened 5 years ago
Related to #155.
For reference, if someone else decided to look at this, there's a script to build the native image here:
dev/build-graal-native-image.sh
Also, we currently use Clojure 1.9 in the Graal profile. This due to this Clojure bug: https://dev.clojure.org/jira/browse/CLJ-1472
This bug is in 1.9 as well, but that version of spec doesn't use the locking
macro, which is where the bug arises. When this ticket is fixed we can move the Graal profile to 1.10. The real fix will be in Clojure, but a potential fix might turn up in spec which circumvents it.
A potential alternative is to downgrade spec to the version in 1.9, but there might be other issues with that.
Also worth noting that Graal itself is currently a 1.8 based JVM.
As JNR doesn't work in the native image, we could consider cutting out JNI (and JNR) entirely and use theorg.graalvm.nativeimage.c
which is only available inside the native image to call C directly from Java.
This blog post and repository is the best example: https://cornerwings.github.io/2018/07/graal-native-methods/ https://github.com/cornerwings/graal-native-interaction
It's somewhat documented by this test: https://github.com/oracle/graal/blob/master/substratevm/src/com.oracle.svm.tutorial/src/com/oracle/svm/tutorial/CInterfaceTutorial.java
The JavaDocs are here: http://www.graalvm.org/sdk/javadoc/
The graal profile would need this dependency (or later):
[org.graalvm.sdk/graal-sdk "1.0.0-rc12"]
Graal has moved on slightly since it's latest big release so our use of it will have to be updated.
With quarkus it's possible to have a navive compiled kafka client, I'm not sure how easy this can be integrated with Clojure https://quarkus.io/guides/kafka-guide
We want
crux.main.graal
to delegate tocrux.bootstrap.cli
like the normalcrux.main
namespace. This is currently blocked by this issue which stops Kafka clients from being used inside a native image: https://github.com/oracle/graal/issues/532We should track this issue and check new releases of Graal and see if we can move
crux.main.graal
to do the right thing.