Fork me on GitHub
#graalvm
<
2020-07-17
>
Gerald T15:07:44

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

borkdude16:07:23

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

Gerald T16:07:20

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

Gerald T16:07:02

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

Gerald T19:07:06

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.

phronmophobic19:07:25

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

Gerald T19:07:36

Yes, I already added that flag

Gerald T19:07:12

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

phronmophobic19:07:08

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

phronmophobic19:07:06

yea, its effect is during AOT compilation

Gerald T19:07:51

Thanks, I can try that as well

borkdude20:07:23

yeah, add during uberjar or clojure.core/compile

Gerald T07:07:10

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 T19:07:37

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