What is `outputting sysimage file` actually doing?

it strikes me as odd that the longest step of building julia (like, from source with make) is ‘outputting’, which I think of as just writing something already in memory to disk. this step is pretty consistently the longest step, which makes me think it’s doing something other than just outputting:

Sysimage built. Summary:
Base ────────  82.924502 seconds 66.0224%
Stdlibs ─────  42.676037 seconds 33.9776%
Total ─────── 125.600575 seconds
    LINK usr/lib/julia/sysbase.so
    JULIA usr/lib/julia/sys-o.a
Collecting precompile statements
Executing precompile statements
Executed 400 precompile statements
Precompilation complete. Summary:
Total ─────── 455.682340 seconds
Outputting sysimage file...
Output ────── 823.662552 seconds
    LINK usr/lib/julia/sys.so
    JULIA stdlib/release.image

# or if there's an error:
Sysimage built. Summary:
Base ────────  83.128810 seconds 67.201%
Stdlibs ─────  40.572814 seconds 32.7989%
Total ─────── 123.701723 seconds
    LINK usr/lib/julia/sysbase.so
    JULIA usr/lib/julia/sys-o.a
Collecting precompile statements
Executing precompile statements
Executed 432 precompile statements
Precompilation complete. Summary:
Total ───────  19.288197 seconds
Outputting sysimage file...
Output ────── 195.348901 seconds
    LINK usr/lib/julia/sys.so
    JULIA stdlib/release.image

what’s it actually doing in the output step?

It’s compiling the basic system image (sys.dll in your build). The compilation engine (if you’re building from scratch) at this point is now LLVM and Julia’s own compilation machinery.

The other part of the answer is it is probably a lot slower than it should be.

Outputting is probably the wrong word, yes. It comes from the fact that the flag to generate this is --output-o. “compiling” or “generating” might be better.