How to build a sysimage for Windows

I built a system image on Windows 10 using Julia 1.12. But I cannot start Julia with this system image:

C:\Users\ufechner\repos\IM_AWES_bench.jl\bin>julia -J sysimage.dll
ERROR: could not load library "C:\Users\ufechner\repos\IM_AWES_bench.jl\bin\sysimage.dll"
%1 is not a valid Win32 application.
julia> versioninfo()
Julia Version 1.12.6
Commit 15346901f0 (2026-04-09 19:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × AMD Ryzen 9 7950X 16-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, znver4)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 16 virtual cores)

Any idea?

Works fine on Linux.

And yes, Windows and Julia are both 64 bit. So the error message is a bit confusing.

Any ideas how to debug?

ufechner@ufryzen:~/Shared_Windows$ objdump -f sysimage.dll 

sysimage.dll:     file format pei-x86-64
architecture: i386:x86-64, flags 0x0000013b:
HAS_RELOC, EXEC_P, HAS_DEBUG, HAS_SYMS, HAS_LOCALS, D_PAGED
start address 0x00000003a4d61320

Hmm. My one thought is do you have a msys2 environment you could work with?

I tested on Windows 11 and got the same error.

You can reproduce the problem like this:

git clone https://github.com/c-nicomar/IM_AWES_bench.jl.git
cd IM_AWES_bench.jl/bin
./install
./create_sys_image
cd ..
./bin/run_julia

Warning: Takes a long time.

If this is your main lead, then we need to create a Windows debugging environment. There are two paths, one is to use MSYS2 and use a GCC-based framework to analyze dynamic library loading.

There are also tools like WinDbg:

Essentially, we need to do the eqiuvalent of LD_DEBUG=libs. You’ll need to use gflags.exe that should come with WinDbg to enable logging of shared library loading on the Julia executable.

PackageCompiler.jl does require a C compiler, and I’m not sure which one you are using.

How big is the sysimage?

How shall I know that? I think PackageCompiler installs its own compiler as an artifact. One of the machines where I tried compiling it is quite virgin, not much on it, definitely no C compiler that I installed myself. I just installed Git for Windows, which comes with a Bash shell.

And a few months ago, this all worked fine.

ufechner@ufryzen:~/Shared_Windows$ ls -la sysimage.dll 
-rwxrwxr-x 1 ufechner ufechner 2208050613 Jul 27 23:21 sysimage.dll
ufechner@ufryzen:~/Shared_Windows$ ls -lah sysimage.dll 
-rwxrwxr-x 1 ufechner ufechner 2.1G Jul 27 23:21 sysimage.dll
const PACKAGES = [
    "ModelingToolkit",
    "OrdinaryDiffEq",
    "MakieControlPlots",
    "CSV",
    "DataFrames",
]

Is that too big?

Removing ModelingToolkit from the system image solved the problem:

This works:

const PACKAGES = [
    "OrdinaryDiffEq",
    "MakieControlPlots",
    "CSV",
    "DataFrames",
]

Size now:

ufechner@DESKTOP-USD9U6B MINGW64 ~/repos/InductionMachineDrives.jl/bin
$ ls -la sysimage.dll
-rwxr-xr-x 1 ufechner 197121 1733065543 Jul 31 20:04 sysimage.dll*
$ ls -lah sysimage.dll
-rwxr-xr-x 1 ufechner 197121 1.7G Jul 31 20:04 sysimage.dll*

This looks a bit as if there might be an upper limit of 2 GB on the size of the sysimage on Windows. If that should be the case, PackageCompiler should at least print a warning.

Any comments? Could this be fixed?

Yes, limit is 2 GB

That’s a good idea. Add compression option and warn on too big sysimage sizes on windows - Pull Request #1114 - JuliaLang/PackageCompiler.jl - GitHub should warn and also on 1.13 add the compress option that significantly reduces the size of the sysimage (but makes it slightly slower to load).

Is there also such a size limit on macOS, or is it only on Windows?

There could be something around 4GB for those but I am not 100% sure