There has been a JuliaCon talk about generating small binaries with juliac:
We will explain new options for ahead-of-time compilation of julia programs that we have been developing. First, there is a new compiler driver `juliac` that provides a more traditional gcc-like command-line interface. Next, we are adding new...
This brings down the binary size, but does it bring down the startup RAM usage? It’s currently more than 200 MB on Linux.
Depends on what your code is like. It can generate binaries without the Julia runtime if your code doesn’t require it, which would make the problem entirely go away. But if you need the runtime, do you need BLAS? Etc.
1 Like
Sorry it does not answer the question but where can juliac be found? I would like to try it. Thank you
nilshg
July 17, 2024, 8:19am
4
juliac
is work-in-progress and not released.
If you feel adventurous you can build this PR:
JuliaLang:master
← JuliaLang:jb/gb/static-call-graph
opened 07:46PM - 05 Jul 24 UTC
This adds a command line option `--static-call-graph` that builds images where c… ode is only included if it is statically reachable from methods marked using the new function `entrypoint`. Compile-time errors are given for call sites that are too dynamic to allow trimming the call graph (however there is an `unsafe` option if you want to try building anyway to see what happens).
The PR has two other components. One is changes to Base that generally allow more code to be compiled in this mode. These changes will either be merged in separate PRs or moved to a separate part of the workflow (where we will build a custom system image for this purpose). The branch is set up this way to make it easy to check out and try the functionality.
The other component is everything in the `juliac/` directory, which implements a compiler driver script based on this new option, along with some examples and tests. This will eventually become a package "app" that depends on PackageCompiler and provides a CLI for all of this stuff, so it will not be merged here. To try an example:
```
cd juliac
../julia juliac.jl --output-exe hello --trim exe_examples/hello_world.jl
```
When stripped the resulting executable is currently about 900kb on my machine.
Note the script calls this `--trim`, which will be the official name of this option (following similar functionality in .NET). It is not yet clear if this is identical to the internal `--static-call-graph` option, or if the latter is an implementation detail of the former.
Also includes a lot of work by @topolarity
4 Likes