PackageCompiler - reduce system image

I was looking at the doc of PackageCompiler but couldn’t find the information I was looking for.
Is there options to strip metadata, ir, documentation, some standard libraries…etc from the system image when building a system image?
If yes, can someone provide an example?
Thank you

Strip metadata/ir: see

strip standard libraries: see PackageCompiler docs here:

(in particular:

filter_stdlibs::Bool: If true, only include stdlibs that are in the project file. Defaults to false, only set to true if you know the potential pitfalls.



Note, you need Julia 1.9 (which has release candidates, but should be out in hours, if not days). And you likely want to use --strip-metadata too, and possibly delete LLVM (which is largest), and maybe more dependencies.

I’m writing for small apps, more than maybe smaller sysimage. The sysimage doesn’t seem like as much of a deal any more with pkgimages. See also, if still as relevent:


Thanks to both. Where do I pass --strip-metadata? When I launch julia? Can pass --strip-ir as well? How do I delete LLVM?
Thanks again.

I guess:

using PackageCompiler
create_sysimage(:SimplePkg, sysimage_path="", precompile_execution_file="scratch.jl", sysimage_build_args=`--strip-ir --strip-metadata`)

I saw this in the linked thread, only added --strip-metadata. And it (both) off the screen to the right, so easy to miss.

You can see LLVM in the generated app, an .so file, or .dll (on Windows) etc. Likely lower case If you’re just making a sysimage, then this doesn’t apply; do not delete your main Julia LLVM…! :slight_smile:

1 Like

After building some system images (which takes a lot of time), here is what works for me :

  • sysimage_build_args = --strip-metadata this produce the smallest system image for me (225MB)
  • sysimage_build_args = --compile=all --strip-metadata --strip-ir produce 297MB, --compile=all is important otherwise it does not work.
  • sysimage_build_args = --compile=all --strip-metadata --strip-ir + filter_stdlibs=true + incremental=false produce 266MB.

Thank you for your help on this.

1 Like