A deps.edn-based approach is currently blocked because Graal’s native-image requires being run from a special command prompt that comes with Windows SDK 7.1, while the current clojure / clj tooling appears to require being launched via PowerShell.
A work-around using Leiningen and a .bat file (using a non-PowerShell command prompt), was determined by borkdude.
This document is mostly about Java 8 based GraalVMs. For Java 11 based GraalVMs, the process is considerably simpler:
choco install visualstudio2017community --version 15.9.17.0 --no-progress --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.CMake.Project"
-
Windows 7 or later (tested on 7 and 10)
-
Windows SDK 7.1
-
Graal 19 or later (leads to installation of native-image)
-
Leiningen
-
Some Clojure Project that’s amenable to native-image-building (e.g. clj-kondo)
1. Install Windows SDK 7.1
Installing Windows SDK 7.1 may be done via Chocolatey — the relevant command is: choco install windows-sdk-7.1
. On Windows 10, an extra download and installation was required. This was unnecessary on Windows 7.
-
Installation of Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1 (http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=4422)
It may be that the following is enough (untested):
choco install -d windows-sdk-7.1 kb2519277
2. Install native-image
native-image is obtainable via Graal. From version 19, to make our lives interesting, after getting Graal, we are now required to run another command to get native-image :(
-
Utility gu Required for native-image Install: oracle/graal#1335
3. Install Leiningen
This can be done in a variety of ways. It appears doable via the Leiningen site, I was happy to do it via scoop.
4. Build Uberjar with Leiningen
In project.clj, be sure to choose :aot :all. Other things may be necessary, see clj-kondo’s project.clj.
5. Build via native-image
Use the -jar option to native-image, specifying the uberjar created in the previous step. Note that this native-image building needs to be performed via the Windows SDK 7.1 command prompt.
-
Build from Windows SDK 7.1 Command Prompt: oracle/graal#1258 (comment)
-
clj-kondo compile.bat script: https://github.com/borkdude/clj-kondo/blob/fde1e542320d9c45c6a213dc1133b35d23b697ae/script/compile.bat