graalvm

Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to https://github.com/clj-easy/graal-docs and https://github.com/BrunoBonacci/graalvm-clojure. GraalVM slack: https://www.graalvm.org/slack-invitation/.
Gerald T 2020-07-17T15:58:44.063400Z

Hello, has anyone tried compiling native-image with taoensso.timbre. I'm doing a minimal lein project with nothing but these:

[org.clojure/clojure "1.9.0"]
[com.taoensso/timbre "4.10.0"]
and I get the following error:
Error: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
 This frame state: [locals: [1,2,3,65,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_] stack: [71] locks: [] rethrowException]
Other frame state: [locals: [1,2,82,65,3,_,_,_,_,_,_,_,_,_,_,_,_,_,_] stack: [85] locks: [78 / 69] rethrowException]
Parser context: io.aviso.exception$write_exception_STAR_.invokeStatic(exception.clj:509) [bci: 55, intrinsic: false]
  55: checkcast     #25         // clojure.lang.IFn
  58: aload         4
  60: invokeinterface#7, 2       // clojure.lang.IFn.invoke:(java.lang.Object)java.lang.Object
  65: dup

Detailed message:
Call path from entry point to io.aviso.exception$write_exception_STAR_.invokeStatic(Object, Object, Object):
	at io.aviso.exception$write_exception_STAR_.invokeStatic(exception.clj:496)
	at io.aviso.exception$write_exception_STAR_.invoke(exception.clj:496)
	at clojure.lang.AFn.applyToHelper(AFn.java:160)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at test2.core.main(Unknown Source)
	at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:149)
	at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:184)
	at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
	at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1541)
	at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1299)
	at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1260)
	at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1219)
	at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1722
Tried this command:
native-image --verbose -H:Log=registerResource: --no-fallback --initialize-at-build-time  --report-unsupported-elements-at-runtime -jar ./target/test2-0.1.0-SNAPSHOT-standalone.jar

borkdude 2020-07-17T16:01:23.064Z

@totoyok285 clojure + GraalVM native-image 101: use 1.10.2-alpha1. Also see the topic of this channel

Gerald T 2020-07-17T16:02:20.064600Z

Yes, thanks just saw it at the top of the channel. Will try it now!

Gerald T 2020-07-17T16:03:02.065200Z

I avoided 1.10.0 because I came across the locking issue, so going to try 10.2-alpha1

Gerald T 2020-07-17T19:36:06.066800Z

Well checked with 1.10.2-alpha, and it managed to compile, but took nearly 1 hour to complete! Using 1.9.0 took a long time too, but I got impatient and stopped it, so it might just work. It only happens with timbre added to the extremely minimal project.

Gerald T 2020-07-18T07:43:10.069900Z

Yup, it works after adding in that flag. I did add it to the leningen plugin native-image jvm-opts options initially, but that doesn't work if I'm generating the uberjar directly. Thanks guys!

Gerald T 2020-07-17T19:36:37.067200Z

So I might have to switch to using clojure.tools.logging instead

phronmophobic 2020-07-17T19:40:25.067300Z

are you using -Dclojure.compiler.direct-linking=true ? It can make a huge difference in compilation time

Gerald T 2020-07-17T19:41:36.068100Z

Yes, I already added that flag

Gerald T 2020-07-17T19:43:12.068500Z

native-image --verbose -J-Dclojure.compiler.direct-linking=true -H:Log=registerResource: --no-fallback --initialize-at-build-time  --report-unsupported-elements-at-runtime -jar ./target/test2-0.1.0-SNAPSHOT-standalone.jar

phronmophobic 2020-07-17T19:44:08.068700Z

I think you need to specify that flag when creating the uberjar

Gerald T 2020-07-17T19:44:23.068900Z

Hmm I see

phronmophobic 2020-07-17T19:45:06.069100Z

yea, its effect is during AOT compilation

Gerald T 2020-07-17T19:47:51.069500Z

Thanks, I can try that as well

borkdude 2020-07-17T20:02:23.069700Z

yeah, add during uberjar or clojure.core/compile