Artificial ownership chaining from precompilation directives


I want to know if it is possible to do some artificial way to give ownership of the precompilation directives generated from SnoopCompile.jl 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:
module PrecompileOwnerEnv
[importing all the packages those necessary]
function f()  
   [All missing precompile directives]
  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. :face_with_raised_eyebrow:


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.