How to compile static single file newLisp binary?

Started by vetelko, January 15, 2025, 01:51:33 AM

Previous topic - Next topic

vetelko

Hi guys, can anyone help me out? Is it possible to compile newlisp statically so I don't have to copy all dependency libraries from /usr/lib/... into the chroot? I need single big fat binary :)

I think Ted Walther mentioned in one of his posts that he managed to do it on OpenBSD (which is also my system). But he doesn't explain how :)
newLISP v.10.7.6 64-bit on BSD IPv4/6 UTF-8 libffi

rrq

The steps I take are basically to
1. first create the makefile_build the normal way and then
2. copy that to a makefile_static file which I hand-edit:
3. remove -DFFI -DREADLINE (see below) from the CFLAGS setup
4. change the "default:" target action to be the two steps
  $(CC) $(OBJS) -m64 -o newlisp -static -Wl,-Bstatic -lm -lc
  strip newlisp

That's with gcc on a linux amd64 (devuan). I've got libc.a and libm.a from the libc6-dev package, and I don't include the FFI and READLINE options for it. Thoug I think you can find .a libraries for them too (libreadline-dev and libffi-dev packages)

EDIT: digging up that old project, I realized it needed musl-gcc as well; gcc doesn't seem to be capable of static binaries.

EDIT: maybe I confused myself; it seems gcc does it well too, and then you may also include ffi and readline (+termcap).

vetelko

newLISP v.10.7.6 64-bit on BSD IPv4/6 UTF-8 libffi