# Artificial ownership chaining from precompilation directives

**URL:** <https://discourse.julialang.org/t/artificial-ownership-chaining-from-precompilation-directives/55405>\
**Category:** General Usage\
**Tags:** precompilation, snoopcompile\
**Created:** [February 16, 2021, 5:01pm UTC](https://discourse.julialang.org/t/artificial-ownership-chaining-from-precompilation-directives/55405 "2021-02-16T17:01:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Post date:** [February 16, 2021, 5:01pm UTC](https://discourse.julialang.org/t/artificial-ownership-chaining-from-precompilation-directives/55405/1 "2021-02-16T17:01:03Z")

</div>

Hey,

I want to know if it is possible to do some artificial way to give ownership of the precompilation directives generated from [SnoopCompile.jl](https://timholy.github.io/SnoopCompile.jl/stable/snoopi_deep_analysis/) to our package.  
My idea:

1. `@snoopi_deep` on a code  
 → export it to `precompile_all_missing.jl`  
 → generate all the importable packages necessary for the precompiled directives.
2. Create a package: PrecompileOwnerEnv with the above generated code. “PrecompileOwnerEnv.jl” would look like this:

```julia
module PrecompileOwnerEnv
[importing all the packages those necessary]
function f()  
   [All missing precompile directives]
end
f()
end

```

1. Then create\_sysimage from the package above.
2. Using the PrecompileOwnerEnv in the “main.jl” or anything you use as main module.

I guess this would by only possible if calling in an other module the `Base.precompile(Tuple{typeof(DemoPkg.f),Core.Int64})` would be appropriate for ownership chaining.

Aren’t there a way to do this somehow? The above mentioned didn’t seem to work for me I don’t know why. 🤨

---

<div class="post-metadata">

**Author:** ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Post date:** [February 16, 2021, 6:38pm UTC](https://discourse.julialang.org/t/artificial-ownership-chaining-from-precompilation-directives/55405/2 "2021-02-16T18:38:05Z")

</div>

Oh my… I think it is working! This way I can create artificial precompilation environment! I will check this in more detail!

The hard part is to make the precompilation directives to work, so for now I can make it work for packages those are installed, so like this: `Using ZygoteRules`.  
But this is already tremendous. For other package I couldn’t figure out how would this work, but I don’t see any limiting factor.
