# Statically compiled and statically linked

**URL:** <https://discourse.julialang.org/t/statically-compiled-and-statically-linked/12290>\
**Category:** General Usage\
**Created:** [July 10, 2018, 12:23pm UTC](https://discourse.julialang.org/t/statically-compiled-and-statically-linked/12290 "2018-07-10T12:23:12Z")\
**Posts on this page:** 1\
**Showing post:** 33

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [September 1, 2020, 5:18pm UTC](https://discourse.julialang.org/t/statically-compiled-and-statically-linked/12290/33 "2020-09-01T17:18:26Z")

</div>

> [@Mayank\_Gupta](#):
>
> I wasn’t saying Julia doesn’t support static compilation.

Yes, and no. If all your types are known you can compile to (even small, in theory) binaries, but in general you can’t! I mean, in general, the binary needs to include the compiler (and/or interpreter).

Think of the function:

```julia
mul(a, b) = a * b

```

Do you want to compile only for the integers, or floating point, or string concatenation or the infinite possible types, as Julia is generic? In general you could `@eval` at runtime, and solving this runs into the halting problem, theoretically not possible. Restricted Julia without being limited to being generic is still as powerful as e.g. C (you could e.g. type all your functions).

> [@What's actually inside precompiled Julia files?](https://discourse.julialang.org/t/whats-actually-inside-precompiled-julia-files/28234/2):
>
> Actually, many types are known when the module is loaded — any functions that are called during module initialization, along with any function for which [precompile](https://docs.julialang.org/en/latest/base/base/#Base.precompile) is called. The [SnoopCompile package](https://github.com/timholy/SnoopCompile.jl) can automatically generate precompile statements for functions that are called during a program execution. My understanding is that it’s currently the lowered+type-inferred code, plus the values of global variables (e.g. const foo = ...some expensive function...). When a precompiled module is …

---

_[View the full topic](https://discourse.julialang.org/t/statically-compiled-and-statically-linked/12290)._
