How to re-trigger pre-compilation

Hello,

I need to re-create the .ji files of my user modules
each time I updated my custom sys image.

I am using a script to create the custom sys image and
I suggest the users of my software to run it again each
time the have pulled a new software version.

If the sys image has changed, but the source code of
my user modules did not change, the compiled .ji files
do not work any more and the startup time of my app
is way higher then normal.

So I want to automatically re-create the .ji files
at the end of the script that creates the user image.

This is easy on Linux:

rm -rf ~/.julia/compiled/v1.6/*.ji

as long as you know the julia version, but it will not
work for example on Windows.

Is there better way to force the re-creation of the .ji
files for user modules?

Uwe

would it work to condition on the OS ? See here.

if Sys.iswindows()
    windows_specific_thing(a)
end

I have no idea where .ji files are stored on Windows…

There must be a mechanism in Julia base that allows to invalidate a module, because this happens automatically when you change its source code and re-load it. How can I trigger this mechanism manually?

I have this function that when run will force pre-compilation on next fresh julia session. It’s meant for a single package but you can extend it for more.

force_precompile() = Sys.iswindows() ? run(`cmd /c copy /b "$(pathof(GMT))" +,, "$(pathof(GMT))"`) : run(`touch '$(pathof(GMT))'`)
1 Like

Well, the touch command is also available on Linux. So I use the following lines now in my script that creates a new system image to force pre-compilation of the user modules:

cd src
touch *.jl # make sure all modules get recompiled in the next step
cd ..
julia --project -J MakieSys.so -e "push!(LOAD_PATH,joinpath(pwd(),\"src\"));using Utils, KCU_Sim, KPS3, Plot2D, RTSim"

This should also work on git-bash which I use on Windows.