This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-04
Channels
- # adventofcode (154)
- # announcements (1)
- # babashka (8)
- # beginners (28)
- # bristol-clojurians (3)
- # calva (131)
- # cider (43)
- # clj-kondo (14)
- # clojure (135)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-madison (1)
- # clojure-nl (6)
- # clojure-spec (8)
- # clojure-uk (90)
- # clojurescript (47)
- # core-async (9)
- # cryogen (4)
- # cursive (12)
- # datomic (9)
- # emacs (7)
- # fulcro (5)
- # graalvm (56)
- # joker (4)
- # juxt (1)
- # leiningen (6)
- # off-topic (62)
- # pathom (4)
- # pedestal (2)
- # reagent (2)
- # reitit (5)
- # ring (2)
- # schema (4)
- # shadow-cljs (133)
- # sql (38)
- # tools-deps (10)
- # vim (28)
@borkdude why did you close https://github.com/lread/clj-graal-docs/issues/4 - i am trying to figure out why a particular project can be built (and run) using your uberjar method, but fails when using clj.native-image
I don't exactly remember the details, it was just a temporary issue for something I was figuring out
one issue I've had with clj-native was the order in which things were compiled or that not all the source was compiled
@borkdude i get multiple of this type of thing:
Error: Unsupported features in 12 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: clojure.tools.reader.reader_types.IPushbackReader. To diagnose the issue you can use the --allow-incomplete-classpath option. The missing type is then reported at run time when it is accessed the first time.
Trace:
at parsing rewrite_clj.reader$unread.invokeStatic(reader.clj:115)
Call path from entry point to rewrite_clj.reader$unread.invokeStatic(Object, Object):
at rewrite_clj.reader$unread.invokeStatic(reader.clj:112)
at rewrite_clj.reader$unread.invoke(reader.clj:112)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.AFn.applyTo(AFn.java:144)
at script.main(Unknown Source)
at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:151)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
full output (from command invocation) at: https://pastebin.com/UM8ty9x6@sogaiu can you compare the .class files in the uberjar to the .class files produced by the clj native tool?
i'll take a look (iiuc IPushbackReader comes into existence via defprotocol -- is that something that can be understood by native-image at build time?)
so far in the comparison, it appears that via lein i get some class files (as well as the source) for tools.reader.reader_types, but i don't see anything in the classes directory for clj-native-image -- that looks relevant < @taylor
it works up through this commit: https://github.com/taylorwood/clj.native-image/commit/7773c73886a5938fec2d6c5a2227c1aec686e1a5 it stops working here: https://github.com/taylorwood/clj.native-image/commit/b3823a48be75122b9671c86ce5353a85589ef15f changing the tools.namespace version seems to trigger the issue
I've had a similar problem, that's why I went to lein eventually, since that has more predictable compilation
let me see if I can find it, but that will be later, since I'm cooking dinner right now
fwiw I can't find it anymore, I think I deleted it while making a hello world for clj-graal-docs and I didn't need it anymore
i did some more experiments and i think i more or less confirmed what you said -- may be you saw already, but fwiw, notes are at: https://github.com/taylorwood/clj.native-image/issues/20#issuecomment-561976573
it seems odd because the part of tools.namespace
that clj.native-image
is using is just find-namespaces-in-dir
-- i've compared the values for both versions of tools.namespace
(the one from the version of clj.native-image
that works from the one that doesn't) and they return the same value.
thanks for looking into this! I’ll try to repro/figure it out soon, otherwise I may rollback to the previous version of that dep as a workaround :man-shrugging:
> Release 1.0.0-alpha1 on 02 Nov 2015 > Reader types implement Closeable > Added pushback-reader > Improved interoperability between reader types and java readers > Release 0.10.0 on 09 Oct 2015 > Better error for invalid octal literal
maybe also relevant https://github.com/clojure/tools.reader/commit/81451a88f887579957d8f29d0afff194b005a0fe
fwiw, if i explicitly set my project to use tools.reader 1.3.2 and (compile 'script)
, at least some (possibly all?) relevant reader_types .class files appear within the classes directory
i tried adding clj.native-image to my deps.edn in the :deps section.
from a fresh repl, if the first thing i do is (compile 'script)
, i see class files for reader_types
from a fresh repl, if i (require '[clj.native-image])
and then (compile 'script)
, i don't get the reader_types class files
also tried adding java.classpath 0.3.0 and tools.namespace 0.3.1 to my deps.edn -- same result
if i (require 'clojure.tools.namespace.find)
before (compile 'script)
, the reader_type class files don't appear
ah, could it be that things that are required end up being cached so they aren't going to be written to disk?
@taylor TIL from noisesmith about *loading-verbosely*
-- when i do:
(in-ns 'clojure.core)
(binding [*loading-verbosely* true] (compile 'script))
i see what is loaded during compilation.
if i require clojure.tools.namespace.find before compilation, reader-types doesn't appear to get loaded during compile
(perhaps it is cached?)
if i don't require anything first and do compile
while observing what's loaded, i do see reader-typesso, possibly using mranderson or similar to "vendor" clj.native-image's dependencies might actually address this situation -- may be there are other alternatives
don't know if there's a way to force compile
to load everything necessary from disk instead of using cached info
there's a *loaded-libs*
in clojure.core -- may be this is a factor in deciding whether to load something. i don't know if it's a good idea, but may be it can be modified to not contain certain libs to force them to get loaded during a call to compile
as an experiment at the repl, i tried (dosync (ref-set *loaded-libs* ...))
after a require of clj.native-image (i saved the value of *loaded-libs*
before the require and used that in ref-set).
this seemed to affect compile
's behavior appropriately. *loaded-libs*
is private though and this approach doesn't seem right.
hey just wanted to say thanks so much for the detailed research/notes for these issues, and apologize that I won’t have much time until after holidays to look at it 😞
https://github.com/taylorwood/clj.native-image/blob/master/src/clj/native_image.clj#L89_L94
(let [deps-map (merged-deps)
namespaces (mapcat (comp find-namespaces-in-dir io/file) (:paths deps-map))]
(prep-compile-path)
(doseq [ns (distinct (cons main-ns namespaces))]
(println "Compiling" ns)
(compile (symbol ns)))
What is the current situation of making native images which use AWS SDK? It seems that Amazonica seems to not work but have anyone tried Cognitects AWS SDK?