Could Someone Explain To Me the Desire for Small Julia Binaries?

One aspect that hasn’t been mentioned so far, and that to me is a reason why I don’t think it’s just 30-1000 LOC change with pkgimages like @tim.holy thinks, is cross compilation. In essence, cross compilation means compiling a program for an architecture other than the one where the compiler is running. Currently, all julia compilation happens under the assumption that the code will run on the same machine as the compiler itself - PkgCompiler and StaticCompiler weaken that assumption a bit, to only assume the same computer architecture (i.e. x86_64 or ARM for example). In order to compile for e.g. Mac M1, we need a bootstrapped julia install capable of running on that M1, to compile a sysimage and subsequently packages & pkgimages.

GPUCompiler breaks that assumption a bit, since we don’t actually have a julia runtime & compiler running on the GPU itself, it’s all compiled on the CPU and then sent to the GPU for execution. In fact, GPUCompiler goes to great lengths to remove remaining bits of those assumptions from the LLVM IR julia spits out. This ~mostly works, but you can very easily run into issues with pointersizes and some other assumptions that happen in the compilation pipeline that make actual crosscompilation (currently) infeasible (some experiments to the contrary not withstanding).

Now, you may say that static compilation is easier or different to cross compilation and thus should be easier, and you’d be right, but only to an extent - the compiler still assumes that the final artifact will run on the same machine during codegen and optimization, and thus targetting a different microarchitecture for e.g. deployment (think a server that has a different x86 CPU with different features than your development machine) is shaky at best. Static compilation to the host system is thus a special case of cross compilation and I think it would be a mistake to first tackle the special case here in julia itself without planning ahead on how to get cross compilation (which, truth be told, I very much see as the desirable endgame).

I do have a list of some of the issues I encountered so far in playing around in this domain, but this post is unfortunately too small to hold it :slight_smile:

18 Likes