News for hackers. Stuff that matters.
Re:Using SBCL Common Lisp as a Dynamic Library by d110af5ccf on Saturday April 16, 2022 @09:49PM (#31057725)
You don't. As others noted, you can save a core image. Cross compiling, tree shaking, and other such things don't exist in the sbcl world and (from what I've read in the past) the people developing it have little or no interest in those features.

If you need those sorts of features paired with common lisp you could give embeddable common lisp a try. Otherwise if any lisp language will work for you then chicken scheme and gambit scheme both compile to c.

Re:Using SBCL Common Lisp as a Dynamic Library by lispm on Sunday April 17, 2022 @03:43AM (#31059241)
> save a core image.

which can be made executable. So saving an image is the way to create an executable.

> the people developing it have little or no interest in those features

the demand for these features from the SBCL user base also does not seem high. If it would have been needed, then the development could have been sponsored, like for example the support for Apple Silicon was sponsored by users.

Though other CL implementations provide different deployment options:

ABCL compiles to JVM code.

ECL can compile to C or portable byte code. It also has been used for Android and iOS apps.

LispWorks & Allegro CL have treeshakers and can generate shared libraries. LispWorks also has a runtime for Android and for iOS.

Re:Using SBCL Common Lisp as a Dynamic Library by reikonomusha on Sunday April 17, 2022 @01:44AM (#31058796)
SBCL certainly produces an executable containing fully native machine code. You can ./run it just fine.

I consider how it arranges that code (the "image" you speak of) to be merely an implementation detail that the user is not concerned with.

Re:Using SBCL Common Lisp as a Dynamic Library by moonchild on Saturday April 16, 2022 @10:10PM (#31057832)
> tree shaking

The technique of 'tree shaking' was originally developed for lisp.

Re:Using SBCL Common Lisp as a Dynamic Library by d110af5ccf on Saturday April 16, 2022 @11:13PM (#31058133)
And? When I last checked sbcl didn't support it. Are you implying that has changed?

Neither did sbcl support cross compiling. To the best of my knowledge all you can do with sbcl is save an image.

When I was looking in to this I read through many discussions where the developers appeared hostile to the idea of implementing these features. A common refrain I encountered was that tree shaking is unnecessary because the core images are compressed.

Re:Using SBCL Common Lisp as a Dynamic Library by reikonomusha on Sunday April 17, 2022 @01:46AM (#31058804)
You can delete data from the image if you want. We used to do it: scrub all doc strings, inlining data, etc. It's trivial.

In 2022, removing a few megabytes of data doesn't seem worth the maintenance cost of the feature. In other words, for most users, it's a non-problem.

Re:Using SBCL Common Lisp as a Dynamic Library by oblio on Sunday April 17, 2022 @03:17AM (#31059125)
Tree shaking isn't data removal, it's dead code removal.

And assuming he doesn't want what he wants is kind of in bad taste. You don't know his requirements.

Re:Using SBCL Common Lisp as a Dynamic Library by reikonomusha on Sunday April 17, 2022 @04:09AM (#31059359)
As far as I'm concerned, as a Lisp programmer, code is data. :)

Yes, and what exactly constitutes "dead code"? Tree shakers rely on heuristics that can fail in practice. There is provably no way to remove functions from a Lisp image and guarantee your application to work. LispWorks has a "tree shaker", but has umpteen options to tame it so your application doesn't inadvertently break.

Fortunately, it is possible to remove these functions if you, an application developer, so please. Nothing stops you. It's not even difficult. But SBCL has not implemented these (potentially fallible) heuristics for you, because (and only because) an insignificant number of users would find shaving a little binary size off to be valuable at the expense of program correctness.

Re:Using SBCL Common Lisp as a Dynamic Library by kazinator on Monday April 18, 2022 @12:16PM (#31072714)
In 2022, if you're linked to libc.so, it's probably substantially bigger than your Lisp image, and so that's where you'd want the tree shaking. Good luck!

The kernel supports manual tree shaking: "make menuconfig" and prune away.

Re:Using SBCL Common Lisp as a Dynamic Library by mark_l_watson on Sunday April 17, 2022 @09:55AM (#31060829)
SBCL supports saving compressed images so even without tree shaking, standalone executables are small. Not a problem.

I pay for a maintenance contract and licensing for LispWorks that does support tree shaking.