Page 1 of 1

Static compiling newlisp for portable binaries

Posted: Fri Jan 27, 2017 1:13 pm
by TedWalther
Has anyone tried to compile newlisp statically for use on Linux or other Unix? It may work on BSD and Mac OSX, I haven't tried. However, the problem is always the resolver. If you use any network functions in the program, you simply cannot get a static binary.

What is a static binary? A static binary is one where all the libraries are compiled into one file together with your program. So you can grab the executable file and dump it on any machine and it will run, without worrying about installing the right versions of libraries.

I looked up the problem today to see if it had a fix yet, and found this article:

http://www.macieira.org/blog/2012/01/so ... -on-linux/

Amazing read. I didn't realize that Linux (and GNU) have broken things so badly. If you link your programs to libraries, there are lots of optimizations that are missed, and lots of code is done sub-optimally. A lot of function calls have to go through 2 levels of indirection.

I wish there was more documentation like this, where people explain what is happening at the assembly language level. It isn't that complicated, once someone actually shows you the important bits.

Has anyone else figured out how to static link newlisp on Linux?

Re: Static compiling newlisp for portable binaries

Posted: Fri Jan 27, 2017 1:39 pm
by TedWalther
I tested a simple socket program on OpenBSD, and static linking works fine. So this is a Linux issue. The solution is to use a different version of libc. The MUSL version looks pretty good. I'll need to test it with newlisp soon to confirm it provides everything newlisp needs.

https://www.musl-libc.org/