graalvm

Ingy döt Net 2023-09-02T00:24:19.280449Z

I'm having trouble with getting a graalvm shared lib working. I'm pretty close. I'm trying to do things similar to https://github.com/babashka/sci/blob/master/doc/libsci.md which works for me here. My reproduction can be seen here: https://gist.github.com/ingydotnet/44fe6887cae602ad05ea687fccb3d495 The repo, branch, commit, and reproduction command can be seen here: https://gist.github.com/ingydotnet/44fe6887cae602ad05ea687fccb3d495#file-gistfile1-txt-L4-L18 It's set up to work on linux x64, macos x64 and macos aarch64. Just run ./test/sh from the top dir of the clojure branch of https://github.com/yaml/yamlscript

borkdude 2023-09-02T09:39:43.040299Z

Original exception that caused the problem: org.graalvm.compiler.core.common.PermanentBailoutException: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
Could it be that you are using a clojure version prior to 1.10.3? It had this unbalanced monitor problem which was solved in 1.10.3 and later

Ingy döt Net 2023-09-02T19:26:47.518659Z

@borkdude Finally got the whole thing sorted. @hifumi123 got a lot of things fixed including depping on 1.11.1. I finally figured out that I needed to build with some extra reflections: https://github.com/yaml/yamlscript/blob/clojure/libyamlscript/reflection.json See https://clojurians.slack.com/archives/C05HQFMTURF/p1693681789082869

👍 1
Ingy döt Net 2023-09-02T20:49:52.248779Z

Welp, native-image is failing on my mac m1. https://gist.github.com/ingydotnet/e2b4fab9820ca0b05f9138014bf695aa

Ingy döt Net 2023-09-02T20:50:57.019249Z

@borkdude ever seen:

com.oracle.svm.core.util.VMError$HostedError: java.lang.RuntimeException: Illegal replacement of symbol table entry
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:76)

borkdude 2023-09-02T20:53:24.359699Z

Why don't you first solve those reflection warnings:

Reflection warning, yamlscript/util.clj:10:5 - call to java.lang.Exception ctor can't be resolved.
Reflection warning, fr33m0nk/optional.clj:83:9 - call to method flatMap can't be resolved (target class is unknown).
Reflection warning, yamlscript/parser.clj:46:7 - reference to field getLine on java.lang.Object can't be resolved.
Reflection warning, yamlscript/parser.clj:47:7 - reference to field getColumn on java.lang.Object can't be resolved.
Reflection warning, yamlscript/parser.clj:48:7 - reference to field getIndex on java.lang.Object can't be resolved.
Reflection warning, yamlscript/parser.clj:50:7 - reference to field getLine on java.lang.Object can't be resolved.
Reflection warning, yamlscript/parser.clj:51:7 - reference to field getColumn on java.lang.Object can't be resolved.
Reflection warning, yamlscript/parser.clj:52:7 - reference to field getIndex on java.lang.Object can't be resolved.
Reflection warning, yamlscript/parser.clj:58:29 - reference to field getTag on org.snakeyaml.engine.v2.events.NodeEvent can't be resolved.
Then it's likely that you don't need as many entries in reflect.config either

borkdude 2023-09-02T20:54:20.432139Z

I have seen similar errors with leiningen, the solution was to adapt the entry from :aot :all to :aot [your.main-namespace]

🙌 1
Ingy döt Net 2023-09-02T20:54:22.427299Z

My collaborator tested on his Mac M2 and worked fine

Ingy döt Net 2023-09-02T20:54:53.199379Z

I'll try

Ingy döt Net 2023-09-02T20:55:39.164149Z

the reflection warnings will go away when I switch out snake to another yaml parser.

Ingy döt Net 2023-09-02T20:56:07.561099Z

and aren't currently in the way

borkdude 2023-09-02T20:56:16.846219Z

where are your aot options anyway with leiningen? I don't see them in project.clj

borkdude 2023-09-02T20:57:48.133969Z

ah ok

Ingy döt Net 2023-09-02T20:58:02.753579Z

the ./clojure/ directory builds a dependency library for the main ./libyamlscript/

borkdude 2023-09-02T20:58:19.919409Z

yeah, change this to something like: https://github.com/borkdude/jet/blob/939be14ef3443a6ea0a22c387e046b9e415ae4f5/project.clj#L27

Ingy döt Net 2023-09-02T20:58:42.924099Z

ie yamlscript.core is a dep for libyamlscript.core

Ingy döt Net 2023-09-02T20:59:22.334309Z

ok I'll try that later. thanks!!

Ingy döt Net 2023-09-03T04:52:22.756609Z

Tried https://github.com/yaml/yamlscript/blob/clojure/libyamlscript/project.clj#L25-L26 with same results

Ingy döt Net 2023-09-03T04:53:43.722669Z

The error message is:

The build process encountered an unexpected error:

com.oracle.svm.core.util.VMError$HostedError: java.lang.RuntimeException: Illegal replacement of symbol table entry
which seems to be from svm:
$ ag -ail "Illegal replacement of symbol table entry" /tmp/graalvm
/tmp/graalvm/Contents/Home/lib/svm/builder/objectfile.jar

Ingy döt Net 2023-09-03T04:56:20.504679Z

google couldn't find anything on that message

borkdude 2023-09-03T07:45:22.341749Z

make sure to clean your target directory before making an uberjar. if this still fails, create an issue with graalvm on github

borkdude 2023-09-03T07:45:32.811789Z

and join their slack as well

Ingy döt Net 2023-09-03T18:01:43.319659Z

The error seems to be from here:

 
I wish the error message included oldEntry.getName(). How would I go about recompiling the svm jar to add that?

borkdude 2023-09-03T18:39:37.912539Z

You can build the whole stuff yourself, using these instructions: https://twitter.com/borkdude/status/1621518747155705857

👀 1
Ingy döt Net 2023-09-03T18:52:48.994179Z

Where do I get the labsjdk-ce-17.0.8... download from?

borkdude 2023-09-03T18:55:41.001059Z

https://github.com/graalvm/labs-openjdk-17/releases

🙌 1
Ingy döt Net 2023-09-03T19:39:41.380689Z

well on my way to do this I decided to delete ~/.m2 and start as clean as possible, and now the build works

Ingy döt Net 2023-09-03T19:40:07.267359Z

might try again to make sure I know what's up

Ingy döt Net 2023-09-03T19:41:00.652999Z

I actually just moved ~/.m2 to /tmp/ so I guess I could debug (in my copious spare time)

Ingy döt Net 2023-09-03T19:55:25.507739Z

I did it again from scratch and it worked fine. Note, need to do this:

~ $ which java
/usr/bin/java
~ $ echo $JAVA_HOME
/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home
~ $ export PATH=$JAVA_HOME/bin:$PATH
~ $ which java
/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home/bin/java
so maybe that was the culprit.

Ingy döt Net 2023-09-02T00:24:58.297019Z

I need to be afk for about 1 hour but will be back here after that

Ingy döt Net 2023-09-02T04:34:32.209329Z

@hifumi123 ++ figured it out. Something to do with data.json being broken...