Fork me on GitHub
#graalvm
<
2023-09-02
>
Ingy döt Net00:09:19

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

Ingy döt Net00:09:58

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

Ingy döt Net04:09:32

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

borkdude09:09:43

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 Net19:09:47

@U04V15CAJ Finally got the whole thing sorted. @U0479UCF48H 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

👍 2
Ingy döt Net20:09:57

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

borkdude20:09:24

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

borkdude20:09:20

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

🙌 2
Ingy döt Net20:09:22

My collaborator tested on his Mac M2 and worked fine

Ingy döt Net20:09:39

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

Ingy döt Net20:09:07

and aren't currently in the way

borkdude20:09:16

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

Ingy döt Net20:09:02

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

Ingy döt Net20:09:42

ie yamlscript.core is a dep for libyamlscript.core

Ingy döt Net20:09:22

ok I'll try that later. thanks!!

Ingy döt Net04:09:43

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 Net04:09:20

google couldn't find anything on that message

borkdude07:09:22

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

borkdude07:09:32

and join their slack as well

Ingy döt Net18:09:43

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?

borkdude18:09:37

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

👀 2
Ingy döt Net18:09:48

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

Ingy döt Net19:09:41

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 Net19:09:07

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

Ingy döt Net19:09:00

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

Ingy döt Net19:09:25

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.