This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-01
Channels
- # announcements (14)
- # beginners (6)
- # biff (6)
- # calva (3)
- # cider (7)
- # clojure (79)
- # clojure-europe (5)
- # clojure-norway (9)
- # cursive (9)
- # data-science (20)
- # datomic (3)
- # fulcro (9)
- # graalvm (15)
- # integrant (2)
- # introduce-yourself (2)
- # jobs (1)
- # lsp (7)
- # malli (5)
- # off-topic (130)
- # parinfer (11)
- # pedestal (11)
- # portal (1)
- # practicalli (4)
- # releases (3)
- # remote-jobs (1)
- # ring (8)
- # ring-swagger (30)
- # shadow-cljs (9)
- # sql (10)
- # tools-deps (8)
I’m trying to build a native image of an internal clojure service. I can successfully create the binary but when I execute it, I get Could not locate clojure/core/server__init.class, clojure/core/server.clj or clojure/core/server.cljc on classpath
.
First of all, I’m puzzled why clojure.core.server
is being loaded. It’s not referenced in my source.
Regardless, I can’t find the right twiddleebits to get around this problem. The relevant clojure.core.server
class files are in my uber jar. My native-image
command is
native-image -jar target/service-standalone.jar --no-fallback --initialize-at-build-time=org.slf4j.helpers,clojure --initialize-at-run-time=clojure.lang.Compiler
Has anyone seen this problem?yes, you need to use --initialize-at-build-time=
for every clojure package.
when using https://github.com/clj-easy/graal-build-time this will be done automatically
Doh! I included graal-build-time in my deps.edn but I forgot to add --features=clj_easy.graal_build_time.InitClojureClasses
to my native-image command line
I'm looking at some examples of compiling Clojure with GraalVM, and I noticed that many sample projects in https://github.com/clj-easy/graalvm-clojure/tree/master, if not all, use:
:aot :all
Same says the guide:
https://github.com/clj-easy/graalvm-clojure/blob/master/doc/clojure-graalvm-native-binary.md
On the other hand
babashka sets:
:main babashka.main
:aot [babashka.main]
I don't assume anything, I'm just curious. Is it better to aot only the main?I took graal-build-time 2.0.5 and I noticed this log:
[clj-easy/graal-build-time] Registering packages for build time initialization: clojure, clj_easy.graal_build_time, simplecgt.web.server
Is that correct for list to include clj_easy.graal_build_time
? It sounds like the package is included in the final binary.
Shouldn't only facilitate the graalvm compilation?Dunno, did you include the dependency on the classpath of the uberjar and did you use aot all? If yes, then don't do that
So what I got:
• graal-built-time in classpath for uberjar
• aot only for main
• the only build time flag related to initialize is: --features=clj_easy.graal_build_time.InitClojureClasses
Here is this demo:
• https://github.com/rynkowsg/simple-cgt-web/blob/main/scripts/compile-native.bash#L17
• https://github.com/rynkowsg/simple-cgt-web/blob/main/project.clj
but I don't think your image will actually contain any of this tool, it's probably how this is supposed to work