by ducktective · 3y ago · 0 comments
AFAIK, there isn't an official and hassle-free way to generate a statically-compiled binary with SBCL the way Go and Rust can. Like you develop on a debian 12 system, then move the binary to your debian 11 server only to be confronted with the notorious 'incompatible glibc version error'. It's super annoying.
In ECL, I think it's possible to use musl and bundle libecl and mucl libc into the final binary, but I'm not sure.
The caveat is ECL output startup time is around 500ms (as opposed to the much more performant SBCL output)
I started making my own freestanding Linux Lisp because of this exact issue. It's nowhere near as performant as something like SBCL but it's small and has zero dependencies. Once compiled it will literally run on any Linux of the same architecture.
https://github.com/lone-lang/lone
I'm taking a break from this project at the moment but eventually I'm gonna add a feature that lets me put a Lisp script into the ELF itself so I can just copy it with the scripts included and have a totally self-contained freestanding Lisp executable.
There is no official, hassle-free way to generate a statically-compiled binary with C for GNU/Linux.
A C program compiled on Deb 12 might not work on 11, if it requests a new version of some function, or a new function.
Go and Rust can, but they are silos.
Glibc dropped support for static linking years ago. You can't deploy a new library to close a library security hole, for programs that have statically linked it.
Rust and Go are doing a stupid thing.
Of course you can. You just recompile affected programs. Just like you need to do in the case of header-only C/C++ libraries like much of widely-used Boost. And if the library is not strictly header-only, but still has significant code in headers, as is often the case in C++, if you only swap the dynamic library, the program is still broken, or much more likely: it becomes broken, even though it originally wasn’t.
I heard projects (like the Kandria game) build their releases on an old glibc (but latest SBCL and libraries), so it can be shipped to any more recent system.
I get that with Go too. I now make all my release builds on the oldest version of Linux I have.
I got the glibc errors when I moved a binary I compiled on the newest Linux Mint to my VPS running some ancient debian.
I've written more about this here:
s/backward/forward/
The commlaint here is that the older glibc on Debian 11 doesn't run programs built against a newer glibc under Debian 12.
glibc has very good backward compatibility, with careful symbol versioning and whatnot.
Backward compatibility means that a newer glibc (like in Debian 12) will handle programs requesting the older glibc (e.g. from Debian 11).
Not in my experience. Working through exercises in Practical Binary Analysis, the first problem I needed to solve was running programs compiled against an older glibc on older Ubuntu on a new Ubuntu version with newer glibc, which boiled down to hunting down the glibc so from the older Ubuntu. Without it, the programs crashed on startup. That problem wasn’t even planned by the book author, but it sure was a good thematic fit. :)
The NetBSD backwards compatibility mechanism is to not change the arguments to an existing syscall, if there is a need to change something then a new syscall will be created and aliased to the old name in the system include files. Old binaries use the old syscall, those compiled after the new one has been added will use that. Languages that don't parse the system .h files like Go need conditional code for NetBSD.
$ time ecl --eval "(quit)"
0.052 secs
$ time ecl --eval "(require 'asdf)" --eval "(quit)"
;;; Loading #P".../lib64/ecl-21.2.1/asdf.fas"
0.301 secs
This is a bad plan for target systems that use glibc, because static linking is not recommended and not supported.
I find a lot of the static binary hand wringing basically: did you ever solve how to ship more than 1 file to production? Did you ever need to virtualize any resource on your compute?
Then you're at a minimum using a chroot and containers.
If you aren't shipping to production, if you're really just copying files around between your laptops and you want them to run - you have glibc.
The moment we end up in a world where a "small CLI program" requires docker.. I give up. Time to retire from software and go raise sheep or something instead.
I think I just use linux enough that all the macos bugs I don't experience.
This is a real problem with Linux (not MacOS or other BSDs from what I understand) because it doesn't have a stable ABI (the ABI is basically glibc). It's a design choice, and a pain in the ass for people who want to distribute things as binaries. Which, well, it's not something I do, but, it has burned me using other people's things.
Could docker/containerization solve this problem? Yes, in the same way that a shotgun would serve for eliminating mosquitoes...
People forgot this lesson when macbooks got popular for development, then had to relearn it by upending the ecosystem into containers.