This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-16
Channels
- # announcements (3)
- # beginners (104)
- # boot (18)
- # calva (1)
- # cider (43)
- # cljs-dev (45)
- # cljsrn (2)
- # clojure (29)
- # clojure-dev (10)
- # clojure-europe (2)
- # clojure-italy (117)
- # clojure-nl (17)
- # clojure-spec (56)
- # clojure-uk (41)
- # clojuredesign-podcast (12)
- # clojurescript (35)
- # community-development (6)
- # cursive (27)
- # datomic (12)
- # emacs (9)
- # fulcro (6)
- # graalvm (52)
- # instaparse (6)
- # klipse (3)
- # leiningen (11)
- # lumo (1)
- # off-topic (16)
- # pathom (31)
- # re-frame (10)
- # reagent (26)
- # reitit (3)
- # shadow-cljs (67)
- # sql (4)
- # tools-deps (1)
What version of Clojure is supported?
we don't consider Graal to be a supported target of Clojure, so the proper answer is "none"
when you say Graal is not supported, do you mean native image specifically or GraalVM the JVM as well?
We do no testing with either
the are probably more nuanced answers as to what people have gotten to work using whatever workaround
I've been using 1.10.1 with great success, just avoiding spec and pprint for the weird locking issue, however that works on 1.9.0
if that gets ever fixed for Android, hopefully graal people won't run into it anymore either
for "basic" things it works great, just don't expect to be using eval etc. from that perspective I understand the decision not to see it as an official target
Weird, cuz I'm getting errors (posted in #beginners) using 1.10.1 for a simple hello world app
@johnjelinek you may have some luck looking at some examples I made: https://github.com/borkdude/clj-kondo https://github.com/borkdude/jet https://github.com/borkdude/babashka
some tips: - make sure you set warn-on-reflection in every namespace - use lein to compile an uberjar with AOT all - feed that jar to graalvm
@johnjelinek this is also a nice one: https://github.com/tomekw/cotd
and another one: https://github.com/taylorwood/clojurl
Any tips when using tools.deps instead of lein?
I was using juxt/pack do to AOT
Ok, I can compile manually as well
Just (compile ...
right? I dumps to my classes dir
yeah I think so. the thing I find easier about lein uberjar + AOT is that it's all in one place and I don't have to set any paths for graal
core.clj:
(ns clj-graalvm.core
(:gen-class))
(defn -main []
(println "š" (clojure-version)))
deps.edn:
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}}
:aliases {:aot {:extra-paths ["classes"]
:main-opts ["-e" "(compile,'clj-graalvm.core)"]}}}
$ clojure -m clj-graalvm.core
š 1.10.1
native-image -cp $(clj -Spath) -cp classes/ -H:+ReportExceptionStackTraces -H:+PrintClassInitialization -H:Name=clj-graalvm --initialize-at-build-time --report-unsupported-elements-at-runtime --no-server --no-fallback clj-graalvm.core
[clj-graalvm:47247] classlist: 2,985.89 ms
Error: Main entry point class 'clj-graalvm.core' not found.
com.oracle.svm.core.util.UserError$UserException: Main entry point class 'clj-graalvm.core' not found.
at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:258)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:446)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:112)
Error: Image build request failed with exit status 1
same error
same error
this works when I did aot
from clojure 1.9.0
native-image -cp $(clojure -Spath) -H:+ReportExceptionStackTraces -H:+PrintClassInitialization -H:Name=clj-graalvm --initialize-at-build-time --report-unsupported-elements-at-runtime --no-server --no-fallback --verbose clj_graalvm.core
if you put this project on github or similar so I can clone and run it, I'm willing to help you fix it. I'm too lazy to copy paste file and create dirs š
ok, fixed it
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}}
:aliases {:aot {:extra-paths ["classes"]
:main-opts ["-e" "(compile,'clj-graalvm.core)"]}}
:paths ["src", "classes"]}
added classes
to :paths
./clj-graalvm
š 1.10.1
so, can I target different architectures with native-image
?
it doesn't do cross compiling. if you're on Mac you can compile for linux using Docker
sweet, built via docker ā
@borkdude: thanks for your help
@johnjelinek fwiw, the windows support for native-image doesn't appear to be as good as that for the *nixes -- e.g. https://github.com/sogaiu/constdin
oic, thanks for sharing