How to create a pre-compiler Julia image from C to reduce init time?


I’ve been working on integratring Julia with Nim on GitHub - Clonkk/nimjl: A bridge between Nim-lang and Julia ! and I’d like to be able to save pre-compiled image and load them at start-up.

For that I’m hoping to be able to use the function jl_save_system_image and jl_init_with_image, but I can’t seem to write a Julia compiled image from C and documentation is sparse on this topic.

I tried a simple code to creat an image with LinearAlgebra (just a dummy example) :

jl_eval_string("using LinearAlgebra"); 

But this segfault :

signal (11): Segmentation fault
in expression starting at none:0
__memmove_sse2_unaligned_erms at /lib64/ (unknown line)
_write_grow at /buildworker/worker/package_linux64/build/src/support/ios.c:249 [inlined]
ios_write at /buildworker/worker/package_linux64/build/src/support/ios.c:412
jl_write_values at /buildworker/worker/package_linux64/build/src/staticdata.c:888 [inlined]
jl_save_system_image_to_stream at /buildworker/worker/package_linux64/build/src/staticdata.c:1563
jl_save_system_image at /buildworker/worker/package_linux64/build/src/staticdata.c:1650
1 Like