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/.
tvaughan 2020-08-20T00:36:44.012600Z

I'm trying to make a native image of a clojure application of mine that's a very simple command-line wrapper around kibit, https://gitlab.com/tvaughan/kibit-runner/-/tree/master/kibit-runner/src/kibit_runner. To compile this I run:

clojure -A:depstar:$@ dist/kibit-runner-standalone.jar -C -m kibit-runner.cmdline
	native-image                                                            \
	  -jar dist/kibit-runner-standalone.jar                                 \
	  dist/kibit-runner                                                     \
	  --initialize-at-build-time=clojure                                    \
	  --report-unsupported-elements-at-runtime                              \
	  --no-server
And when I run this I get:
[root@f092da83da6c kibit-runner]# ./dist/kibit-runner
Exception in thread "main" java.lang.ExceptionInInitializerError
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:291)
Caused by: java.io.FileNotFoundException: Could not locate clojure/core/server__init.class, clojure/core/server.clj or clojure/core/server.cljc on classpath.
        at clojure.lang.RT.load(RT.java:462)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:384)
        at clojure.lang.RT.doInit(RT.java:491)
        at clojure.lang.RT.init(RT.java:467)
        at clojure.lang.Util.loadWithClass(Util.java:248)
        at kibit_runner.cmdline.<clinit>(Unknown Source)
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
This seems to say that the application is trying to start a socket repl of some sort but why? Anyone have any clue what's going on?

tvaughan 2020-08-20T11:33:36.004100Z

The stacktrace occurs at runtime, not compile time

chrisn 2020-08-22T20:34:02.006900Z

I get the same issue if I use initialize-at-build-time=clojure. If I just use initialize-at-build-time then things appear fine but that causes other issues.

tvaughan 2020-08-24T13:50:57.016700Z

I tried numerous different combinations myself, each with different errors

phronmophobic 2020-08-20T01:46:40.000100Z

are you aot compiling everything?

tvaughan 2020-08-20T01:48:03.000300Z

I think so. I'm using the -C option in depstar to compile the uberjar, https://github.com/seancorfield/depstar#aot-compilation

phronmophobic 2020-08-20T02:00:12.000700Z

require allows you to specify you can load it verbosely: https://clojuredocs.org/clojure.core/require

phronmophobic 2020-08-20T02:00:52.000900Z

I would try requiring verbosely and seeing if that helps track down what might be using clojure.server

phronmophobic 2020-08-20T02:04:03.001100Z

nothing jumps out as a problem with your usage. I might try starting with a simple -main that just prints something and progressively add the dependencies and functionality to try to narrow down what might be the issue. it's a little tricky though since native-image does a pretty good job of only trying to only include necessary dependenciies

tvaughan 2020-08-20T02:19:30.001300Z

What should I look for in this output? I don't see any namespace being loaded that contains the string server

tvaughan 2020-08-20T02:19:47.001500Z

I appreciate the help. Thanks

phronmophobic 2020-08-20T03:07:21.003100Z

it should be printing out the order in which namespaces are loaded. i was hoping the last print before the stack trace would identify the culprit