Skip to content

Commit

Permalink
Use same PrecompileTools.jl approach as REPL to precompile (#4024)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Sep 18, 2024
1 parent e5f400b commit 308f9d3
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,31 @@ let
return nothing
end

if Base.generating_output()
pkg_precompile()
# Copied from REPL (originally PrecompileTools.jl)
function check_edges(node)
parentmi = node.mi_info.mi
for child in node.children
childmi = child.mi_info.mi
if !(isdefined(childmi, :backedges) && parentmi childmi.backedges)
Base.precompile(childmi.specTypes)
end
check_edges(child)
end
end

if Base.generating_output() && Base.JLOptions().use_pkgimages != 0
Core.Compiler.Timings.reset_timings()
Core.Compiler.__set_measure_typeinf(true)
try
pkg_precompile()
finally
Core.Compiler.__set_measure_typeinf(false)
Core.Compiler.Timings.close_current_timer()
end
roots = Core.Compiler.Timings._timings[1].children
for child in roots
Base.precompile(child.mi_info.mi.specTypes)
check_edges(child)
end
end
end

0 comments on commit 308f9d3

Please sign in to comment.