The short answer is, not in a really satisfying way. PackageCompiler and AppBundler are the best solutions; juliac with --trim are considered experimental and come with limitations. Here’s my understanding of generally what the issues are:
- Julia has a large runtime composed of both Julia-specific code that provides much of the dynamicity, as well as a number of external dependencies packaged as dynamic libraries. If you want the whole Julia experience, you pretty much need the whole of these. PackageCompiler+AppBundler take care of collecting all of these. But it’s not going to be a small, simple, single-file exe.
- You can’t cross-compile. So, if you precompile, it has to be for the same platform. Otherwise, you basically have to ship the code and the compiler (LLVM… it’s one of those not-small dependencies), and build it on first run on the user’s target machine. Again, the excellent AppBundler will help with this when you target for another platform.
- There are also choices about the dependencies (packages) your code relies on and whether they are bundled (and similarly precompiled) or hydrated on the target machine (if possible, i.e. it’s not “air-gapped”).
juliaccompiles, but again, only to the current platform for the moment. I believe there are currently some other limitations, but this is still considered experimental.- The
--trimoption onjuliac, which will eventually be merged with PackageCompiler in some manner, as best as I can tell looks to see which of the DLL dependencies you don’t need, and drops them. It’s a sort of coarse-grained dead code elimination. - Another (still experimental) approach is to ship as an “app” managed by
Pkg: 6. Apps · Pkg.jl. Of course, your target user needs to have a full installation of Julia for this, and of course it’s not really a .exe.
As stated here, shipping binaries is not considered a “core Julia idea.” That said, as you can see, there are a number of lines of effort to offer solutions, but these will always have some limitations if you’re thinking about Julia like C or golang in this respect. While it may be possible to generate small binaries, they are only going to be small-to-distribute to the degree they don’t depend on the Julia runtime components.