graalvm 2023-09-02

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

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

@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

@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)

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

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

🙌 1

My collaborator tested on his Mac M2 and worked fine

I'll try

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

and aren't currently in the way

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

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

ie yamlscript.core is a dep for libyamlscript.core

ok I'll try that later. thanks!!

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

google couldn't find anything on that message

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

and join their slack as well

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?

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

👀 1

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

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

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

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

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.

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

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