Closed deaddowney closed 4 years ago
I think this has nothing to do with CLI-matic; the gen namespace is for generators. Have you tried with Clojure 1.9?
If I downgrade to Clojure 1.9.0, I get
java.io.FileNotFoundException: Could not locate Clojure resource on classpath:
clojure/core_instant18.clj
at clojure.lang.RT.loadResourceScript(RT.java:386)
at clojure.lang.RT.loadResourceScript(RT.java:370)
at clojure.lang.RT.load(RT.java:460)
at clojure.lang.RT.load(RT.java:426)
at clojure.core$load$fn__6548.invoke(core_clj:6046)
at clojure.core$load.invokeStatic(core_clj:6045)
at clojure.core$load.doInvoke(core_clj:6029)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$fn_8955.invokeStatic(core_clj:6709)
at clojure.core$fn_8955.invoke(core_clj:6708)
at clojure.core_init.load(Unknown Source)
If I add "--report-unsupported-elements-at-runtime", I can compile, but it barfs when I run the executable.
java.io.FileNotFoundException: Could not locate clojure/core__init.class or clojure/core.clj on classpath
The issue is weird because if I native-image without bringing in cli-matic, with just my own -main implementation, it works and runs.
I get this too. The only dependency is cli-matic absolutely minimal program
(ns hello.core
(:gen-class)
(:require [cli-matic.core :as cli]))
(def CLI-CONFIGURATION
{:app {:command "test"
:description "A test cli"
:version "0.0.1"}
:commands [{:command "hello"
:run (fn [args]
(println "Hello World"))}]})
(defn -main
[& args]
(cli/run-cmd args CLI-CONFIGURATION))
Maybe it's an issue with Clojure 1.10, because i just tried it with 1.9 and the current cli-matic and GraalVM and it seems to work.
[root@localhost graal]# ./graalvm-ce-1.0.0-rc15/bin/native-image -H:+ReportUnsupportedElementsAtRuntime -J-Xmx3G -J-Xms3G --no-server -jar ../target/pippo-0.1.4-SNAPSHOT-standalone.jar
[pippo-0.1.4-SNAPSHOT-standalone:4430] classlist: 3,252.54 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] (cap): 771.12 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] setup: 39,045.86 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] (typeflow): 49,676.01 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] (objects): 12,748.93 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] (features): 535.75 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] analysis: 63,937.07 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] universe: 757.10 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] (parse): 3,626.17 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] (inline): 6,424.41 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] (compile): 29,594.25 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] compile: 40,766.34 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] image: 2,510.03 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] write: 354.18 ms
[pippo-0.1.4-SNAPSHOT-standalone:4430] [total]: 150,770.49 ms
And it runs:
[root@localhost graal]# ./pippo-0.1.4-SNAPSHOT-standalone
** ERROR: **
No sub-command specified.
NAME:
toycalc - A command-line toy calculator
USAGE:
toycalc [global-options] command [command options] [arguments...]
VERSION:
0.1
COMMANDS:
add, a Adds two numbers together
sub, s Subtracts parameter B from A
GLOBAL OPTIONS:
--base N 10 The number base for output
-?, --help
[root@localhost graal]# ./pippo-0.1.4-SNAPSHOT-standalone add -a 1 -b 2
3
This is my project.clj:
(defproject pippo "0.1.4-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.9.0"]
[cli-matic "0.3.6"]]
:repl-options {:init-ns pippo.core}
:main pippo.core
:aot :all)
On a Centos7 VM:
[root@localhost pippo]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
If I use 1.10 it complains about Unbalanced Monitors (?):
Warning: Abort stand-alone image build. unbalanced monitors: mismatch at monitorexit, 96|LoadField#lockee__5436__auto__ != 3|LoadField#lockee__5436__auto__
Detailed message:
Call path from entry point to clojure.spec.gen.alpha$dynaload$fn__2628.invoke():
at clojure.spec.gen.alpha$dynaload$fn__2628.invoke(alpha.clj:21)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:473)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Build on Server(pid: 4674, port: 55930)*
I believe in my wanderings that this is a problem when native-image is put in the same room with clojure.spec, particularly clojure.spec.alpha . This was built-in to clojure in 1.9.0, so downgrading makes the issue disappear. I'm thinking that's the explosive combo: clojure + clojure.spec.alpha (first appears in 1.10.0 of clojure) + native-image.
Yes I think it's so. And the Clojure team is aware of the issue https://dev.clojure.org/jira/browse/CLJ-1472 and is due for resolution in 1.11 (or so Jira says).
Just as a little update on that issue: Using Clojure 1.10.2-alpha1 already solves this issue. No need to wait for 1.11.
I verified it when porting my own little pet project https://github.com/JohannesFKnauf/parti-time to graalvm native-image distribution.
I think this issue can be closed.
When I run native-image on my jar with graal-rc10 I am getting an error: "unbalanced monitors: mismatch at monitorexit" due to clojure.spec.gen.alpha$dynaload$fn__2628, which I think is due to its use of the clojure.core.locking macro, which is known to trip up Graal https://dev.clojure.org/jira/browse/CLJ-1472
I'm using clojure 1.10.0 and clojure.spec.alpah 0.2.176