Skip to content

Commit e8faf9d

Browse files
authored
ensure that the non-REPL precompile code actually get precompiled (#41898)
1 parent d612c47 commit e8faf9d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

contrib/generate_precompile.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,20 @@ function generate_precompile_statements()
250250
module $pkgname
251251
end
252252
""")
253-
tmp = tempname()
253+
tmp_prec = tempname()
254+
tmp_proc = tempname()
254255
s = """
255256
pushfirst!(DEPOT_PATH, $(repr(prec_path)));
256-
Base.PRECOMPILE_TRACE_COMPILE[] = $(repr(tmp));
257+
Base.PRECOMPILE_TRACE_COMPILE[] = $(repr(tmp_prec));
257258
Base.compilecache(Base.PkgId($(repr(pkgname))), $(repr(path)))
258259
$precompile_script
259260
"""
260-
run(`$(julia_exepath()) -O0 --sysimage $sysimg --startup-file=no -Cnative -e $s`)
261-
for statement in split(read(tmp, String), '\n')
262-
push!(statements, statement)
261+
run(`$(julia_exepath()) -O0 --sysimage $sysimg --trace-compile=$tmp_proc --startup-file=no -Cnative -e $s`)
262+
for f in (tmp_prec, tmp_proc)
263+
for statement in split(read(f, String), '\n')
264+
occursin("Main.", statement) && continue
265+
push!(statements, statement)
266+
end
263267
end
264268
end
265269

0 commit comments

Comments
 (0)