# Precompilation of Module

**URL:** <https://discourse.julialang.org/t/precompilation-of-module/91383>\
**Category:** General Usage\
**Created:** [December 7, 2022, 6:46pm UTC](https://discourse.julialang.org/t/precompilation-of-module/91383 "2022-12-07T18:46:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [December 7, 2022, 6:46pm UTC](https://discourse.julialang.org/t/precompilation-of-module/91383/1 "2022-12-07T18:46:24Z")

</div>

I am working in VSC (Visual Studio Code) and added `ModelingToolkit.jl` to the packages. All went well, and then I typed `using ModelingToolkit`, and all was good. Then I went to a different window, and started up Julia on the terminal command line (on Mac Ventura) and executed Julia with --check\_bounds=yes. What was strange is that `ModelingToolkit` got precompiled. Why would that happen? Thanks.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 7, 2022, 9:26pm UTC](https://discourse.julialang.org/t/precompilation-of-module/91383/2 "2022-12-07T21:26:29Z")

</div>

`check_bounds=yes` may have forced recompilation. Otherwise, anything that touches the source files may have also influenced the need for precompilation. Also, a different environment, possibly involving a different package version may be responsible.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [December 8, 2022, 12:31am UTC](https://discourse.julialang.org/t/precompilation-of-module/91383/3 "2022-12-08T00:31:51Z")

</div>

One of these is the culprit more than likely. It is a pain and unexpected. It would be nice if the user could control this with compilation options like in C++: -O0, -O1, -O2. I have the impression that Julia is always compiled full blast. Cheers.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 8, 2022, 5:09am UTC](https://discourse.julialang.org/t/precompilation-of-module/91383/4 "2022-12-08T05:09:33Z")

</div>

Two options.

There’s a command line option:

```julia
    julia [switches] -- [programfile] [args...]

Switches (a '*' marks the default value, if applicable):
...
 -O, --optimize={0,1,2*,3} Set the optimization level (level 3 if `-O` is used without a level)

```

There is also a per-module option:

```julia
help?> Base.Experimental.@optlevel
  Experimental.@optlevel n::Int

  Set the optimization level (equivalent to the -O command line argument) for code in the current module. Submodules inherit the setting of their parent module.

  Supported values are 0, 1, 2, and 3.

  The effective optimization level is the minimum of that specified on the command line and in per-module settings. If a --min-optlevel value is set on the command line,
  that is enforced as a lower bound.

```

The above deals with native code generation. Note that “precompilation” does not refer to any of the above. It refers to parsing and type inference only, not native code generation.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [December 8, 2022, 3:09pm UTC](https://discourse.julialang.org/t/precompilation-of-module/91383/5 "2022-12-08T15:09:40Z")

</div>

Thanks! I will learn more about these options!

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 9, 2022, 2:29am UTC](https://discourse.julialang.org/t/precompilation-of-module/91383/6 "2022-12-09T02:29:00Z")

</div>

Just to be clear, Julia uses the LLVM compiler framework. The clang compiler also uses this framework. If you would like the gritty details of what each optimization level does in terms of LLVM options here is the source code:

> <https://github.com/JuliaLang/julia/blob/v1.3.1/src/jitlayers.cpp#L105>
