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

**URL:** <https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099>\
**Category:** General Usage\
**Created:** [April 15, 2025, 2:31pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099 "2025-04-15T14:31:09Z")\
**Posts on this page:** 14\
**Page:** 3

<div class="post-metadata">

**Author:** ![uwestoehr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwestoehr/32/216201_2.png) [@uwestoehr](https://discourse.julialang.org/u/uwestoehr)\
**Post date:** [April 21, 2025, 9:23pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/41 "2025-04-21T21:23:57Z")

</div>

> [@kristoffer.carlsson](#):
>
> does that PR work for you though

No, it does not work. It only uncovers a severe issue in Julia 1.11. I write in Julia because using the same PackageCompiler version works well with the latest Julia 1.10.9 (no matter if I have the environment variable “JULIA\_NUM\_THREADS” or not), and does not work with Julia 1.11.4.

Your patch is only a hotfix to make it compile at all, but the compilation takes up to 40% longer than with 1.10 and, more important, I often get errors that some threads cannot be stopped and the compilation fails. These issues also occur with your patch.

Something is is different in Julia 1.11 or PackageCompiler needs an update for Julia 1.11. I mean that it suddenly fails if users have set JULIA\_NUM\_THREADS and even with only one thread it does no longer run stable and takes way more time. With way more time, I directly compared Julia 1.11.4 and 1.10.9 using each only one thread.

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [April 21, 2025, 9:47pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/42 "2025-04-21T21:47:10Z")

</div>

> [@uwestoehr](#):
>
> Your patch is only a hotfix to make it compile at all

I think that is @kristoffer.carlsson definition of “works”. So just to double check: independently of how long it takes to compile, it _does_ compile and the resulting file does what you need it to do. Is that correct?

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [April 22, 2025, 12:10am UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/43 "2025-04-22T00:10:37Z")

</div>

The wording isn’t the clearest and details aren’t given, but I’m pretty confident uwestoehr is saying single-threaded PackageCompiler takes longer (~40%) and often fails with errors on v1.11.4 compared to v1.10.9 for something. To broadly speculate, some third-party package developers have reported slower compilation, larger caches, or slower loading, which could be related to any of the big internal changes in v1.11 which PackageCompiler can’t directly do anything about; the silver lining is precompilation at least only has to be paid once per unique environment and there are people invested in improvements.

---

<div class="post-metadata">

**Author:** ![uwestoehr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwestoehr/32/216201_2.png) [@uwestoehr](https://discourse.julialang.org/u/uwestoehr)\
**Post date:** [April 22, 2025, 1:18am UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/44 "2025-04-22T01:18:01Z")

</div>

> [@Benny](#):
>
> uwestoehr is saying single-threaded PackageCompiler takes longer (~40%) and often fails with errors on v1.11.4 compared to v1.10.9 for something.

Exactly. During the work on my solution, I announced [in this thread](https://discourse.julialang.org/t/step-by-step-instruction-and-example-how-to-create-standalone-applications-for-windows-with-a-g-ui/128274/1).  
I performed dozens of compilations. With Julia 1.11.4 there are threading issues. You get during PackageCompilation first warnings that a thread could not be ended and in contrast to Julia 1.10 the compilation sometimes fails. And as strange as it is, this is the case no matter if I set JULIA\_NUM\_THREADS to 1 or don’t have a JULIA\_NUM\_THREADS at all. Also, you can perform the same compilation 10 times in a row and several times the compilation fails but not always and not reproducibly. I really have no clue and this kind of randomness made me crazy.

To test, [I documented](https://codeberg.org/donovaly/Juliastic/src/branch/main/Readme.md) what I did in detail. I cannot do more as I have no clue how the JIT compiler works and how threading is done. After working on this many hours, I am however, sure that the issue is somewhere in the handling of threading.

Note that Julia 1.10 also gives you kind of random threading warnings, but first after the nonincremental system image was successfully compiled and they can be ignored as the compilation eventually succeeds every time.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [April 22, 2025, 2:17am UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/45 "2025-04-22T02:17:14Z")

</div>

> [@uwestoehr](#):
>
> [I documented](https://codeberg.org/donovaly/Juliastic/src/branch/main/Readme.md) what I did in detail. I cannot do more

I think that should serve as a MWE. The only things left for reporting an issue is sharing the exact text of your `versioninfo()`, the 1.10 threading warnings, the 1.11 errors, and relevant descriptions (do they occur sporadically, randomly, condtionally, etc). The rest should be investigated by people who know PackageCompiler or Julia internals.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [April 22, 2025, 8:48am UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/46 "2025-04-22T08:48:10Z")

</div>

> [@uwestoehr](#):
>
> but the compilation takes up to 40% longer than with 1.10

Yes, we already established this, but as I said, I don’t think this has anything to do with threading. Maybe you didn’t see this because my message got moved (I think):

[https://discourse.julialang.org/t/about-julias-development-policy-regarding-windows/128011/66?u=kristoffer.carlsson](https://discourse.julialang.org/t/about-julias-development-policy-regarding-windows/128011/66)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 22, 2025, 9:23am UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/47 "2025-04-22T09:23:28Z")

</div>

> [@kristoffer.carlsson](#):
>
> except a part of the very last step in outputting the sysimage and I am not sure that even uses the number of julia threads

When generating an incremental system image on Linux, threading makes the process much faster, like 6 min instead of 10min (well, if you have enough RAM, otherwise it crashes. For me, 32GB are sufficient). On Windows multi-threading was never used because the linker does not manage to link the different files created by the different threads.

---

<div class="post-metadata">

**Author:** ![PatrickHaecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickhaecker/32/222891_2.png) [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Post date:** [April 22, 2025, 11:23am UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/48 "2025-04-22T11:23:38Z")

</div>

I [created a PR](https://github.com/JuliaLang/PackageCompiler.jl/pull/1042) to limit the single-threading to the one call where it is currently necessary.

I also [created a Julia issue](https://github.com/JuliaLang/julia/issues/58190) for fixing the last place where single-threading is needed. The latter one needs some in-depth mutex knowledge, I assume. But we have a commit which probably introduced the problem and we have a test case, so it sounds possible to hunt that bug down.  
Please have a look if you know something about these things.

---

<div class="post-metadata">

**Author:** ![PatrickHaecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickhaecker/32/222891_2.png) [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Post date:** [April 22, 2025, 12:33pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/49 "2025-04-22T12:33:48Z")

</div>

@uwestoehr: Can you please test whether the compilation takes still longer with the [fix from the PR](https://github.com/JuliaLang/PackageCompiler.jl/pull/1042)?

You can apply the fix (temporarily) manually in the `packages` directory of your Julia installation (sorry, I don’t know where that is located on Windows (just to prove your point from above ;-))).  
Alternatively, you can point Julia’s package manager to `add https://github.com/PatrickHaecker/PackageCompiler.jl#fix_hang_multiple_threads`.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [April 22, 2025, 2:00pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/51 "2025-04-22T14:00:05Z")

</div>

> [@ufechner7](#):
>
> When generating an incremental system image on Linux, threading makes the process much faster,

This parallelism is controlled by `JULIA_IMAGE_THREADS` ([Environment Variables · The Julia Language](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_IMAGE_THREADS)), which claims:

> If left unspecified, the smaller of the value of [`JULIA_CPU_THREADS`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_CPU_THREADS) or half the number of logical CPU cores is used in its place.

So, unless you specify `JULIA_CPU_THREADS`, I don’t think the number of julia threads should influence this.

---

<div class="post-metadata">

**Author:** ![uwestoehr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwestoehr/32/216201_2.png) [@uwestoehr](https://discourse.julialang.org/u/uwestoehr)\
**Post date:** [April 22, 2025, 10:46pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/52 "2025-04-22T22:46:43Z")

</div>

> [@PatrickHaecker](#):
>
> Can you please test whether the compilation takes still longer with the [fix from the PR](https://github.com/JuliaLang/PackageCompiler.jl/pull/1042)?

@kristoffer.carlsson , @PatrickHaecker , I made now a brief test:

- on a laptop that is used only for office purposes, thus should have a clean Windows 10
- Julia was uninstalled, all its traces cleaned, then computer restarted, then Julia was installed using the standalone official installer.
- Before PackageCompile was executed, I only added “PackageCompiler” and Distributions"
- For the test I used the module of “Juliastic”: [Is linear and HEAD.](https://codeberg.org/donovaly/Juliastic/src/branch/main/src/Juliastic.jl)
- for the precompilation, this file: [Change, you can set the number of hexadecimal digits is replaced with the --template option.](https://codeberg.org/donovaly/Juliastic/src/branch/main/build/precompilation.jl)
- the command for the Julia REPL is:

```julia-auto
lib_input_path= "D:\\Julia\\Juliastic"
cd(lib_input_path)
using PackageCompiler
lib_name= "Juliastic"
lib_output= joinpath(lib_input_path, "CompilationResult")
precomp_file= joinpath(lib_input_path, "build", "precompilation.jl")
lib_header= joinpath(lib_input_path, "build", lib_name * ".h")
create_library(lib_input_path, lib_output;
 incremental= false, force= true, filter_stdlibs= true, lib_name= lib_name,
 precompile_execution_file= precomp_file,
 header_files= [lib_header])

```

### At first Julia 1.10.9

- The CPU has 12 threads, so I set JULIA\_NUM\_THREADS to 12.

result: compilation works, total time 363 seconds, here a screen shot with all details. Note the warnings about threads.

 ![julia_alkBRh0Ftg](https://global.discourse-cdn.com/julialang/original/3X/9/d/9daab13380fd317be9cc35ec036d0df6e90b0c84.png)

### 1.11.5

- JULIA\_NUM\_THREADS to 12

result: compilations hands (the bug why we have this discussion), but see the screenshot with the compilation times:

Step 1: 79% longer  
Step 2: 30% longer

 ![julia_5HcC6QIXcs](https://global.discourse-cdn.com/julialang/original/3X/d/f/df1df262a722360df46ba6a60e265a499b843cfd.png)

### 1.11.5 with patch

- JULIA\_NUM\_THREADS to 12
- I applied [Fix hanging system image creation if multiple threads are set - Pull Request #1042 - JuliaLang/PackageCompiler.jl - GitHub](https://github.com/JuliaLang/PackageCompiler.jl/pull/1042)

result: compilation works, total time 593 seconds, here a screen shot with all details. Note that there are now no warnings about threads.  
But the compilation time increased by 63 %

 ![julia_9ucXdjEgO0](https://global.discourse-cdn.com/julialang/original/3X/a/f/af27a623c142c4953d3875ec8bc97a52a4401f31.png)

So the patch makes it compiling, but the performance loss with 1.11.x is severe.

---

<div class="post-metadata">

**Author:** ![uwestoehr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwestoehr/32/216201_2.png) [@uwestoehr](https://discourse.julialang.org/u/uwestoehr)\
**Post date:** [April 22, 2025, 10:50pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/53 "2025-04-22T22:50:27Z")

</div>

> [@kristoffer.carlsson](#):
>
> If you turn off threading, does 1.10 also become 40% slower?

No. The difference is only 5 seconds, so for me 368 s instead of 363 s. And you are right, the multithreading is actually only used when the packages are precompiled.

BUT, Julia 1.11.5 compiles the same module via PackageCompiler 63 % slower than Julia 1.10.9, see my [detailed test here](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/52).

---

<div class="post-metadata">

**Author:** ![PatrickHaecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickhaecker/32/222891_2.png) [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Post date:** [April 23, 2025, 5:54am UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/54 "2025-04-23T05:54:24Z")

</div>

Thanks for the detailed experiment and the great writeup. Thanks also for creating [[regression] Julia 1.11 needs 60 % more compile time than Julia 1.10 with PackageCompiler 2.2 · Issue #58201 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/58201). As all steps besides the last one are unaffected by [Fix hanging system image creation if multiple threads are set by PatrickHaecker · Pull Request #1042 · JuliaLang/PackageCompiler.jl · GitHub](https://github.com/JuliaLang/PackageCompiler.jl/pull/1042) this is indeed a Julia and not a `PackageCompiler.jl` issue.

This means the PR should probably be integrated. @kristoffer.carlsson I Think you have the permissions to do so. Could you pleas have a look?

The long build times are also annoying for us (in the company I work for). But as the development where fast iterations are necessary works without `PackageCompiler.jl` they are only that: annoying, but not really expensive.

Therefore, we don’t have a business incentive to invest into making it faster. My impression from looking at the code and its history is that this is the same for others, too. @kristoffer.carlsson has done a tremendous job with creating and maintaining `PackageCompiler.jl` together with the community, but it does look like it was never really a focus topic for a longer time (which is only natural with so much on the plate).

The run-time of `PackageCompiler.jl` could be reduced by more than a factor of two by [caching some of the artefacts](https://github.com/JuliaLang/PackageCompiler.jl/issues/916) and I am pretty sure there is even more optimization potential when going down the rabbit hole. However, I guess people will mostly focus on the `--trim` feature in 1.12 and beyond.

Does your company, @uwestoehr, have a relevant business incentive for fast compilations and the possibility to pay someone improving `PackageCompiler.jl` or `--trim`? I assume more hands would be more than welcome. Otherwise I think we need to be thankful for all the great work people in the community do and try to help out whenever we have some time to spare.

---

<div class="post-metadata">

**Author:** ![uwestoehr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwestoehr/32/216201_2.png) [@uwestoehr](https://discourse.julialang.org/u/uwestoehr)\
**Post date:** [April 23, 2025, 10:45pm UTC](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099/55 "2025-04-23T22:45:37Z")

</div>

> [@PatrickHaecker](#):
>
> Does your company, @uwestoehr, have a relevant business incentive for fast compilations and the possibility to pay someone improving `PackageCompiler.jl` or `--trim`?

At first I have to convince the team that my approach to use neuronal nets can improve the overall performance of the sensors. And then to prove that my idea to use Julia’s FluxML, compile the Julia code to a DLL and then use it for a UI actually works.  
As of now I don’t know if my idea will work.

[Previous page](https://discourse.julialang.org/t/packagecompiler-hangs-while-compiling-nonincremental-system-image-on-julia-v1-11/128099.md?page=2)
