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/.
2020-05-13T19:48:21.251100Z

I'm trying to native compile the following:

(ns graal.me.maybe.core
  (:gen-class)
  (:require [clj-http.client :as client]))

(defn -main [& args]
  (time
    (:body (client/request
             {:method :get
              :url    "<http://www.google.com>"}))))
And here's my build script:
clj -A:uberjar

/Library/Java/JavaVirtualMachines/graalvm-ce-java11-19.3.2/Contents/Home/bin/native-image \
 -H:+ReportUnsupportedElementsAtRuntime \
 -H:ReflectionConfigurationFiles=reflectConfig.json \
 -H:+ReportExceptionStackTraces \
 -H:+TraceClassInitialization \
 -jar ./target/foo-1.0.0-SNAPSHOT-standalone.jar \
 foo
I've tried two paths with the following issues: 1. The above. When I run the output I get <http://java.io|java.io>.FileNotFoundException: Could not locate clojure/core__init.class, clojure/core.clj or clojure/core.cljc on classpath.. 2. I've added the --initialize-at-build-time flag. When I do this I get a bunch of build errors along the lines of "Error: No instances of http://javax.net.ssl.SSLContext". However, the image does build. Any tips on a happy path here?

borkdude 2020-05-13T19:52:55.251600Z

@markbastian clj-http is known not to work with GraalVM. clj-http-lite is

2020-05-13T19:54:38.253500Z

Cool, I'll try that. Do you recommend ce version 20 or 19?

borkdude 2020-05-13T19:55:00.253700Z

@markbastian for SSL you must add some flags: https://github.com/borkdude/babashka/blob/master/script/compile#L44-L45

borkdude 2020-05-13T19:55:33.254500Z

I'm using 19.3.1 myself because it's LTS, more stable

1👍
borkdude 2020-05-13T19:56:34.255200Z

@markbastian also take a look at https://github.com/taylorwood/clojurl which essentially wraps clj-http-lite in a graal binary

borkdude 2020-05-13T19:57:03.255700Z

@markbastian there's also this even lighter curl wrapper: https://github.com/borkdude/babashka.curl

2020-05-13T19:58:54.256900Z

Cool, thanks! I'll check those out.