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/.
borkdude 2021-03-06T11:29:24.063300Z

1
futurile 2021-03-06T11:59:06.063400Z

@borkdude: just watching your Graal video, nice! If you're looking for ideas/requests for videos - I would love one on development for Clojure with Docker. Personally I've never really grokked Docker and then when you add mounting your src and connecting through the REPL it feels complex - though the idea of a repeatable / shareable dev set-up is cool.

borkdude 2021-03-06T12:11:59.064100Z

@slgeorge That's not my favorite thing to do either. I only run services in Docker, not the main app I'm developing usually

lread 2021-03-06T12:51:09.065100Z

Awesome video @borkdude!

1โค๏ธ
lread 2021-03-06T12:54:53.067600Z

And a good review of our old hello world scripts! I think Iโ€™ll update with some of your comments. I can also link in your video.

borkdude 2021-03-06T12:55:33.067800Z

:thumbsup: :)

borkdude 2021-03-06T12:56:16.068400Z

One thing I also tend to do by default now is use depstar to build an uberjar first. This prevented me having some weird "too long classpath" problems on Windows, so I kinda do it by default now

borkdude 2021-03-06T12:56:30.068700Z

Didn't show it in the video

borkdude 2021-03-06T12:57:06.069800Z

but it's good to see what's going on and how to compile the sources yourself

1๐Ÿ‘
borkdude 2021-03-06T12:57:15.070200Z

we can add the classpath thing to tips and tricks

1๐Ÿ‘
lread 2021-03-06T12:59:51.073200Z

was thinking at one point of rewriting script in bb so that itโ€™d work on windows but decided against it. we can point to examples in the wild.

borkdude 2021-03-06T13:01:11.073500Z

yeah, it's good to give the most basic vanilla example

borkdude 2021-03-06T13:01:18.073800Z

for learning purposes, not convenience

lread 2021-03-06T13:09:44.074Z

agreed

johan1a 2021-03-06T15:07:18.075500Z

Has anyone gotten cljfmt to run as a native image? When I run lein native-image, I get an exception:

Caused by: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.ClassLoader.defineClass(String, byte[], int, int) is reachable
(I am a beginner at clojure so let me know if there is a better place to ask.)

borkdude 2021-03-06T15:20:12.075800Z

@johan1a Have you maybe watched my video? https://youtu.be/G9Xp2zlEmos

borkdude 2021-03-06T15:20:20.076Z

I explain it in there

borkdude 2021-03-06T15:20:38.076200Z

Add the flag --report-unsupported-elements-at-runtime

borkdude 2021-03-06T15:27:07.077Z

It would be interesting to see which part of cljfmt triggers that though, afaik it doesn't need compilation anywhere, but there could be some runtime require or something lingering somewhere

borkdude 2021-03-06T15:28:02.077500Z

If you can share some location info that would be nice

ericdallo 2021-03-06T15:28:59.078500Z

Clojure-lsp uses cljfmt via JVM and is compiled with graalvm, maybe the graalvm config should be similar? https://github.com/clojure-lsp/clojure-lsp/tree/master/graalvm

borkdude 2021-03-06T15:29:22.078900Z

Ah I see the cljfmt project already has a graalvm config: https://github.com/weavejester/cljfmt/blob/master/cljfmt/project.clj

borkdude 2021-03-06T15:29:32.079400Z

So you can run it straight from the project itself

1๐Ÿ‘
ericdallo 2021-03-06T15:30:40.080700Z

@borkdude shouldn't cljfmt add the reflect config to the classpath/META-INF folder? then it would work for projects that use?

johan1a 2021-03-06T15:30:47.080900Z

Thanks, it worked when I added the --report-unsupported-elements-at-runtime. I will watch the video!

borkdude 2021-03-06T15:31:23.081300Z

@ericdallo Will native-image gather all configs?

borkdude 2021-03-06T15:31:26.081500Z

from all libs?

borkdude 2021-03-06T15:32:10.082Z

If so, then that would be great to add to the META-INF

ericdallo 2021-03-06T15:32:43.083100Z

yes, I saw it somewhere, if the lib add its graalvm config to a specific folder, native-image will check that automatically

borkdude 2021-03-06T15:32:55.083400Z

I don't see the --report-unsupported-elements-at-runtime flag in the build of cljfmt itself, so I still wonder what triggered it @johan1a. Can you share your entire in a gist?

ericdallo 2021-03-06T15:34:09.084100Z

I already saw 1 or 2 projects following that rule

johan1a 2021-03-06T15:34:22.084200Z

I added it here

borkdude 2021-03-06T15:34:56.084700Z

Nice, yeah, I knew that it existed, but haven't used it.

borkdude 2021-03-06T15:35:22.085400Z

@johan1a I mean the output of your failing compilation.

ericdallo 2021-03-06T15:35:59.086600Z

Yeah, that'd be perfect for clj-kondo/lsp4j/slite/datalevin and etc for example, then other libs would need to just take care of its lib graalvm configuration, not copy other libs reflect/jni etc content

borkdude 2021-03-06T15:37:03.086700Z

ok, weird, I don't see anything suspicious about cljfmt there. thanks for sharing

1๐Ÿ‘
borkdude 2021-03-06T15:37:10.087Z

yeah

lread 2021-03-06T16:59:23.087900Z

huhโ€ฆ looks like current GraalVM install instruction https://www.graalvm.org/docs/getting-started/linux/.

borkdude 2021-03-06T17:01:31.088300Z

@lee That's for general JVM usage. Check here: https://www.graalvm.org/reference-manual/native-image/

lread 2021-03-06T17:01:56.088800Z

merci buckets!

borkdude 2021-03-06T17:02:18.089300Z

I also saw they used this in some of their latest streaming videos on twitch. But regardless, I think it's a saner convention

borkdude 2021-03-06T17:02:44.090200Z

since GraalVM has more stuff than only invoking native-image, like the gu installer for installing native-image in the first place

lread 2021-03-06T17:03:18.091200Z

I use SDKman and it only sets JAVA_HOME, but Iโ€™ll stick with GRAALVM_HOME for clj-graal-docs hello world.

borkdude 2021-03-06T17:03:19.091300Z

and it's easier to set JAVA_HOME to GRAALVM_HOME and place GRAALVM_HOME/bin on the path

ericdallo 2021-03-06T17:38:37.093100Z

Really good video @borkdude, If I had that when compiling clojure-lsp... ๐Ÿ˜„ I bet it will help new users to compile with graalvm their clojure apps

lread 2021-03-06T18:35:41.095700Z

Iโ€™ve updated our https://github.com/lread/clj-graal-docs/blob/master/doc/hello-world.md to address some review comments from @borkdudeโ€™s video. Also, of course, included a link to the vid. This means I watched your video TWICE @borkdude! It was even better the 2nd time! :simple_smile:

lread 2021-03-06T18:36:39.095900Z

I end up setting GRAALVM_HOME to JAVA_HOME for scripts that require it. But either way is good with me.

borkdude 2021-03-06T18:51:36.096200Z

Haha! thanks!