# Questions about Julia Compilation Optimization Levels

**URL:** https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296
**Category:** Performance
**Created:** [May 31, 2018, 5:25pm UTC](https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296 "2018-05-31T17:25:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jinliangwei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jinliangwei/32/1929_2.png) [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)
#### Post date: [May 31, 2018, 5:25pm UTC](https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296/1 "2018-05-31T17:25:50Z")

</div>

I couldn’t find documentation on optimization flags. Is there such a documentation?

I know one can pass optimization flags (e.g. `O0`) when calling Julia. Is this `O0` the same as Clang’s `O0`?

What is the default optimization level that Julia uses?

If I am embedding Julia inside C or C++, how would I control Julia’s optimization level?

---

<div class="post-metadata">

### Author: ![Impressium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/impressium/32/19575_2.png) [@Impressium](https://discourse.julialang.org/u/Impressium)
#### Post date: [March 19, 2020, 3:56pm UTC](https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296/2 "2020-03-19T15:56:33Z")

</div>

Did you find an answer yet?

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [March 19, 2020, 4:05pm UTC](https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296/3 "2020-03-19T16:05:43Z")

</div>

Julia’s O0 has no relation to any C compiler O0 other than that it has the same goal of less compile time in exchange for more runtime. I’m not aware of anywhere where all the differences are laid out, but it’s basically just that O3 infers more and runs some extra compiler passes.

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [March 19, 2020, 4:15pm UTC](https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296/4 "2020-03-19T16:15:38Z")

</div>

In Julia 1.3.1, the LLVM optimization passes are listed in [jitlayers.cpp](https://github.com/JuliaLang/julia/blob/v1.3.1/src/jitlayers.cpp), while on master they’re given in [aotcompile.cpp](https://github.com/JuliaLang/julia/blob/master/src/aotcompile.cpp).

Basically the only difference between `-O2` and `-O3` as far as I can tell is that `-O3` adds a basic alias analysis pass.

`-O2` is the default.
