I’m learning PackageCompiler.jl, and I’m wondering why creating a sysimage requires an input of packages, the project/environment, and precompile scripts. I do appreciate the paper trail, but couldn’t a sysimage be created from a session on the fly, like calling
savesessionto(file) in the REPL?
This thread gave me the impression that such a session snapshot is possible and actually done for base Julia. However, I read issue #22598 from 2017 that “it seems to be technically nearly impossible to do this because of the large amount of program state which cannot be persisted or restored across processes.” Is that still true? If so, how does PackageCompiler manage to do it with the aforementioned stipulations? If not, why isn’t
savesessionto standard issue?
I spent a small amount of time a while ago trying to make this work.
Here’s my WIP rebased: add exit_save_sysimage · IanButterworth/julia@454090a · GitHub
One of the issues I came up against, IIUC, was that the output process needs all tasks to be finished. This was crashing during serialization of active tasks.
It might be worth giving it a go to see what it hits.
% ./julia --startup-file=no -e 'Base.exit_save_sysimage("f.so")'
[ Info: Julia exiting. A sysimage will be generated at "/Users/ian/Documents/GitHub/julia/f.so"
ERROR: Task cannot be serialized
@ ./initdefs.jl:28 [inlined]
@ ./initdefs.jl:29 [inlined]
@ Base ./output.jl:14
 top-level scope
Here is a list of sources of global state separate-compilation.md · GitHub