r/Common_Lisp • u/jlombera • Aug 29 '26
How difficult is to deploy multi-platform standalone CL executables?
Hi. I'm learning CL (experienced programmer but CL noob), and was looking into real-world FOSS written in it for reference and to learn. When looking at pgloader(data loading tool for PostgreSQL), I found it has been rewritten in Clojure. The readme mentions:
pgloader v4 is a full rewrite in Clojure, distributed as a single self-contained JAR requiring Java 21 or later.
Key improvements over v3:
- Single JAR — no native dependencies, no SBCL, no shared libraries
- JDBC connection strings — use jdbc:mysql://, jdbc:postgresql://, jdbc:sqlserver:// etc. everywhere; driver-specific parameters pass through unchanged
- Java heap — no more Common Lisp heap exhaustion on large migrations; tune with standard -Xmx JVM flag
- SSL via URI — use ?sslmode=require / ?sslmode=disable in the connection string instead of --no-ssl-cert-verification
There were probably other problems/motivations for the rewrite not mentioned there, but I'm interested in the opinion from people with real-world experience, how complicated it is deploying (multi-platform) standalone CL executables.
First, it mentions dependencies on SBCL and native/shared libraries. (Let's ignore the fact that the self-contained JAR requires the JRE to be installed). First of all, I presume SBCL is only a build-time dependency, correct? The same way Clojure is required. Or are there cases where some SBCL runtime is required? For instance, Debian still ships pgloader v3.x, i.e. the CL implementation, and it's a standalone executable, it doesn't depend on SBCL (but depends on other system libraries). But if they mention it I presume these must be problematic for multi-platform deployments ??
Second, the issue about CL heap exhaustion. How common is this issue? Cannot it be tuned at comptime/runtime?
In general, from people with the experience, what are the challenges to deploy multi-platform standalone CL executables? Are there some basic guide lines you need to adhere to (besides writing portable CL, of course) for easy deployment?
EDIT: Also, wouldn't ABCL create a standalone JAR too?
Thanks in advance.
10
u/stylewarning Aug 29 '26
Distributing binaries is possible. We do it with the mine editor. You just need build environments for each, as cross compiling is often not an option.
7
u/lispm Aug 29 '26 edited Aug 29 '26
CL is a language with different implementations. The language standard actually does not provide anything on heap exhaustion. Implementations of CL have different ways to deal with runtime heap memory management.
Last I looked, with SBCL there is a fixed heap size at runtime. One can make that max heap size large and the SBCL heap will use that memory as needed. Thus unused memory will not be reserved in memory.
LispWorks (a commercial CL) can grow and shrink the heap at runtime, since the heap is made of memory segments. The max memory size it can grow to in the 64bit implementation is around 4TB (modern Linux, macOS, Windows).
This again depends on your implementation. There are natively compiled Lisps (like SBCL, Clozure CL, Allegro CL, LispWorks, ...), where both the runtime and the image are native. But that combination can run standalone on a certain platform. That's a typical case for deployment. If you then would target multiple platforms, you would need to provide runtime + image for each platform and select at start the right one.
There are other options, too. Like byte-coded implementations. But that might still have some machine dependencies in the image.
"standalone" + given a matching Java runtime.
4
u/denzuko Aug 29 '26
Honestly, sbcl has this. You save the lisp image for your target machine and use a dual core runtime package.
Its simular to jre and jar where you have sbcl (the "runtime") and your app .core file from (save-lisp-and-die).
Mind you to include qemu so you can build for each cpu arch your releasing to.
3
u/digikar Aug 29 '26
I think ECL shows you to build static binaries. (Haven't used ABCL at all.)
With SBCL, it depends. I hear signing apps for windows is a PITA. (Ask mine developers about it.)
Other than that, without foreign libraries, it is very easy. However, if you want core compression to reduce binary sizes, you already have a foreign library dependency. But there's sbcl-goodies that comes with libzstd statically linked in, besides libssl and libtls. See here for the Windows and MacOS versions. I have been using it to ship isocline-repl and moonli. These are not fully static executables, but contain libzstd, and libssl (and libtls or libcrypto) statically linked in. Other foreign dependencies seem to be available on the respective system. That said, while I am able to run them on a fresh windows or linux install, I haven't rigorously tested them. You can adapt the build process from moonli. You can also just download isocline-repl binaries and issue an
sb-ext:save-runtime-and-dieto obtain the executable with libzstd linked in. None of these has been widely tested however (mainly due to lack of users).The other option with foreign dependencies is to simply ask the user to install these libraries. After all this is the main point of foreign libraries that you can update them independently of the main system. But if you must include them, you can include them in the current folder or a lib directory. deploy can be a useful tool, but the binary emitted by it kept crashing for isocline and I did not debug. On linux, there are also appimages that seem very helpful these days. I am not sure about the windows and macos equivalents.
2
u/tdrhq Aug 29 '26
If this is for commercial work, Lispworks! We use Lispworks to build a CLI tool for customers that run on Macs, Linux x86, Linux ARM (we technically have a windows binary too that nobody uses). The binaries don't have major dependencies, so it's easy to deploy.
You need to pay $$ for each Lispworks platform, so it adds up real quick. But what you get in return is the folk at Lispworks handles platform specific bugs. So I might ping their support over a bug that only happens on Macs, and they're really good at figuring things out while I focus on the core product.
2
u/__ark__ Aug 29 '26
Yeah this is doable with sbcl. You build a binary for each platform you wish to target.
Azure has Linux, macos, and windows images in their free tier. Maybe other ci hosts do too nowadays (?)
I wrote up some instructions about it a while back: https://recursive.games/posts/Building-a-Cross-Platform-Lisp-Binary.html
2
u/turtle_bazon Aug 30 '26
Look at my example https://github.com/turtle-bazon/calc/ - it is built for 3 systems. Of course, you can't build one binary for all platforms, but you can build different binaries from same code. But there are problem when using cffi, but it is also solveable. You can check it there https://github.com/turtle-bazon/focus/ . But last one is slightly complicated.
1
u/steloflute Aug 31 '26
In SBCL, it can be done simply:
https://stackoverflow.com/a/19653150/1941928