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
@totoyok285 clojure + GraalVM native-image 101: use 1.10.2-alpha1. Also see the topic of this channel
Yes, thanks just saw it at the top of the channel. Will try it now!
I avoided 1.10.0 because I came across the locking issue, so going to try 10.2-alpha1
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.
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!
So I might have to switch to using clojure.tools.logging instead
are you using -Dclojure.compiler.direct-linking=true
? It can make a huge difference in compilation time
see https://github.com/lread/clj-graal-docs#native-image-compilation-time
Yes, I already added that flag
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
I think you need to specify that flag when creating the uberjar
Hmm I see
yea, its effect is during AOT compilation
Thanks, I can try that as well
yeah, add during uberjar or clojure.core/compile