# What is the difference between switch --compile=yes & --compile=all for AOT?

**URL:** <https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608>\
**Category:** General Usage\
**Tags:** question, compilation\
**Created:** [January 26, 2018, 8:39am UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608 "2018-01-26T08:39:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 26, 2018, 8:39am UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/1 "2018-01-26T08:39:45Z")

</div>

I using the perfect repository [Julia AOT compiler](https://github.com/JuliaComputing/static-julia), but I have questions about switch

> –compile={yes|no|all|min} Enable or disable JIT compiler, or request exhaustive compilation

I have no idea what this does. I suspect that with `yes` it is AOT and with `all` static compiled Julia. Is it correct?

---

<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:** [January 26, 2018, 10:19am UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/2 "2018-01-26T10:19:17Z")

</div>

EDIT: Since even Karpinski said “–compile={yes|no|all|min} – I have no idea what this does, despite reading julia --h” in the issue I posted below, I’m not even going to guess (again) and take my original with a grain of salt:

Does this for sure apply for julia **c**? I didn’t see it in the README (and haven’t tried juliac).

This allies to julia, see julia --help, you get different options. Did you just mistype? There it simply controls the optimizer I think, e.g. you get an interpreter(?) that’s slower, but faster to start up.

See also e.g.: -O option.

---

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 26, 2018, 12:11pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/3 "2018-01-26T12:11:42Z")

</div>

This option is in

> Base.julia\_cmd()

I think that my question is clear. What is the difference between switch –compile=yes & –compile=all ?  
When I compiled with `yes` I get libhello.so 49MB, but with `all` 98MB. In runtime I get 4 times better time with switch `–compile=all`.

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [January 26, 2018, 12:34pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/4 "2018-01-26T12:34:19Z")

</div>

While we are on the subject, does anybody manage to run compiled programs on OS X ? For me they segfault as soon as the [gc is used](https://github.com/JuliaComputing/static-julia/issues/34).

---

<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:** [January 26, 2018, 1:07pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/5 "2018-01-26T13:07:36Z")

</div>

Googling the option (and searching in the Docs) found this:

[https://github.com/JuliaLang/julia/issues/23054](https://github.com/JuliaLang/julia/issues/23054)

[and nothing of interest in Docs; as the option has been hidden in master.]

[https://github.com/JuliaLang/julia/blob/master/src/jloptions.c](https://github.com/JuliaLang/julia/blob/master/src/jloptions.c)

[https://github.com/JuliaLang/julia/issues/15864](https://github.com/JuliaLang/julia/issues/15864)

---

<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:** [January 26, 2018, 1:15pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/6 "2018-01-26T13:15:00Z")

</div>

> [@Martin\_Florek](#):
>
> > Base.julia\_cmd()
> 
> I think that my question is clear.

Probably it was (you just confused me with involving the question with the package), see my other post, and edited my first post. Aslo note Base.julia\_cmd() is about JIT, not AOT package that came later; but the option may also apply to it, I’m just not sure if/how.

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [January 26, 2018, 11:13pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/7 "2018-01-26T23:13:20Z")

</div>

> [@Martin\_Florek](#):
>
> I have no idea what this does. I suspect that with yes it is AOT and with all static compiled Julia. Is it correct?

`--compile=no` turns off the JIT compiler (on 0.6 you then get an error if a method is not available in the system image, on 0.7 it’ll run in the interpreter)  
`--compile=yes` is the default  
`--compile=all` is a more-agressive version of `--compile=yes`, that also compiles a bunch of fallbacks and specializations you didn’t call (and if you’re building a system image thus get cached as a result). Thus `--compile=all` is useful to build a system image that will later be used with `--compile=no` (like in an AOT compile).

---

<div class="post-metadata">

**Author:** ![JaredCrean2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredcrean2/32/3574_2.png) [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)\
**Post date:** [January 26, 2018, 11:33pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/8 "2018-01-26T23:33:36Z")

</div>

Is it possible to give hints to `--compile=all` about what methods to compile? For example, I have a lot of functions that look like

```julia
function myfunc(q::AbstractVector, qg::AbstractVector, coords::AbstractVector, res::AbstractVector)

```

where each `AbstractVector` is usually either an `Array` or a view of an array. I was thinking about writing a script to generate the appropriate precompile statements, but is there some machinery behind `--compile=all` that I could hook into?

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [January 26, 2018, 11:35pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/9 "2018-01-26T23:35:01Z")

</div>

Not really, `precompile` is the best way if you want to generate extra specializations. `--compile=all` mostly generates definitions on e.g. abstract types that you wouldn’t usually need if you had the compiler because you could just conjure up a specialization on the fly.

---

<div class="post-metadata">

**Author:** ![lucatrv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucatrv/32/5650_2.png) [@lucatrv](https://discourse.julialang.org/u/lucatrv)\
**Post date:** [January 27, 2018, 7:45pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-switch-compile-yes-compile-all-for-aot/8608/10 "2018-01-27T19:45:04Z")

</div>

I am adding support for `--compile` to [static-julia](https://github.com/JuliaComputing/static-julia).
