# Static Compilation in Julia

**URL:** https://discourse.julialang.org/t/static-compilation-in-julia/124416
**Category:** New to Julia
**Tags:** question
**Created:** [January 3, 2025, 5:35pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416 "2025-01-03T17:35:44Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![leviathan](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@leviathan](https://discourse.julialang.org/u/leviathan)
#### Post date: [January 3, 2025, 5:35pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/1 "2025-01-03T17:35:44Z")

</div>

Hello all, I am new to Julia, and I am planning to develop some projects with the language in my own free time. Reading the docs, I saw that Julia is a JIT language, as such it does not natively support AOT compilation. However, I’ve also seen two major packages for static compilation to a binary. With the ongoing development to support static compilation, is a full-fledged compiler a future feature I can expect? Or rather, is the focus on developing support for static compilation via packages such as those.

---

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [January 3, 2025, 6:00pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/2 "2025-01-03T18:00:49Z")

</div>

Here’s a nice talk on the current state of the art and the direction things are going for AOT compilation of julia: [https://www.youtube.com/watch?v=R0DEG-ddBZA](https://www.youtube.com/watch?v=R0DEG-ddBZA)

---

<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: [January 3, 2025, 7:19pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/3 "2025-01-03T19:19:23Z")

</div>

It depends a bit on your goal. Very small programs can already be statically compiled using [GitHub - tshort/StaticCompiler.jl: Compiles Julia code to a standalone library (experimental)](https://github.com/tshort/StaticCompiler.jl), but you will lack a lot of language features.

Larger projects can also be AOT compiled (well, a few packages might fail, but it mostly works) using PackageCompiler.jl But you end up with large binaries, for a GUI program at least 300 MB for example. My main program that uses 500 packages compiles to 1.3 GB. Julia 1.12 will provide the option to create smaller binaries, but again with some limitations of the language features that you can use.

Cross compilation is another feature that is still missing, but planned, and there are some work-arounds.

---

<div class="post-metadata">

### Author: ![leviathan](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@leviathan](https://discourse.julialang.org/u/leviathan)
#### Post date: [January 3, 2025, 7:50pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/4 "2025-01-03T19:50:26Z")

</div>

Thank you very much, I appreciate it!

---

<div class="post-metadata">

### Author: ![leviathan](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@leviathan](https://discourse.julialang.org/u/leviathan)
#### Post date: [January 3, 2025, 7:57pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/5 "2025-01-03T19:57:56Z")

</div>

Thank you for your response, would I be correct in supposing that it is something that it is being actively working on and likely to see improvements upon as the year progresses? On your point about limitations of the language features you can use; is that something that will be worked upon over time as well? I am looking to build a GUI application for myself, so the latter package would be more applicable to be.

---

<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: [January 3, 2025, 8:14pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/6 "2025-01-03T20:14:44Z")

</div>

> [@leviathan](#):
>
> On your point about limitations of the language features you can use; is that something that will be worked upon over time as well?

To some degree this cannot be improved: If you want to use a garbage collector, you need to include the code of the garbage collector which increases the binary size. Not much we can do about it.

If you do not know all combinations of types with which a function can be called you have to include the compiler in your binary, which increases the size a lot. Again not much we can do about.

You want to have an easy life → large binaries  
You need small binaries → you need to invest more time and effort

Your choice. Well, at least when Julia 1.12 is released, for now it will in many cases not be possible to achieve small binaries.

---

<div class="post-metadata">

### Author: ![leviathan](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@leviathan](https://discourse.julialang.org/u/leviathan)
#### Post date: [January 3, 2025, 8:19pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/7 "2025-01-03T20:19:09Z")

</div>

This has been really helpful for me, thank you for your help!

---

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [January 3, 2025, 8:43pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/8 "2025-01-03T20:43:49Z")

</div>

Here’s an example of static compilation, adapted from the [instructions here](https://jbytecode.github.io/juliac/). A small program requiring GC compiles to 18 MB on my Linux machine (libc x86\_64).

First, I install the Julia nightly channel:

```
#> juliaup add nightly

```

Then I cloned the Julia git repo to get the juliac scripts:

```
#> git clone https://github.com/JuliaLang/julia.git

```

Here’s a small program `try.jl` which stores the squares of the numbers 1, 2, … ,100 into a dictionary (GC is needed for this data structure). Then it prints out the value for the key 10.

```julia
module Try

Base.@ccallable function main()::Cint
    square_dict = Dict(i => i^2 for i in 1:100)
    println(Core.stdout, square_dict[10])
    return 0
end

end # End of module Try

```

I compile the program with

```
#> julia +nightly julia/contrib/juliac.jl --output-exe try --experimental --trim try.jl

```

This took about 22 seconds and produced the binary `try` with a size 18 MB. Executing the produced binary took about 37 milliseconds.

```
#> time ./try
100

real	0m0.037s
user	0m0.014s
sys 0m0.027s

```

P.S. since this is experimental stuff, it goes without saying that the information could become outdated very quickly.

---

<div class="post-metadata">

### Author: ![Domenico\_Lahaye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/domenico_lahaye/32/203728_2.png) [@Domenico\_Lahaye](https://discourse.julialang.org/u/Domenico_Lahaye)
#### Post date: [January 3, 2025, 9:15pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/9 "2025-01-03T21:15:16Z")

</div>

Not sure to what extend [https://www.youtube.com/watch?v=4CV5SG3OLMw](https://www.youtube.com/watch?v=4CV5SG3OLMw) is adding value here.

---

<div class="post-metadata">

### Author: ![Thomas008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thomas008/32/204169_2.png) [@Thomas008](https://discourse.julialang.org/u/Thomas008)
#### Post date: [November 20, 2025, 6:41pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/10 "2025-11-20T18:41:36Z")

</div>

I tried to use StaticCompiler for julia versions higher than 1.10, but it still does not work.  
[https://github.com/tshort/StaticCompiler.jl/issues/166](https://issue166)  
[https://github.com/tshort/StaticCompiler.jl/issues/177](https://issue177)

I’d like to know, whether there is still interest in using StaticCompiler at all, since juliac came up?

I thought, StaticCompiler has still some advantages, e.g. the binary for around 1000 lines of code is in the range of 200 kB, instead of 2 MB.

---

<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: [November 20, 2025, 10:36pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/11 "2025-11-20T22:36:11Z")

</div>

StaticCompiler never really had much interest to begin with. It doesn’t support much of idiomatic Julia and its features are specifically extended by StaticTools. Leaving the interactive Julia world to do the same things in C/C++ opens up a huge ecosystem.

---

<div class="post-metadata">

### Author: ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)
#### Post date: [November 30, 2025, 2:10pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/12 "2025-11-30T14:10:02Z")

</div>

This video is from Sep 2024. Could someone comment whether it still represents the state of the art as of Nov 2025?

---

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [November 30, 2025, 2:30pm UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/13 "2025-11-30T14:30:16Z")

</div>

The current state is that v1.12 is now released, so the mechanisms discussed in that video are now available as experimental features in the latest release.

The preferred API for compiling using these new mechanisms is through the JuliaC.jl package / App.

---

<div class="post-metadata">

### Author: ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)
#### Post date: [December 1, 2025, 7:59am UTC](https://discourse.julialang.org/t/static-compilation-in-julia/124416/14 "2025-12-01T07:59:50Z")

</div>

> [@Thomas008](#):
>
> I’d like to know, whether there is still interest in using StaticCompiler at all, since juliac came up?

I find it attractive. I’d even argue it should have been the short / mid term path solution for binaries.  
I find it as a better choice to have MATLAB Coder alternative.
