Skip to content

Commit

Permalink
ensure that the non-REPL precompile code actually get precompiled (Ju…
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored and LilithHafner committed Mar 8, 2022
1 parent 75b989f commit f668c57
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,20 @@ function generate_precompile_statements()
module $pkgname
end
""")
tmp = tempname()
tmp_prec = tempname()
tmp_proc = tempname()
s = """
pushfirst!(DEPOT_PATH, $(repr(prec_path)));
Base.PRECOMPILE_TRACE_COMPILE[] = $(repr(tmp));
Base.PRECOMPILE_TRACE_COMPILE[] = $(repr(tmp_prec));
Base.compilecache(Base.PkgId($(repr(pkgname))), $(repr(path)))
$precompile_script
"""
run(`$(julia_exepath()) -O0 --sysimage $sysimg --startup-file=no -Cnative -e $s`)
for statement in split(read(tmp, String), '\n')
push!(statements, statement)
run(`$(julia_exepath()) -O0 --sysimage $sysimg --trace-compile=$tmp_proc --startup-file=no -Cnative -e $s`)
for f in (tmp_prec, tmp_proc)
for statement in split(read(f, String), '\n')
occursin("Main.", statement) && continue
push!(statements, statement)
end
end
end

Expand Down

0 comments on commit f668c57

Please sign in to comment.