How to make small executables?

If you want to build a significantly more minimal application, then you could take the following approach:

  1. Compile your Racket program to a single, stand-alone linklet using the tools here: https://github.com/racket/racket/blob/master/racket/src/expander/README.txt#L73-L83
  2. Compile that linklet to Scheme using these tools: https://github.com/racket/racket/blob/master/racket/src/cs/README.txt#L295-L297
  3. Compile that Scheme code, along with the necessary supporting portions of the runtime, using the Chez Scheme compiler.
  4. Link the result into a boot file as described here: Using Chez Scheme

Whether this is notably smaller would depend on the size of your application and what portions of the Racket standard library and runtime system you use, as well as whether you want to preserve full Racket semantics for various operations (such as error messages).

This process won't work currently for every program (the extraction tools are designed for building the core of Racket) and is, as you can see, not automated at all. Probably you would run into some other issues that would need to be fixed as well. I would be happy to answer questions and provide advice if you wanted to go this route, and once someone does it, that would make it easier for other people to try.

3 Likes