[erlang-questions] Making a minimal distributable program in Erlang.
Thu Sep 21 11:00:02 CEST 2017
Yes^1000 I would very much like this to happen.
The windows version I put together was 5.5 MB in 9 files
The emulator is 3.5 MB and all the erlang code (compiled and compressed
a MB or so) - so realistically we could make an stand-along program in c. 5MB
Things like Hugo (static site generator in GO) are single file executables
- Hugo is massive 18MB on my machine (probably a lot of templates - who knows?)
I did an experiment a while back with self-modifing executables
Basicicall the structure of a executable is:
Stub 3.5 MB
Data Len bytes
Len 4 bytes
Magic 4 bytes
The Stub is always the same and gets copied from app to app.
Following the sub is the program. It's just Data (compress beam code)
Then a length counter (length of Data) then a magic number.
When Stub starts it reads itself, checks there's a magic byte on the
end, if so reads the Length of the Data, then the data and then boot's itself.
(This is how PDF files work, reading backwards from the end - it's nice
because you could always daisy-chain things on the end)
How do we write Stub? - this needs "yet another top-level program to
What you can't do is include the erlang DLL's in the Data area of the program
I think you have to statically link *everything* into the stub.
I don't know how squashable the object code is - it might be nice to compress
the object code for (Mac,Windows,Linux) and put them in the Data area
of the program, then decompress them and load them on-the-fly.
This kind of code goes way beyond my knowledge of the low-level code
needed to boot C applications.
I have a feeling it might not be a lot of code - but it's (really) tricky
So my first question is - how can I compile Erlang into a single file
executable? - I want no scripts/batch files to launch erlang no DLLs
and a statically linked binary?
On Wed, Sep 20, 2017 at 4:34 PM, Frank Muller
> Do you think it's possible to package this minimal distribution in one
> Imagine we can ship a whole release in one binary (like in Go).
> Wed 20 sept. 2017 at 16:23, Joe Armstrong <> wrote :
>> Thanks everybody for you help - I got it down to 5.5MB in 9 files
>> Relocated as follows. I've also packed/compressed the libraries
>> Here are the files that are needed
>> %% DEST/bin/erl.exe 120320 bytes
>> %% DEST/bin/start.boot 5603 bytes
>> %% DEST/erts-9.0/bin/beam.smp.dll 3346944 bytes
>> %% DEST/erts-9.0/bin/erlexec.dll 162304 bytes
>> %% DEST/erts-9.0/bin/inet_gethost.exec 45568 bytes
>> %% DEST/lib/compiler-7.1.ez 409091 bytes
>> %% DEST/lib/kernel-5.2.ez 384730 bytes
>> %% DEST/lib/sasl-3.0.4.ez 106278 bytes
>> %% DEST/lib/stdlib-3.4.ez 913013 bytes
>> This seems to work :-)
>> On Wed, Sep 20, 2017 at 2:24 PM, Dmitry Kolesnikov
>> <> wrote:
>> > Hello,
>> > On 20 Sep 2017, at 13.35, Stu Bailey <> wrote:
>> > "As an afterthought - it would be *very nice* to have a program which
>> > makes a minimal distributable program for Windows/Mac/Linux."
>> > This program is called relx.
>> > It generates a release package which are deployable to any vanilla linux
>> > or
>> > other vanilla os.
>> > The usage of Docker-image-with-Erlang complicates the process of
>> > distribution.
>> > Best Regards,
>> > Dmitry
>> erlang-questions mailing list
More information about the erlang-questions