PackageCompiler hangs while compiling nonincremental system image on Julia v1.11

After many hours of trying I found the solution and the bug in PackageCompiler.

At first the step by step instruction:

  1. Assure that the python.exe is in the PATH environment variable (either the one of the current user or the system-wide one)
  2. Assure that you don’t have a Julia thread setting as environment variable, so there must not be an environment variable called JULIA_NUM_THREADS
  3. Start Julia and change to the source directory, for example: cd("D:\\Julia")
  4. Execute using PackageCompiler
  5. Execute this command:
create_library("MyLib", "MyLibCompiled";
                lib_name="libinc",
                precompile_execution_file="D:\\Julia\\MyLib\\build\\generate_precompile.jl",
                precompile_statements_file="D:\\\Julia\\MyLib\\build\\additional_precompile.jl",
                header_files = ["D:\\Julia\\MyLib\\build\\mylib.h"])

whereas “MyLib” is the name of the subfolder of “D:\Julia” (so “D:\Julia\MyLib”), “LyLibCompiled” will become a new folder with the compilation results. “libinc” will be the name of the created library (“libinc.dll”). For the statements of precompile_execution_file etc. take the skeleton of the files and file structure given in the examples folder of the PackageCompiler docs.

The bug making PackageCompiler failing

Since my application are neuronal networks and the computation time reduces a lot when using multiple of the CPU threads, I use the environment variable JULIA_NUM_THREADS
But if this is set, no matter to what value, PackageCompiler runs forever, not creating any library or app and you also get no information why it fails.

8 Likes