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/.
2021-06-04T15:37:54.021300Z

Does anyone know why the graal agent that can discover how to make reflective calls, always generates loads of spurious config that causes warnings like this when compiling the native-image: WARNING: Could not resolve me.raynes.fs$eval2576 for reflection configuration. Reason: java.lang.ClassNotFoundException: me.raynes.fs$eval2576.

borkdude 2021-06-04T15:49:55.022Z

@rickmoynihan The agent gets triggered with a lot of false positives I think because the Clojure compiler uses reflection to look up things for compilation

borkdude 2021-06-04T15:50:15.022600Z

And the numbering scheme for functions, etc isn't stable over multiple compilations

2021-06-04T15:51:15.023600Z

ah ok that makes some sense; I figured it was something like that as a lot of the class names look to essentially be evaluations of defs at the top-level

borkdude 2021-06-04T15:53:27.024600Z

If you blindly follow what the agent generates, you will (probably) end up with lots of garbage inside your image

2021-06-04T15:56:21.025400Z

yeah, I’ve culled everything that gives me a warning; but I suspect there’s a huge amount more I could remove. Not sure where to start with that though

borkdude 2021-06-04T15:58:06.025700Z

I usually start with nothing and add only what is needed after testing

borkdude 2021-06-04T15:58:25.026200Z

the output of the agent I only use as inspiration if I have trouble finding out what's wrong

2021-06-04T16:00:04.026800Z

Yeah I think that’s ultimately a better direction; though at least going the other direction I can get something working quickly 🙂

2021-06-04T16:00:38.027300Z

I’m guessing it can make a pretty huge difference to image size?

borkdude 2021-06-04T16:02:36.027500Z

Perhaps, just try

borkdude 2021-06-04T16:02:54.027800Z

I usually start with ensuring *warn-on-reflection* is enabled

2021-06-04T16:09:11.028100Z

yeah doing that already — I have a lot of transitive deps though

borkdude 2021-06-04T16:10:01.028500Z

I wonder how you can set it globally...

$ clj -M -e "(alter-var-root #'*warn-on-reflection* (constantly true))" -e '(fn [x] (.length x))'
true
#object[user$eval138$fn__139 0x7c2327fa "user$eval138$fn__139@7c2327fa"]
That doesn't seem to work...

alexmiller 2021-06-04T16:16:05.028700Z

I don't think there actually is a way

borkdude 2021-06-04T16:26:57.029500Z

somehow leiningen pulls it of, but maybe using some hack

alexmiller 2021-06-04T16:29:02.030300Z

lein is binding around the process iirc

alexmiller 2021-06-04T16:29:59.030600Z

there really should be a way to do it